hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [05/23] hbase git commit: HBASE-16014 Get and Put constructor argument lists are divergent
Date Mon, 27 Mar 2017 20:09:03 GMT
HBASE-16014 Get and Put constructor argument lists are divergent

Signed-off-by: CHIA-PING TSAI <chia7712@gmail.com>


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

Branch: refs/heads/hbase-12439
Commit: 9c8f02e4ef3037e8eaf649360ce83a898c3b20e1
Parents: a41b185
Author: brandboat <brandboat@gmail.com>
Authored: Sat Mar 18 18:02:42 2017 +0800
Committer: CHIA-PING TSAI <chia7712@gmail.com>
Committed: Tue Mar 21 09:33:24 2017 +0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/client/Get.java     | 22 ++++++++++++++++++++
 .../org/apache/hadoop/hbase/client/TestGet.java | 12 +++++++++++
 2 files changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/9c8f02e4/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Get.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Get.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Get.java
index a581ed5..3771aff 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Get.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Get.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.client;
 
 
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -130,6 +131,27 @@ public class Get extends Query
     }
   }
 
+  /**
+   * Create a Get operation for the specified row.
+   * @param row
+   * @param rowOffset
+   * @param rowLength
+   */
+  public Get(byte[] row, int rowOffset, int rowLength) {
+    Mutation.checkRow(row, rowOffset, rowLength);
+    this.row = Bytes.copy(row, rowOffset, rowLength);
+  }
+
+  /**
+   * Create a Get operation for the specified row.
+   * @param row
+   */
+  public Get(ByteBuffer row) {
+    Mutation.checkRow(row);
+    this.row = new byte[row.remaining()];
+    row.get(this.row);
+  }
+
   public boolean isCheckExistenceOnly() {
     return checkExistenceOnly;
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/9c8f02e4/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestGet.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestGet.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestGet.java
index 810f6bc..6a2bb39 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestGet.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestGet.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.lang.reflect.InvocationTargetException;
 import java.util.Arrays;
 import java.util.List;
@@ -241,4 +242,15 @@ public class TestGet {
     assertEquals("my.MockFilter", filters.get(1).getClass().getName());
     assertTrue(filters.get(2) instanceof KeyOnlyFilter);
   }
+
+  @Test
+  public void testGetRowConstructor() {
+    byte[] row1 = Bytes.toBytes("testRow");
+    byte[] row2 = Bytes.toBytes("testtestRow");
+    ByteBuffer rowBuffer = ByteBuffer.allocate(16);
+    rowBuffer = ByteBuffer.wrap(row1);
+    Get get1 = new Get(rowBuffer);
+    Get get2 = new Get(row2, 4, 7);
+    Assert.assertArrayEquals(get1.getRow(), get2.getRow());
+  }
 }


Mime
View raw message