使用Thrift c ++

时间:2015-05-01 10:27:34

标签: c++ null hbase thrift isnull

我需要使用Thrift c ++在Hbase中获取带有NULL列(不存在)的行。有些行包含此列,有些行没有。

我有以下代码与过滤器,它完美地工作,但我怎么能得到不存在列的行?

/* 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的内容 - How to filter out rows with given column(not null)?,但我怎么能在我的代码中实现它呢? 或者也许有其他解决方案?

0 个答案:

没有答案