^_^ 大家好:
如何在 Thrift 的 C++ 中使用方法“scannerOpenWithScan()”和 filterString。hbase 版本是 hbase-0.92.1。
我想根据列的值选择行,所以我将scannerOpenWithScan()添加到“examples/thrift/DemoClient.cpp”中:
/**
* open a scanner with scan (filter string)
*/
320 TScan tscan;
321 std::string filterStr;
322 filterStr = "SingleColumnValueFilter (<=, '25', 'entry', 'num', true, false)";
323 tscan.__set_filterString(filterStr);
324
325 std::cout << "Starting scanner with scan..." << std::endl;
326 scanner = client.scannerOpenWithScan(t, tscan);
327 std::cout << "The scanner id is " << scanner << std::endl;
328 try { ...... }
但是没有返回扫描仪ID,错误是:
Starting scanner with scan...
ERROR: No more data to read.
thrift.log 错误是:
796 java.lang.IllegalArgumentException: Incorrect filter string SingleColumnValueFilter(<=, '25', 'entry', 'num', true, false)
797 at org.apache.hadoop.hbase.filter.ParseFilter.parseSimpleFilterExpression(ParseFilter.java:250)
798 at org.apache.hadoop.hbase.filter.ParseFilter.parseFilterString(ParseFilter.java:168)
799 at org.apache.hadoop.hbase.thrift.ThriftServer$HBaseHandler.scannerOpenWithScan(ThriftServer.java:766)
thrift.out 是:
java.lang.reflect.InvocationTargetException
6 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
7 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
8 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
9 at java.lang.reflect.Method.invoke(Method.java:616)
10 at org.apache.hadoop.hbase.filter.ParseFilter.parseSimpleFilterExpression(ParseFilter.java:240)
11 at org.apache.hadoop.hbase.filter.ParseFilter.parseFilterString(ParseFilter.java:168)
12 at org.apache.hadoop.hbase.thrift.ThriftServer$HBaseHandler.scannerOpenWithScan(ThriftServer.java:766)
13 at org.apache.hadoop.hbase.thrift.generated.Hbase$Processor$scannerOpenWithScan.getResult(Hbase.java:3821)
我对此一无所知。有谁知道如何使用具有过滤功能的 C++ 来访问 HBase?