HBASE-14737 Clear cachedMaxVersions when HColumnDescriptor#setValue(VERSIONS, value) is called (Pankaj Kumar)
This commit is contained in:
parent
6b11adbfa4
commit
9a91f5ac81
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue