gpt4 book ai didi

c++ - 在 C++ 中使用 Hbase Thrift2 API

转载 作者:太空狗 更新时间:2023-10-29 23:13:49 25 4
gpt4 key购买 nike

我一直在 C++ 中使用 HBase 的 Thrift API(示例用法 here ),但现在我需要改用 Thrift2。我知道有在其他语言(例如 C#、Python 和 Java)中使用 Thrift2 的示例,但我找不到 C++ 的文档。

这是我当前调用 Thrift API 的代码:

transport->open();
std::string t("demo_table");

/ Scan all tables, look for the demo table and delete it. /
std::cout << "scanning tables..." << std::endl;
StrVec tables;
client.getTableNames(tables);
for (StrVec::const_iterator it = tables.begin(); it != tables.end(); ++it) {
std::cout << " found: " << *it << std::endl;
if (t == *it) {
if (client.isTableEnabled(*it)) {
std::cout << " disabling table: " << *it << std::endl;
client.disableTable(*it);
}
std::cout << " deleting table: " << *it << std::endl;
client.deleteTable(*it);
}
}

现在切换到 Thrift2 后失败了。例如,client.getTableNames() 不再有效(该函数不存在)。

最佳答案

从 hbase thrift2 接口(interface)中删除了一些功能。如果你只想获取 hbase 中的表名列表,你可以使用 get children of/hbase/table in zookeeper。

struct String_vector paths;
int ret = zoo_get_children(zkhandle,"/hbase/table", 0,&paths);//
if(ret)
{
std::cout << "zoo_get_children error " << ret << std::endl;
} else {
for(i = 0;i < paths.count;i++)
printf("/hbase/table/%s\n",paths.data[i]);
free_vector(&paths);
}

关于c++ - 在 C++ 中使用 Hbase Thrift2 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37059144/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com