HBASE-14737 Clear cachedMaxVersions when HColumnDescriptor#setValue(VERSIONS, value) is called (Pankaj Kumar)

This commit is contained in:
tedyu 2015-11-23 20:13:00 -08:00
parent 6b11adbfa4
commit 9a91f5ac81
2 changed files with 16 additions and 0 deletions

View File

@ -439,6 +439,9 @@ public class HColumnDescriptor implements Comparable<HColumnDescriptor> {
* @return this (for chained invocation)
*/
public HColumnDescriptor setValue(byte[] key, byte[] value) {
if (Bytes.compareTo(Bytes.toBytes(HConstants.VERSIONS), key) == 0) {
cachedMaxVersions = UNINITIALIZED;
}
values.put(new Bytes(key),
new Bytes(value));
return this;

View File

@ -133,6 +133,19 @@ public class TestHColumnDescriptorDefaultVersions {
admin.deleteTable(TABLE_NAME);
}
}
@Test
public void testHColumnDescriptorCachedMaxVersions() throws Exception {
HColumnDescriptor hcd = new HColumnDescriptor(FAMILY);
hcd.setMaxVersions(5);
// Verify the max version
assertEquals(5, hcd.getMaxVersions());
// modify the max version
hcd.setValue(Bytes.toBytes(HConstants.VERSIONS), Bytes.toBytes("8"));
// Verify the max version
assertEquals(8, hcd.getMaxVersions());
}
private void verifyHColumnDescriptor(int expected, final TableName tableName,
final byte[]... families) throws IOException {