hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [16/24] hbase git commit: HBASE-14737 Clear cachedMaxVersions when HColumnDescriptor#setValue(VERSIONS, value) is called (Pankaj Kumar)
Date Tue, 24 Nov 2015 22:29:53 GMT
HBASE-14737 Clear cachedMaxVersions when HColumnDescriptor#setValue(VERSIONS, value) is called
(Pankaj Kumar)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/9a91f5ac
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/9a91f5ac
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/9a91f5ac

Branch: refs/heads/hbase-12439
Commit: 9a91f5ac818b078526962e5c64183a2541a064b4
Parents: 6b11adb
Author: tedyu <yuzhihong@gmail.com>
Authored: Mon Nov 23 20:13:00 2015 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Mon Nov 23 20:13:00 2015 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/HColumnDescriptor.java     |  3 +++
 .../hbase/TestHColumnDescriptorDefaultVersions.java    | 13 +++++++++++++
 2 files changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/9a91f5ac/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java
index 4daf6ef..2c10308 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/hbase/blob/9a91f5ac/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHColumnDescriptorDefaultVersions.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHColumnDescriptorDefaultVersions.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHColumnDescriptorDefaultVersions.java
index 94df71f..8d0557f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHColumnDescriptorDefaultVersions.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHColumnDescriptorDefaultVersions.java
@@ -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 {


Mime
View raw message