gremlin - JanusGraph - 创建索引后有关所有顶点扫描的警告
问题描述
我正在使用 Janusgraph 0.2.0 并定义了以下顶点(在 Python 中):
class Airport(TypedVertex):
type = goblin.VertexProperty(goblin.String, card=Cardinality.single)
airport_code = goblin.VertexProperty(goblin.String,
card=Cardinality.single)
airport_city = goblin.VertexProperty(goblin.String,
card=Cardinality.single)
airport_name = goblin.VertexProperty(goblin.String,
card=Cardinality.single)
airport_region = goblin.VertexProperty(goblin.String,
card=Cardinality.single)
airport_runways = goblin.VertexProperty(goblin.Integer,
card=Cardinality.single)
airport_longest_runway = goblin.VertexProperty(goblin.Integer,
card=Cardinality.single)
airport_elev = goblin.VertexProperty(goblin.Integer,
card=Cardinality.single)
airport_country = goblin.VertexProperty(goblin.String,
card=Cardinality.single)
airport_lat = goblin.VertexProperty(goblin.Float,
card=Cardinality.single)
airport_long = goblin.VertexProperty(goblin.Float,
card=Cardinality.single)
然后,我使用以下命令在机场代码字段上为该节点定义了一个索引(排除了一些命令以保持简短)。
mgmt.makePropertyKey('type').dataType(String.class).cardinality(Cardinality.SINGLE).make()
mgmt.makePropertyKey('airport_city').dataType(String.class).cardinality(Cardinality.SINGLE).make()
mgmt.makePropertyKey('airport_code').dataType(String.class).cardinality(Cardinality.SINGLE).make()
mgmt.makePropertyKey('airport_country').dataType(String.class).cardinality(Cardinality.SINGLE).make()
airport_code = mgmt.getPropertyKey('airport_code')
airport_city = mgmt.getPropertyKey('airport_city')
airport_country = mgmt.getPropertyKey('airport_country')
mgmt.buildIndex('by_airport_code_unique', Vertex.class).addKey(airport_code).unique().buildCompositeIndex()
mgmt.buildIndex('by_airport_city', Vertex.class).addKey(airport_city).buildCompositeIndex()
mgmt.buildIndex('by_airport_country', Vertex.class).addKey(airport_country).buildCompositeIndex()
mgmt.awaitGraphIndexStatus(graph, 'by_airport_code_unique').call()
mgmt.awaitGraphIndexStatus(graph, 'by_airport_city').call()
mgmt.awaitGraphIndexStatus(graph, 'by_airport_country').call()
创建后,我使用脚本来描述 :schema 并且我看到所有索引都已注册:
| Graph Index . | Type . | Element | Unique | Backing | PropertyKey | Status |
|-----------------------:|:-----|:--------|:-------|:--------|:-----------|:--------|
| by_airport_code_unique | Composite | JanusGraphVertex | true | internalindex | airport_code | REGISTERED |
| by_airport_city | Composite | JanusGraphVertex | false | internalindex | airport_city | REGISTERED |
| by_airport_country | Composite | JanusGraphVertex | false | internalindex | airport_country | REGISTERED |
当我尝试插入具有相同 airport_code 的第二个顶点时,如预期的那样,我得到了违反约束的异常。但是,如果我进入 gremlin 控制台并运行遍历以通过其 airport_code 检索顶点:
g.V().has('airport_code').values()
我收到警告:WARN org.janusgraph.graphdb.transaction.StandardJanusGraphTx - 查询需要遍历所有顶点 [()]。为了获得更好的性能,请使用索引
几周前我遇到了类似的问题,问题是我试图根据标签定义索引,当时有人告诉我,janusgraph 不支持标签上的索引。但是,我认为情况并非如此。关于为什么我的索引不起作用或未被使用的任何建议或想法?提前感谢您的帮助。--MD
解决方案
推荐阅读
- mongoose - 如何使用 GraphQL 和猫鼬将文件从客户端上传到数据库?
- r - 使用相同的 IV 但不同的 DV 添加来自不同模型的标准化残差列
- python - 如何在大型 dask 数据帧上执行 set_index 并避免工人被杀死?
- python - 如何将 django 视图请求拆分为多个
- python - 用户如何在不在本地机器上安装 python 并且不将脚本转换为可执行文件的情况下运行 python 脚本?
- python - Python - 进程以退出代码 134 完成(被信号 6:SIGABRT 中断) - 龟模块
- google-app-engine - 在 2 个 App Engine 灵活服务的实例之间路由流量的最佳方式是什么(在 VPC 内?)?
- oracle - Informatica 工作流正在从 Oracle 视图中删除记录
- html - 如何在悬停时在图像上放置文本和叠加层?
- docker - docker pull 忽略 http_proxy 和 https_proxy 环境变量?