我正在尝试通过 HBase 将数据批量加载到 janusgraph 0.2 中。我正在使用 python 的 gremlinpython 库。对于批量加载,我将 storage.batch-loading
设置为 true
,现在必须为图形定义架构。
我找到了为图形设置架构的文档(https://docs.janusgraph.org/0.2.0/schema.html 和 https://docs.janusgraph.org/0.2.0/advanced-schema.html)。
它建议了一些基本的模式代码:
mgmt = graph.openManagement()
follow = mgmt.makeEdgeLabel('follow').multiplicity(MULTI).make()
mother = mgmt.makeEdgeLabel('mother').multiplicity(MANY2ONE).make()
mgmt.commit()
我使用 python 的 gremlinpython 库连接到图形。这就是我正在做的:
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
from gremlin_python.process.traversal import T
from gremlin_python.process.traversal import Order
from gremlin_python.process.traversal import Cardinality
from gremlin_python.process.traversal import Column
from gremlin_python.process.traversal import Direction
from gremlin_python.process.traversal import Operator
from gremlin_python.process.traversal import P
from gremlin_python.process.traversal import Pop
from gremlin_python.process.traversal import Scope
from gremlin_python.process.traversal import Barrier
from config import graph_url, graph_name
graph = Graph()
drc = DriverRemoteConnection(graph_url, graph_name)
g = graph.traversal().withRemote(drc)
# I successfully get g here, I check it by :
# g.V().count().next()
现在我的问题是,我应该在哪里设置架构。我尝试在注释掉的行之后执行 mgmt = graph.openManagement()
,但它不起作用。
更新
它在 gremlin 控制台上的工作方式如下:
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin>
gremlin> :> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@625dfab4
但是任何进一步的命令在这里都不起作用:
:> follow = mgmt.makeEdgeLabel('follow').multiplicity(MULTI).make()
No such property: mgmt for class: Script10
最佳答案
gremlinpython司机是Gremlin Language Variant (GLV),它允许您在编程语言 Python 中原生使用 Gremlin。 JanusGraph 模式定义特定于 JanusGraph 数据库,但是 gremlinpython GLV 是一个通用的 TinkerPop 驱动程序,因此它没有调用数据库特定 API 的结构。
如您所述,您可以通过 Gremlin 控制台声明您的架构。另一种选择是使用基于字符串的 Gremlin 驱动程序,例如 gremlinclient或 gremlinpy ,并将您的模式作为字符串查询发送到服务器。
关于python - 如何使用 python 为 janusgraph 设置模式以进行批量加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50378399/