交互式查询¶
- class graphscope.interactive.query.InteractiveQuery(graph, frontend_gremlin_endpoint, frontend_cypher_endpoint)[源代码]¶
InteractiveQuery 类是对 Gremlin-Python 的一个简单封装,它在 Python 语言中实现了 Gremlin 功能。该类还可以通过 gremlin_url() 方法暴露 gremlin 端点,供其他标准 gremlin 控制台使用。
它还有一个名为subgraph的方法,可以从原始图中提取某些片段,生成一个新的、更小但简洁的图并存储在vineyard中,其生命周期独立于原始图。
用户既可以使用execute()提交脚本,也可以通过traversal_source()获取GraphTraversalSource进行后续遍历操作。
- __init__(graph, frontend_gremlin_endpoint, frontend_cypher_endpoint)[源代码]¶
构建一个
InteractiveQuery对象。
- property cypher_driver¶
- property cypher_url¶
Cypher图URL可与任何标准的Cypher控制台配合使用,例如neo4j。
- property graph_url¶
- property gremlin_client¶
- property gremlin_url¶
Gremlin图URL可与任何标准的Gremlin控制台配合使用,例如TinkerPop。
- property object_id¶
- property session¶
- property session_id¶
- subgraph(gremlin_script, lang='gremlin', request_options=None)[源代码]¶
目前我们仅支持通过gremlin脚本使用子图功能。
创建一个子图,其输入为gremlin_script的执行器结果。
任何输出一组边的gremlin脚本都可以用来构建子图。
- Parameters:
gremlin_script (str) – 要执行的Gremlin脚本。
request_options (dict, optional) – Gremlin请求选项。格式:
{ – “engine”: “gae”
} –
- Returns:
由gremlin输出构建的新图,该图也存储在vineyard中。
- Return type:
- traversal_source()[源代码]¶
目前我们仅支持使用gremlin的traversal_source。
创建一个GraphTraversalSource并返回。 当使用连接创建g后,我们就可以开始编写 Gremlin遍历语句来查询远程图数据。
- Raises:
运行时错误 – 如果交互式脚本未运行。
示例
sess = graphscope.session() graph = load_modern_graph(sess, modern_graph_data_dir) interactive = sess.gremlin(graph) g = interactive.traversal_source() print(g.V().both()[1:3].toList()) print(g.V().both().name.toList())
- Returns:
GraphTraversalSource