hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-14737 Clear cachedMaxVersions when HColumnDescriptor#setValue(VERSIONS, value) is called (Pankaj Kumar)
Date Tue, 24 Nov 2015 04:28:52 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.2 4916e3805 -> 68f8f87bd


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/68f8f87b
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/68f8f87b
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/68f8f87b

Branch: refs/heads/branch-1.2
Commit: 68f8f87bdc60e9941252561665c5f85dd7e97a7b
Parents: 4916e38
Author: tedyu <yuzhihong@gmail.com>
Authored: Mon Nov 23 20:28:43 2015 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Mon Nov 23 20:28:43 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/68f8f87b/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 542d928..480aff9 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
@@ -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;

http://git-wip-us.apache.org/repos/asf/hbase/blob/68f8f87b/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 17ad36d..4660bbb 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
@@ -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 {


Mime
View raw message