Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

客户端报错 Cannot evaluate com.vesoft.nebula.client.graph.data.ResultSet.toString() #335

Closed
an-shi-chi-fan opened this issue Aug 5, 2021 · 14 comments

Comments

@an-shi-chi-fan
Copy link

nebula版本: 2.0.1
客户端版本:2.0.0
使用代码:

       NebulaPoolConfig nebulaPoolConfig = new NebulaPoolConfig();
        nebulaPoolConfig.setMaxConnSize(10);
        List<HostAddress> addresses = Arrays.asList(new HostAddress("127.0.0.1", 9669));
        NebulaPool pool = new NebulaPool();
        pool.init(addresses, nebulaPoolConfig);
        Session session = pool.getSession("root", "nebula", false);
        ResultSet res = session.execute("show edges");  ```

这个为什么会报错是版本不对应吗但是我编译了2.0.1的客户端版本编译的jar依旧是2.0.0 新手求救
@laura-ding
Copy link
Contributor

Import the wrong ResultSet module?
the module name is import com.vesoft.nebula.client.graph.data.ResultSet;

@an-shi-chi-fan
Copy link
Author

import com.vesoft.nebula.client.graph.NebulaPoolConfig;
import com.vesoft.nebula.client.graph.data.HostAddress;
import com.vesoft.nebula.client.graph.data.ResultSet;
import com.vesoft.nebula.client.graph.net.NebulaPool;
import com.vesoft.nebula.client.graph.net.Session;

没有导入错误

@laura-ding
Copy link
Contributor

There maybe exists the null pointer in the old version of toString, so the IDE receives this exception and reports this error. The master code has fixed the null pointer issue so that the IDE does not report errors.

@an-shi-chi-fan
Copy link
Author

        <!-- https://mvnrepository.com/artifact/com.vesoft/client -->
        <dependency>
            <groupId>com.vesoft</groupId>
            <artifactId>client</artifactId>
            <version>2.0.0</version>
        </dependency>

是不是这个版本的客户端不支持nebula 2.0.1版本

@an-shi-chi-fan
Copy link
Author

请问一下我现在安装的nebula需要引入什么版本的客户端呢,是需要下载客户端源码自己编译master分支吗

@laura-ding
Copy link
Contributor

请问一下我现在安装的nebula需要引入什么版本的客户端呢,是需要下载客户端源码自己编译master分支吗

The master client couldn’t use 2.0.1 server, it must use master server.

@an-shi-chi-fan
Copy link
Author

那这个nebula2.0.1 是不是目前没有客户端可以用?

@laura-ding
Copy link
Contributor

那这个nebula2.0.1 是不是目前没有客户端可以用?

2.0.0 client can use with 2.0.0/2.0.1 server

@an-shi-chi-fan
Copy link
Author

可是我目前使用的2.0.0版本的客户端会报错 空指针异常啊,but client v2.0.0 it does not work!
我需要怎么做呢

@laura-ding
Copy link
Contributor

laura-ding commented Aug 6, 2021

可是我目前使用的2.0.0版本的客户端会报错 空指针异常啊,but client v2.0.0 it does not work!
我需要怎么做呢

That's just a warning from the IDE.
Or you can use #334 install to local, and your project use the 2.0.1 version client.

@an-shi-chi-fan
Copy link
Author

非常感谢!!,这个问题已经解决了,我发现我使用客户端的时候必须先指定space,如果不指定运行时就会提示空指针异常。

其实这边建议没指定space的话客户端给个未指定space的错误提示。

@laura-ding
Copy link
Contributor

非常感谢!!,这个问题已经解决了,我发现我使用客户端的时候必须先指定space,如果不指定运行时就会提示空指针异常。

其实这边建议没指定space的话客户端给个未指定space的错误提示。

Can you provide the picture information of the exception?
There is no limit on whether or not you can specify space, not all commands need to specify space, so this one will not be prompted.

@an-shi-chi-fan
Copy link
Author

先贴上我的代码

package fun;


import com.vesoft.nebula.client.graph.NebulaPoolConfig;
import com.vesoft.nebula.client.graph.data.HostAddress;
import com.vesoft.nebula.client.graph.data.ResultSet;
import com.vesoft.nebula.client.graph.data.ValueWrapper;
import com.vesoft.nebula.client.graph.net.NebulaPool;
import com.vesoft.nebula.client.graph.net.Session;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.List;

/**
 * @FileDescription
 * @Create 2021-08-03 9:59
 */
public class CuraterTest {
    public static void main(String[] args) throws Exception {

        NebulaPoolConfig nebulaPoolConfig = new NebulaPoolConfig();
        nebulaPoolConfig.setMaxConnSize(10);
        List<HostAddress> addresses = Arrays.asList(new HostAddress("127.0.0.1", 9669) );
        NebulaPool pool = new NebulaPool();
        pool.init(addresses, nebulaPoolConfig);
        Session session = pool.getSession("root", "nebula", false);

//        ResultSet use_test = session.execute("use test");
        ResultSet show_edges = session.execute("show edges");
        printResult(show_edges);

        session.release();
        pool.close();
    }


    private static void printResult(ResultSet resultSet) throws UnsupportedEncodingException {
        List<String> colNames = resultSet.keys();
        for (String name : colNames) {
            System.out.printf("%15s |", name);
        }
        System.out.println();
        for (int i = 0; i < resultSet.rowsSize(); i++) {
            ResultSet.Record record = resultSet.rowValues(i);
            for (ValueWrapper value : record.values()) {
                if (value.isLong()) {
                    System.out.printf("%15s |", value.asLong());
                }
                if (value.isBoolean()) {
                    System.out.printf("%15s |", value.asBoolean());
                }
                if (value.isDouble()) {
                    System.out.printf("%15s |", value.asDouble());
                }
                if (value.isString()) {
                    System.out.printf("%15s |", value.asString());
                }
                if (value.isTime()) {
                    System.out.printf("%15s |", value.asTime());
                }
                if (value.isDate()) {
                    System.out.printf("%15s |", value.asDate());
                }
                if (value.isDateTime()) {
                    System.out.printf("%15s |", value.asDateTime());
                }
                if (value.isVertex()) {
                    System.out.printf("%15s |", value.asNode());
                }
                if (value.isEdge()) {
                    System.out.printf("%15s |", value.asRelationship());
                }
                if (value.isPath()) {
                    System.out.printf("%15s |", value.asPath());
                }
                if (value.isList()) {
                    System.out.printf("%15s |", value.asList());
                }
                if (value.isSet()) {
                    System.out.printf("%15s |", value.asSet());
                }
                if (value.isMap()) {
                    System.out.printf("%15s |", value.asMap());
                }
            }
            System.out.println();
        }
    }
}

再贴上报错信息

image

@Nicole00
Copy link
Contributor

Nicole00 commented Sep 3, 2021

Nebula Client 2.0.1 and master branch has fixed this NPE bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants