HBASE-22011 ThriftUtilities.getFromThrift should set filter when not set columns

This commit is contained in:
Bing Xiao 2019-03-11 15:16:15 +08:00 committed by zhengyan.ywl
parent 10ca598004
commit 8a2ee8339a
2 changed files with 29 additions and 10 deletions

View File

@ -180,18 +180,16 @@ public final class ThriftUtilities {
out.setCheckExistenceOnly(in.isExistence_only()); out.setCheckExistenceOnly(in.isExistence_only());
} }
if (in.isSetColumns()) {
if (!in.isSetColumns()) { for (TColumn column : in.getColumns()) {
return out; if (column.isSetQualifier()) {
} out.addColumn(column.getFamily(), column.getQualifier());
} else {
for (TColumn column : in.getColumns()) { out.addFamily(column.getFamily());
if (column.isSetQualifier()) { }
out.addColumn(column.getFamily(), column.getQualifier());
} else {
out.addFamily(column.getFamily());
} }
} }
if (in.isSetFilterBytes()) { if (in.isSetFilterBytes()) {
out.setFilter(filterFromThrift(in.getFilterBytes())); out.setFilter(filterFromThrift(in.getFilterBytes()));
} }

View File

@ -56,6 +56,7 @@ import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder; 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.ColumnValueFilter;
import org.apache.hadoop.hbase.filter.FilterList; import org.apache.hadoop.hbase.filter.FilterList;
import org.apache.hadoop.hbase.filter.PrefixFilter; import org.apache.hadoop.hbase.filter.PrefixFilter;
@ -315,6 +316,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 @Test
public void testMultiGet() throws Exception { public void testMultiGet() throws Exception {
testMultiGet(thriftConnection, "testMultiGetTable"); testMultiGet(thriftConnection, "testMultiGetTable");