首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用Gremlinpython列出具有".toList()“的Janusgraph中存在的所有顶点

无法使用Gremlinpython列出具有".toList()“的Janusgraph中存在的所有顶点
EN

Stack Overflow用户
提问于 2019-07-18 05:41:02
回答 1查看 640关注 0票数 0

我已经尝试测试我创建的图中的内容,以查看是否确实创建了节点。

创建用于测试的小图形的代码:

代码语言:javascript
复制
from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection

graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))

# in a loop add nodes and properties to get a small graph for testing
t = g.addV('testnode').property('val',1)
    for i in range(2,11):
    t = g.addV('testnode').property('val', i)
    t.iterate()

# proceed to create edge (as_ and from_ contain an underscore because as & from are python's reserved words)
g.V().has("val", 2).as_("a").V().has("val", 4).as_("b").addE("link").property("someproperty", "abc").from_("a").to("b").iterate()

list1 = []
list1 = g.V().has("val", 2).toList()
print(len(list1))

我希望在终端中返回值"1“,这在以前的测试中是正确的(现在失败了)。但是,这将返回一个错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "test_addingVEs.py", line 47, in <module>
    list1 = g.V().has("val_i", 2).toList()
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/process/traversal.py", line 52, in toList
    return list(iter(self))
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/process/traversal.py", line 43, in __next__
    self.traversal_strategies.apply_strategies(self)
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/process/traversal.py", line 346, in apply_strategies
    traversal_strategy.apply(traversal)
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/remote_connection.py", line 143, in apply
    remote_traversal = self.remote_connection.submit(traversal.bytecode)
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/driver_remote_connection.py", line 54, in submit
    results = result_set.all().result()
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 405, in result
    return self.__get_result()
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 357, in __get_result
    raise self._exception
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/resultset.py", line 81, in cb
    f.result()
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 398, in result
    return self.__get_result()
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 357, in __get_result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/connection.py", line 77, in _receive
    self._protocol.data_received(data, self._results)
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/protocol.py", line 98, in data_received
    "{0}: {1}".format(status_code, message["status"]["message"]))
gremlin_python.driver.protocol.GremlinServerError: 598: 
    A timeout occurred during traversal evaluation of [RequestMessage
    {, requestId=d56cce63-77f3-4c1f-9c14-3f5f33d4a67b, op='bytecode', processor='traversal', args={gremlin=[[], [V(), has(val, 2)]], aliases={g=g}}}]
     - consider increasing the limit given to scriptEvaluationTimeout

.toList()函数以前确实起作用,但现在不起作用了。我的代码中是否有任何错误,或者我应该在其他地方寻找可能的原因?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-19 22:15:20

那么,这个错误就是问题所在:

代码语言:javascript
复制
A timeout occurred during traversal evaluation of [RequestMessage
    {, requestId=d56cce63-77f3-4c1f-9c14-3f5f33d4a67b, op='bytecode', processor='traversal', args={gremlin=[[], [V(), has(val, 2)]], aliases={g=g}}}]
     - consider increasing the limit given to scriptEvaluationTimeout

当然,假设默认的scriptEvaluationTimeout为30秒,那么返回正在执行的查询的结果应该不会花那么长的时间,除非您有大量的顶点,并且您在"val“上没有索引。因此,考虑到您的图非常小,我不明白为什么这样的执行会花费这么长的时间。

我不知道你正在测试的环境是什么样的,但如果你在一台动力极低的机器上运行JanusGraph/Cassandra,我猜一些高度资源匮乏的东西可能需要很长时间才能执行。我想我会试着按照错误中的建议增加scriptEvaluationTimeout,看看你必须增加它多高才能得到结果。如果你在val上没有索引,你可能无论如何都应该添加这些索引(尽管我不认为这是你的问题,除非顶点计数比你的代码所指示的要大)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57084389

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档