incubator-hugegraph icon indicating copy to clipboard operation
incubator-hugegraph copied to clipboard

feat: improve index hits

Open zpw-123 opened this issue 2 years ago • 6 comments

EdgeCoreTest.java与VertexCoreTest.java是部分索引的例子!

Purpose of the PR

  • close #xxx

Main Changes

Verifying these changes

  • [ ] Trivial rework / code cleanup without any test coverage. (No Need)
  • [ ] Already covered by existing tests, such as (please modify tests here).
  • [ ] Need tests and can be verified as follows:
    • xxx

Does this PR potentially affect the following parts?

  • [ ] Nope
  • [ ] Dependencies (add/update license info)
  • [ ] Modify configurations
  • [ ] The public API
  • [ ] Other affects (typed here)

Documentation Status

  • [ ] Doc - TODO
  • [ ] Doc - Done
  • [ ] Doc - No Need

zpw-123 avatar Sep 17 '23 07:09 zpw-123

前辈好 我是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: @.***>

zpw-123 avatar Oct 06 '23 08:10 zpw-123

hi @zpw-123 , is it still in progress?

simon824 avatar Oct 27 '23 01:10 simon824

是的

---Original--- From: "Simon @.> Date: Fri, Oct 27, 2023 09:51 AM To: @.>; Cc: @.@.>; Subject: Re: [apache/incubator-hugegraph] feat: improve index hits (PR #2314)

hi @zpw-123 , is it still in progress?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

zpw-123 avatar Oct 27 '23 12:10 zpw-123

Due to the lack of activity, the current pr is marked as stale and will be closed after 180 days, any update will remove the stale label

github-actions[bot] avatar Nov 26 '23 21:11 github-actions[bot]

前辈好 我是#2314 目前好像很多测试都没有通过,我毕竟就修改170+行,为啥这么多测试都通过不了啊! 然后实现的思路大概是:首先需要判断是否命中索引,如果部分命中索引就创建 更加宽泛的条件查询语句,后面再用过滤操作来筛选出来最后结果!

@zpw-123 总体思路是可以的,不过涉及面较广,希望能补充一下详细设计文档。先进行文档Review没问题之后,再进行代码修改。如果有什么问题欢迎通过HugeGraph微信公众号联系我们。

javeme avatar Nov 27 '23 03:11 javeme

Due to the lack of activity, the current pr is marked as stale and will be closed after 180 days, any update will remove the stale label

github-actions[bot] avatar Dec 28 '23 21:12 github-actions[bot]