gremlin python 使用submit()打开janusgraph数据库

问题描述 投票:0回答:1

我试图在 gremlin_python 运行时切换到不同的数据库。为此,我使用 JanusGraphFactory.open() 打开不同的配置。因为 gremlin_python 没有 JanusGraphFactory,所以我必须通过 Submit() 运行此代码。

from gremlin_python.driver import client
client = client.Client('ws://localhost:8182/gremlin','g')

query = "conf = new BaseConfiguration();\
conf.setProperty('gremlin.graph', 'org.janusgraph.core.JanusGraphFactory');\
conf.setProperty('cache.db-cache-size', 0.25);\
conf.setProperty('cache.db-cache-clean-wait', 20);\
conf.setProperty('ids.block-size', 10000);\
conf.setProperty('cache.db-cache', true);\
conf.setProperty('storage.backend', 'hbase');\
conf.setProperty('storage.write-time', '1000000 ms');\
conf.setProperty('storage.hostname', 'hostname');\
conf.setProperty('storage.transactions', false);\
conf.setProperty('storage.hbase.table', 'table');\
conf.setProperty('storage.batch-loading', true);\
conf.setProperty('cache.db-cache-time', 180000);\
graph = JanusGraphFactory.open(conf);"

result  = client.submit(query)
future_results = result.all()
results = future_results.result()
print(results)

但是,我收到以下错误,我相信该错误来自“graph = JanusGraphFactory.open(conf);”:

Traceback (most recent call last):
File "/home/kk/project/janusgraph_test/janusgraph_test3.py", line 29, in \<module\>
results = future_results.result()
File "/usr/lib/python3.10/concurrent/futures/\_base.py", line 458, in result
return self.\__get_result()
File "/usr/lib/python3.10/concurrent/futures/\_base.py", line 403, in \__get_result
raise self.\_exception
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/driver/resultset.py", line 90, in cb
f.result()
File "/usr/lib/python3.10/concurrent/futures/\_base.py", line 451, in result
return self.\__get_result()
File "/usr/lib/python3.10/concurrent/futures/\_base.py", line 403, in \__get_result
raise self.\_exception
File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(\*self.args, \*\*self.kwargs)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/driver/connection.py", line 90, in \_receive
status_code = self.\_protocol.data_received(data, self.\_results)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/driver/protocol.py", line 96, in data_received
message = self.\_message_serializer.deserialize_message(message)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/driver/serializer.py", line 280, in deserialize_message
result = self.\_graphbinary_reader.to_object(b)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 203, in to_object
return self.deserializers\[DataType(bt)\].objectify(buff, self, nullable)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 502, in objectify
return cls.is_null(buff, reader, cls.\_read_list, nullable)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 231, in is_null
return None if nullable and buff.read(1)\[0\] == 0x01 else else_opt(buff, reader)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 509, in \_read_list
the_list.append(r.read_object(b))
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 194, in read_object
return self.to_object(b)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 203, in to_object
return self.deserializers\[DataType(bt)\].objectify(buff, self, nullable)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 662, in objectify
raise AttributeError("TinkerGraph deserialization is not currently supported by gremlin-python")
AttributeError: TinkerGraph deserialization is not currently supported by gremlin-python`

我在 Groovy 控制台上尝试了相同的代码,打开conf没有问题。

我还研究了ConfiguredGraphFactory。它也不包含在 gremlin_python 中,并且我没有找到 gremlin-python 的明确用法。希望有人对此有一些想法,提前谢谢!

groovy gremlin janusgraph gremlin-server gremlinpython
1个回答
0
投票

Gremlin-Python 连接到现有的 JanusGraph

对于任何想要为 gremlin python 设置ConfiguredGraphFactory 的人,请参阅此链接

© www.soinside.com 2019 - 2024. All rights reserved.