zpw-123 commented on PR #2314: URL: https://github.com/apache/incubator-hugegraph/pull/2314#issuecomment-1750211493
前辈好 我是https://github.com/apache/incubator-hugegraph/pull/2314 目前好像很多测试都没有通过,我毕竟就修改170+行,为啥这么多测试都通过不了啊! 然后实现的思路大概是:首先需要判断是否命中索引,如果部分命中索引就创建 更加宽泛的条件查询语句,后面再用过滤操作来筛选出来最后结果! ------------------ 原始邮件 ------------------ 发件人: "apache/incubator-hugegraph" ***@***.***>; 发送时间: 2023年10月1日(星期天) 凌晨3:57 ***@***.***>; ***@***.******@***.***>; 主题: Re: [apache/incubator-hugegraph] 修改了上面的几个文件,来实现部分索引命中! (PR #2314) @javeme commented on this pull request. Thank you very much for your PR. Could you briefly describe the feature intent and design framework? In hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphIndexTransaction.java: > public MatchedIndex(SchemaLabel schemaLabel, Set<IndexLabel> indexLabels) { - this.schemaLabel = schemaLabel; + //this.schemaLabels = new HashSet<>(); remove it? In hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java: > @@ -1395,8 +1397,8 @@ private <R> QueryList<R> optimizeQueries(Query query, } boolean supportIn = this.storeFeatures().supportsQueryWithInCondition(); - for (ConditionQuery cq : ConditionQueryFlatten.flatten( - (ConditionQuery) query, supportIn)) { + for (ConditionQuery cq: ConditionQueryFlatten.flatten( + (ConditionQuery) query, supportIn)) { prefer to keep the old style In hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java: > @@ -1405,13 +1407,127 @@ private <R> QueryList<R> optimizeQueries(Query query, * 2.index-query result(ids after optimization), which may be empty. */ if (q == null) { - queries.add(this.indexQuery(cq), this.batchSize); + boolean sys = cq.syspropConditions().size() != 0; sysprop? In hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/AbstractTransaction.java: > @@ -133,7 +133,7 @@ public Number queryNumber(Query query) { } @Watched(prefix = "tx") - public QueryResults<BackendEntry> query(Query query) { + protected QueryResults<BackendEntry> query(Query query) { not sure why need to mark protected In hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java: > } else if (!q.empty()) { queries.add(q); } } return queries; } + private boolean hasOlapCondition(ConditionQuery query) { + for (Id pk : query.userpropKeys()) { + if(this.graph().propertyKey(pk).olap()) { + return true; + } + } + + return false; + } + // Method to reorder conditions + private void excludeOnlyLabelQuery(ConditionQuery cq, QueryList queries) { + // 判断是否命中索引 can we translate all Chinese comments? In hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java: > + + // 如果条件查询中包含olap相关属性查询,暂不做补充查询 + if(this.hasOlapCondition(rawQuery)) { + return queries; + } + + Collection<VertexLabel> vertexLabels = this.graph().vertexLabels(); + Collection<EdgeLabel> edgeLabels = this.graph().edgeLabels(); + + Set<SchemaLabel> matchedLabels = + matchedIndices.stream() + .flatMap(matchedIndex -> matchedIndex.schemaLabels().stream()) + .collect(Collectors.toSet()); + + Id label = rawQuery.condition(HugeKeys.LABEL); + if (label == null) { prefer return if (label != null) — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: ***@***.***> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
