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

This commit is contained in:
tedyu 2015-11-23 20:26:18 -08:00
parent 81e7eb2805
commit 447a0e7b7e
2 changed files with 16 additions and 0 deletions

View File

@ -568,6 +568,9 @@ public class HColumnDescriptor implements WritableComparable<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 ImmutableBytesWritable(key),
new ImmutableBytesWritable(value));
return this;

View File

@ -134,6 +134,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 {