关于java客户端创建tag并建立对应的索引,怎么能在资源完全创建成功之后返回一个值呢?

  1. meta 的日志:

创建已经存在的index的edge,报错
删除一个有index的tag,报错

  1. graph 的日志:
    做lookup查询的时候,你查询的label的schema信息还没加载到缓存,缓存拿不到所以报错

3 stderr.log 就是graph的日志。

你好,请问一下2.0版本的java client,这行代码用什么替代呢,我看了example,没有metaClient的代码,是取消掉这个方法了是吗?请问下我可以怎么处理来获取schema呢?
image
image

你看这里

谢谢 解决了,另外请问下,获取节点的VertexID,现在是必须通过storageClient吗,像以下这样(1.0.0是通过graphClient有一个getId()的方法):
public static void scanVertex(StorageClient client) {
ScanVertexResultIterator iterator = client.scanVertex(
“test”,
“person”,
Arrays.asList(“name”, “age”));

    while (iterator.hasNext()) {
        ScanVertexResult result = null;
        try {
            result = iterator.next();
        } catch (Exception e) {
            LOGGER.error("scan error, ", e);
            System.exit(1);
        }
        if (result.isEmpty()) {
            continue;
        }
        System.out.println(result.getPropNames());
        List<VertexRow> vertexRows = result.getVertices();
        for (VertexRow row : vertexRows) {
            if (result.getVertex(row.getVid()) != null) {
                System.out.println("vid : " + result.getVertex(row.getVid()));
            }
        }
        System.out.println(result.getVidVertices());


        System.out.println("result vertex table view:");
        List<VertexTableRow> vertexTableRows = result.getVertexTableRows();
        for (VertexTableRow vertex : vertexTableRows) {
            try {
                System.out.println("_vid: " + vertex.getVid().asString());
                System.out.println(vertex.getValues());
            } catch (UnsupportedEncodingException e) {
                LOGGER.error("decode String error, ", e);
            }
        }
        System.out.println(result.getVertices());
    }
}

2.0 通过GraphClient和StorageClient都是可以获取节点的vertexId; 1.0是有 vid 的类型的,所以GraphClient可以提供 getId 接口,但是2.0没有vid这个类型,假如是多列返回,返回的数据哪一列是 VertexId,用户自己肯定知道,space设置的是int的VertexId,通过 ValueWrapper::asInt()获得int的VertexId ,VertexId 为string的时候,就是 ValueWrapper::asString()。这两个对于GraphClient和StorageClient都是通用的。
假如返回的是Vertex这样的数据结构,那么直接可以ValueWrapper::asNode().getId() 可以获取 VertexId

1 个赞

谢谢!再请问下,1.0版本的graphClient.switchSpace()方法选择图空间,现在2.0怎么处理呢,执行语句 "use " + spaceName吗?还有别的处理方法吗请问

目前就是只有让用户自己执行 "use " + spaceName 来达到切换space

请问下,我用storageClient获取vertex,报错没有找到space:test。但是我明明创建了spaceName为test的space,下面是我的代码和报错截图。


storageClient传进去的还是metad的端口,你把44500改成45500

metad是45500,storage是44500,没写错啊

new StorageClient(ip, 45500)

改了,也就是metad和storage的端口要写一样的? 没明白。
改了之后日志是这样,没有报错,但没有获取到vertex
image

请问下用storageClient的这个scanVertex方法怎么获取不到vertex呢?而且为什么两个服务要传同一个端口?

storageclient是通过向meta服务获取storage的地址信息的,所以用的是meta的地址和端口。至于为什么没有点信息,你确定你导入数据了吗?你用console查询截图下

是的,就最初始的数据,插入了,我加行代码吧,如下:


你的resp获取的代码截图下吧?或者你直接到console下面执行吧,更直观点。

image

你用的服务端版本是什么,原来这个问题用的是1.0的,你现在用的服务端是2.0,具体用2.0 什么版本?还有java client是什么版本。
还有麻烦你以后不要在在一个问题下面无限问问题,新的问题开新的问题单,这样方便记录和查找。

1 个赞