Repository: hbase Updated Branches: refs/heads/branch-1.2 76f599de9 -> 8eac32fe9
HBASE-20231 Not able to delete column family from a row using RemoteHTable Signed-off-by: Ashish Singhi <ashishsin...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8eac32fe Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8eac32fe Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8eac32fe Branch: refs/heads/branch-1.2 Commit: 8eac32fe92cc960490a9f560133b5be2c05558b4 Parents: 76f599d Author: Pankaj Kumar <pankaj...@huawei.com> Authored: Wed Apr 4 14:44:12 2018 +0530 Committer: Ashish Singhi <ashishsin...@apache.org> Committed: Wed Apr 4 14:44:12 2018 +0530 ---------------------------------------------------------------------- .../hadoop/hbase/rest/client/RemoteHTable.java | 7 +++++-- .../hbase/rest/client/TestRemoteTable.java | 22 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/8eac32fe/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java index 8c5c168..e878794 100644 --- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java +++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java @@ -109,13 +109,16 @@ public class RemoteHTable implements Table { Iterator ii = quals.iterator(); while (ii.hasNext()) { sb.append(Bytes.toStringBinary((byte[])e.getKey())); - sb.append(':'); Object o = ii.next(); // Puts use byte[] but Deletes use KeyValue if (o instanceof byte[]) { + sb.append(':'); sb.append(Bytes.toStringBinary((byte[])o)); } else if (o instanceof KeyValue) { - sb.append(Bytes.toStringBinary(((KeyValue)o).getQualifier())); + if (((KeyValue) o).getQualifierLength() != 0) { + sb.append(':'); + sb.append(Bytes.toStringBinary(((KeyValue) o).getQualifier())); + } } else { throw new RuntimeException("object type not handled"); } http://git-wip-us.apache.org/repos/asf/hbase/blob/8eac32fe/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteTable.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteTable.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteTable.java index 121ff65..cd33edd 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteTable.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteTable.java @@ -330,18 +330,27 @@ public class TestRemoteTable { Put put = new Put(ROW_3); put.add(COLUMN_1, QUALIFIER_1, VALUE_1); put.add(COLUMN_2, QUALIFIER_2, VALUE_2); + put.add(COLUMN_3, QUALIFIER_1, VALUE_1); + put.add(COLUMN_3, QUALIFIER_2, VALUE_2); remoteTable.put(put); Get get = new Get(ROW_3); get.addFamily(COLUMN_1); get.addFamily(COLUMN_2); + get.addFamily(COLUMN_3); Result result = remoteTable.get(get); byte[] value1 = result.getValue(COLUMN_1, QUALIFIER_1); byte[] value2 = result.getValue(COLUMN_2, QUALIFIER_2); + byte[] value3 = result.getValue(COLUMN_3, QUALIFIER_1); + byte[] value4 = result.getValue(COLUMN_3, QUALIFIER_2); assertNotNull(value1); assertTrue(Bytes.equals(VALUE_1, value1)); assertNotNull(value2); assertTrue(Bytes.equals(VALUE_2, value2)); + assertNotNull(value3); + assertTrue(Bytes.equals(VALUE_1, value3)); + assertNotNull(value4); + assertTrue(Bytes.equals(VALUE_2, value4)); Delete delete = new Delete(ROW_3); delete.addColumn(COLUMN_2, QUALIFIER_2); @@ -371,6 +380,19 @@ public class TestRemoteTable { assertTrue(Bytes.equals(VALUE_1, value1)); assertNull(value2); + // Delete column family from row + delete = new Delete(ROW_3); + delete.addFamily(COLUMN_3); + remoteTable.delete(delete); + + get = new Get(ROW_3); + get.addFamily(COLUMN_3); + result = remoteTable.get(get); + value3 = result.getValue(COLUMN_3, QUALIFIER_1); + value4 = result.getValue(COLUMN_3, QUALIFIER_2); + assertNull(value3); + assertNull(value4); + delete = new Delete(ROW_3); remoteTable.delete(delete);