You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by op...@apache.org on 2019/03/11 11:46:09 UTC

[hbase] 23/24: HBASE-22011 ThriftUtilities.getFromThrift should set filter when not set columns

This is an automated email from the ASF dual-hosted git repository.

openinx pushed a commit to branch HBASE-21879
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 6cb2dbe581da8e9b0d0fd89245b89805e20f4954
Author: Bing Xiao <bu...@gmail.com>
AuthorDate: Mon Mar 11 15:16:15 2019 +0800

    HBASE-22011 ThriftUtilities.getFromThrift should set filter when not set columns
---
 .../hadoop/hbase/thrift2/ThriftUtilities.java       | 18 ++++++++----------
 .../hadoop/hbase/thrift2/TestThriftConnection.java  | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java
index 204d20d..1fc85e5 100644
--- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java
+++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java
@@ -180,18 +180,16 @@ public final class ThriftUtilities {
       out.setCheckExistenceOnly(in.isExistence_only());
     }
 
-
-    if (!in.isSetColumns()) {
-      return out;
-    }
-
-    for (TColumn column : in.getColumns()) {
-      if (column.isSetQualifier()) {
-        out.addColumn(column.getFamily(), column.getQualifier());
-      } else {
-        out.addFamily(column.getFamily());
+    if (in.isSetColumns()) {
+      for (TColumn column : in.getColumns()) {
+        if (column.isSetQualifier()) {
+          out.addColumn(column.getFamily(), column.getQualifier());
+        } else {
+          out.addFamily(column.getFamily());
+        }
       }
     }
+
     if (in.isSetFilterBytes()) {
       out.setFilter(filterFromThrift(in.getFilterBytes()));
     }
diff --git a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftConnection.java b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftConnection.java
index 2c9bf69..a11f2e8 100644
--- a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftConnection.java
+++ b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftConnection.java
@@ -56,6 +56,7 @@ import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.client.TableDescriptor;
 import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
+import org.apache.hadoop.hbase.filter.ColumnCountGetFilter;
 import org.apache.hadoop.hbase.filter.ColumnValueFilter;
 import org.apache.hadoop.hbase.filter.FilterList;
 import org.apache.hadoop.hbase.filter.PrefixFilter;
@@ -316,6 +317,26 @@ public class TestThriftConnection {
   }
 
   @Test
+  public void testHBASE22011()throws Exception{
+    testHBASE22011(thriftConnection, "testHBASE22011Table");
+    testHBASE22011(thriftHttpConnection, "testHBASE22011HttpTable");
+  }
+
+  public void testHBASE22011(Connection connection, String tableName) throws IOException {
+    createTable(thriftAdmin, tableName);
+    try (Table table = connection.getTable(TableName.valueOf(tableName))){
+      Get get = new Get(ROW_2);
+      Result result = table.get(get);
+      assertEquals(2, result.listCells().size());
+
+      ColumnCountGetFilter filter = new ColumnCountGetFilter(1);
+      get.setFilter(filter);
+      result = table.get(get);
+      assertEquals(1, result.listCells().size());
+    }
+  }
+
+  @Test
   public void testMultiGet() throws Exception {
     testMultiGet(thriftConnection, "testMultiGetTable");
     testMultiGet(thriftHttpConnection, "testMultiGetHttpTable");