【发布时间】:2020-01-21 11:09:44
【问题描述】:
我正在使用以嵌入式模式部署的 Janus 图。我正在使用java。并触发以下查询
--> g.V().has('deleted',false).valueMap() //慢
--> g.V().has('deleted',false).toList() //慢
上述查询在实现复合索引后也需要时间
--> g.V().has('deleted',false) //快
上述查询速度很快,并使用在已删除键上创建的已实现复合索引。
也尝试过使用 java 代码
List<Vertex> list = new ArrayList<>();
DateTime dt1 = new DateTime();
JanusGraphQuery<? extends JanusGraphQuery> query = GraphClient.getJGraph().query();
Iterator iterator = query.has("deleted",false).vertices().iterator();
while(iterator.hasNext()) {
Vertex next = (Vertex) iterator.next();
getPropertyMapByVertex(next); //time consuming to convert vertex into Map.
list.add(next);
}
public static Map<String, Object> getPropertyMapByVertex(Vertex vertex) {
Map<String, Object> propertyMap = new HashMap<>();
try {
if (vertex != null) {
Iterator<VertexProperty<Object>> properties = vertex.properties();
if (properties != null) {
while (properties.hasNext()) {
Property<Object> property = properties.next();
propertyMap.put(property.key(), property.value());
}
propertyMap.put(GraphConstants.VERTEX_ID, vertex.id());
}
}
} catch (Exception e) {
logger.error("Exception in getPropertyMapByVertex : {}", ExceptionUtils.getStackTrace(e));
}
return propertyMap;
}
我们有什么方法可以快速使用“getPropertyMapByVertex”方法或任何其他方法来触发查询并使用 java 快速获取数据。
【问题讨论】:
标签: gremlin janusgraph janus