nebula-cpp3.0读边数据为空

  • nebula 版本:3.0

  • 部署方式:单机

  • 安装方式:rpm

  • 是否为线上版本:n

  • 问题的具体描述
    物理机上部署新版的nebula3.0和cpp-client3.0和3.0版的nebula-console,在线导入nba数据集,控制台可以正常读取边数据,但是编译StorageClientExample.cpp文件执行后读出边结果为空;编译SessionExample.cpp执行时无法连接graph服务。
    另外换了basketballplayer数据集,结果只有部分边的属性,但是没有边数据。

3.0需要添加hosts,否则报错:Zone not enough!,添加方式如下(单机环境不知道这种添加方式对不对,但是可以用),

(root@nebula) [(none)]> :play nba;
Start loading dataset nba...
Error: load dataset failed, an error occurred when executing: CREATE SPACE nba(VID_TYPE=FIXED_STRING(32));USE nba;, [ERROR (-1005)]: Zone not enough!
(root@nebula) [(none)]> add hosts 127.0.0.1:9779;
(root@nebula) [(none)]> :play nba;
(root@nebula) [(none)]> show hosts
+-------------+------+----------+--------------+---------------------+------------------------+---------+
| Host        | Port | Status   | Leader count | Leader distribution | Partition distribution | Version |
+-------------+------+----------+--------------+---------------------+------------------------+---------+
| "127.0.0.1" | 9779 | "ONLINE" | 100          | "nba:100"           | "nba:100"              | "3.0.0" |
+-------------+------+----------+--------------+---------------------+------------------------+---------+
Got 1 rows (time spent 2060/3104 us)

通过console控制台命令可以读取边数据,但是通过StorageClientExample.cpp程序读取为空,如下:

[root@764eb88e07cd examples]# ./session_example 
scan edge...
-------------------------
like.likeness|


+++++++++++++++++++++++++

通过SessionExample.cpp程序也无法正常运行,一直就卡着不动,如下:

[root@764eb88e07cd examples]# ./session_example 
Current address: 127.0.0.1:9669

于是换了basketballplayer的测试集,控制台可以正常遍历边数据,但是cpp-client结果只能读取部分数据,而且只有属性值,没有边数据,如下:

[root@764eb88e07cd examples]# ./session_example 
scan edge...
-------------------------
follow.degree|
95|
95|
80|
80|
90|
80|
90|
90|


+++++++++++++++++++++++++

[root@764eb88e07cd examples]# ./session_example 
scan edge...
-------------------------
serve.start_year|serve.end_year|
1997|2016|
2011|2015|
2015|2017|
2017|2019|
2012|2019|
2009|2012|
2014|2019|
2012|2013|
2007|2012|
1994|2000|


+++++++++++++++++++++++++
-------------------------
serve.start_year|serve.end_year|
2000|2007|
2018|2019|


+++++++++++++++++++++++++

cpp client的示例程序的基本参数都没变,看了个帖子说貌似跟partition_num 或者partID这个有关,不知道咋设置,而且client程序关于配置和使用也没有太多的说明。

    nebula::ScanEdgeIter scanEdgeIter = c.scanEdgeWithPart("basketballplayer",
                                           1,
                                           "serve",
                                           std::vector<std::string>{},
                                           10,
                                           0,
                                           std::numeric_limits<int64_t>::max(),
                                           "",
                                           true,
                                           true);
    std::cout << "scan edge..." << std::endl;
    while (scanEdgeIter.hasNext()) {
        std::cout << "-------------------------" << std::endl;
        nebula::DataSet ds = scanEdgeIter.next();
        std::cout << ds << std::endl;
        std::cout << "+++++++++++++++++++++++++" << std::endl;
    }

    return 0;
}
1 个赞

目前nebula-cpp的storageClient主要是给内部用的, 所以没啥文档.
nebula-java和nebula-python的storageClient是专门提供给用户用的.

但是cpp-client结果只能读取部分数据,而且只有属性值,没有边数据
如果需要取到边上的src, dst, rank那些默认属性, 可以试着改下这里, 在set_props的参数那个vector里加入"_src", “_type”, “_dst”, "_rank"这些属性

https://github.com/vesoft-inc/nebula-cpp/blob/eb894a119341f29bd129f002b8565f4889b61116/src/sclient/StorageClient.cpp#L67

ok 回头试一下,主要想着cpp客户端读大图的话速度可以快点,java的目前还没试过,Python的速度太慢了。另外cpp client 的storageClient模块啥时候支持用户使用啊?

另外,数据只能读取部分,不能全部读出怎么解决啊?我想把一种边的所有边数据都读出来

scanEdgeWithPart参数的第二个参数是partID, 意思是只会从这个partition读数据, 你如果要读所有part数据, 那需要遍历所有partId(partID的值的取值范围是1到create space时指定的partition_num数), 对每个partID调用scanEdgeWithPart函数
代码大概长这样子:

for (int partId = 1; partId <= 100; ++partID) {
    nebula::ScanEdgeIter scanEdgeIter = c.scanEdgeWithPart("basketballplayer",
                                           partID,
                                           "serve",
                                           std::vector<std::string>{},
                                           10,
                                           0,
                                           std::numeric_limits<int64_t>::max(),
                                           "",
                                           true,
                                           true);
    std::cout << "scan edge..." << std::endl;
 
    while (scanEdgeIter.hasNext()) {
        std::cout << "-------------------------" << std::endl;
        nebula::DataSet ds = scanEdgeIter.next();
        std::cout << ds << std::endl;
        std::cout << "+++++++++++++++++++++++++" << std::endl;
    }
}
1 个赞

明白了 多谢!

此话题已在最后回复的 7 天后被自动关闭。不再允许新回复。