使用thrift c在hbase中获取包含空列(不存在)的行++

nlejzf6q  于 2021-06-09  发布在  Hbase
关注(0)|答案(0)|浏览(218)

我需要使用thrift c++在hbase中获取包含空列(不存在)的行。有些行有这个列,有些没有。
我有下面的代码和过滤器,这是完美的工作,但我如何才能得到行与不存在的列?

/* Connection to the thrift server */
boost::shared_ptr<TSocket> socket(new TSocket("localhost", 9090));
boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));

/* Creating the Hbase client*/
HbaseClient client(protocol);

try
{
    /* Open the client transport*/
    transport->open();

    /* The table name */
    std::string t("sometable");

/* Open the scanner: need to scan with a filter*/
StrVec columnNames;
StrMap atr_test;
TScan tscan;
std::string filterStr;
filterStr = "SingleColumnValueFilter('ColumnFamily', 'ColumnQualifier', =, 'substring:value', true, false)";
tscan.__set_filterString(filterStr);

int scanner = client.scannerOpenWithScan(t, tscan, atr_test);

while (true) {
    std::vector<TRowResult> value;
    client.scannerGet(value, scanner);
        // Print value
        for (CellMap::const_iterator it = value[0].columns.begin(); it != value[0].columns.end(); ++it) {
            std::cout << "     " << it->first << " => " << it->second.value << ";\n";
        }

    }
}

我在这里读过setfilterifmissing—如何过滤出具有给定列(非空)的行?但是如何在代码中实现它呢?或者有别的解决办法?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题