问题描述: java客户端连接nebula使用scan命令(com.vesoft.nebula.client.storage.StorageClient#scanVertex())进行导数据操作,Iterator返回的hasNext为false,但是nebula数据库中是有数据的
nebula版本: 2020.06.29-nightly
nebula-java版本: 1.0.0-rc4.20200323
nebula端口信息:
[INFO] nebula-metad: Running as 36200, Listening on 45500
[INFO] nebula-graphd: Running as 36210, Listening on 3699
[INFO] nebula-storaged: Running as 36220, Listening on 44500
nebula show host信息
nebula数据库数据
[root@p88230v bin]# ./db_dump -space=graphx -db_path=/usr/local/nebula_v1_new/data/storage/nebula/ -mode=stat -parts=1,2,3
===========================PARAMS============================
mode: stat
meta server: 127.0.0.1:45500
space: graphx
path: /usr/local/nebula_v1_new/data/storage/nebula/
parts: 1,2,3
vids:
tags:
edges:
limit: 1000
===========================PARAMS============================
===========================STATISTICS============================
COUNT: 1000
VERTEX COUNT: 159
EDGE COUNT: 841
TAG STATISTICS:
mobile : 125
java代码
public class NebulaVertexScanTest{
private static final Logger LOGGER = LoggerFactory.getLogger(NebulaVertexScanTest.class);
private static MetaClient metaClient;
private static StorageClient storageClient;
private static ScanVertexProcessor processor;
private static void scanVertex(String space, int part, Map<String, List<String>> returnCols,
boolean allCols) {
System.out.println(("Start to scan space " + space + " part " + part));
try {
Iterator<ScanVertexResponse> iterator =
storageClient.scanVertex(space, part, returnCols, allCols,
100, 0L, Long.MAX_VALUE);
while (iterator.hasNext()) {
ScanVertexResponse response = iterator.next();
if (response == null) {
System.err.println(("Error occurs while scan vertex"));
break;
}
process(space, response);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private static void process(String space, ScanVertexResponse response) {
// Result result = processor.process(space, response);
System.out.println(("process " + response + " vertices"));
}
@Test
public void testScan() {
try {
MetaClientImpl metaClientImpl = new MetaClientImpl("127.0.0.1", 45500);
metaClientImpl.connect();
metaClient = metaClientImpl;
StorageClientImpl storageClientImpl = new StorageClientImpl(metaClientImpl);
storageClient = storageClientImpl;
processor = new ScanVertexProcessor(metaClientImpl);
Map<String, List<String>> returnCols = new HashMap<>();
returnCols.put("mobile", Arrays.asList());
boolean allCols = true;
for (Map.Entry<String, Map<Integer, List<HostAndPort>>> spaceEntry :
metaClient.getPartsAllocFromCache().entrySet()) {
String space = spaceEntry.getKey();
for (Integer part : spaceEntry.getValue().keySet()) {
scanVertex(space, part, returnCols, allCols);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
日志输出内容
Start to scan space graphx part 1
process ScanVertexResponse (
result : ResponseCommon (
failed_codes : [
],
latency_in_us : 12912
),
vertex_schema : {
248 : Schema (
columns : [
ColumnDef (
name : "mobile",
type : ValueType (
type : STRING (6)
)
)
ColumnDef (
name : "update_time",
type : ValueType (
type : TIMESTAMP (21)
)
)
ColumnDef (
name : "create_time",
type : ValueType (
type : TIMESTAMP (21)
)
)
],
schema_prop : SchemaProp (
)
)
},
vertex_data : [
],
has_next : false,
next_cursor :
) vertices
Start to scan space graphx part 2
process ScanVertexResponse (
result : ResponseCommon (
failed_codes : [
],
latency_in_us : 14528
),
vertex_schema : {
248 : Schema (
columns : [
ColumnDef (
name : "mobile",
type : ValueType (
type : STRING (6)
)
)
ColumnDef (
name : "update_time",
type : ValueType (
type : TIMESTAMP (21)
)
)
ColumnDef (
name : "create_time",
type : ValueType (
type : TIMESTAMP (21)
)
)
],
schema_prop : SchemaProp (
)
)
},
vertex_data : [
],
has_next : false,
next_cursor :
) vertices
Start to scan space graphx part 3
process ScanVertexResponse (
result : ResponseCommon (
failed_codes : [
],
latency_in_us : 11417
),
vertex_schema : {
248 : Schema (
columns : [
ColumnDef (
name : "mobile",
type : ValueType (
type : STRING (6)
)
)
ColumnDef (
name : "update_time",
type : ValueType (
type : TIMESTAMP (21)
)
)
ColumnDef (
name : "create_time",
type : ValueType (
type : TIMESTAMP (21)
)
)
],
schema_prop : SchemaProp (
)
)
},
vertex_data : [
],
has_next : false,
next_cursor :
) vertices