HBASE-13711 Provide an API to set min and max versions in HColumnDescriptor (Stephen Yuan Jiang)
This commit is contained in:
parent
88f19ab697
commit
77d9719e2b
|
@ -504,6 +504,30 @@ public class HColumnDescriptor implements Comparable<HColumnDescriptor> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set minimum and maximum versions to keep
|
||||||
|
*
|
||||||
|
* @param minVersions minimal number of versions
|
||||||
|
* @param maxVersions maximum number of versions
|
||||||
|
* @return this (for chained invocation)
|
||||||
|
*/
|
||||||
|
public HColumnDescriptor setVersions(int minVersions, int maxVersions) {
|
||||||
|
if (minVersions <= 0) {
|
||||||
|
// TODO: Allow minVersion and maxVersion of 0 to be the way you say "Keep all versions".
|
||||||
|
// Until there is support, consider 0 or < 0 -- a configuration error.
|
||||||
|
throw new IllegalArgumentException("Minimum versions must be positive");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxVersions < minVersions) {
|
||||||
|
throw new IllegalArgumentException("Unable to set MaxVersion to " + maxVersions
|
||||||
|
+ " and set MinVersion to " + minVersions
|
||||||
|
+ ", as maximum versions must be >= minimum versions.");
|
||||||
|
}
|
||||||
|
setMinVersions(minVersions);
|
||||||
|
setMaxVersions(maxVersions);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The storefile/hfile blocksize for this column family.
|
* @return The storefile/hfile blocksize for this column family.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -59,8 +59,7 @@ public class ChangeVersionsAction extends Action {
|
||||||
|
|
||||||
int versions = random.nextInt(3) + 1;
|
int versions = random.nextInt(3) + 1;
|
||||||
for(HColumnDescriptor descriptor:columnDescriptors) {
|
for(HColumnDescriptor descriptor:columnDescriptors) {
|
||||||
descriptor.setMaxVersions(versions);
|
descriptor.setVersions(versions, versions);
|
||||||
descriptor.setMinVersions(versions);
|
|
||||||
}
|
}
|
||||||
LOG.debug("Performing action: Changing versions on " + tableName.getNameAsString());
|
LOG.debug("Performing action: Changing versions on " + tableName.getNameAsString());
|
||||||
admin.modifyTable(tableName, tableDescriptor);
|
admin.modifyTable(tableName, tableDescriptor);
|
||||||
|
|
Loading…
Reference in New Issue