You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by va...@apache.org on 2023/02/27 08:42:19 UTC

[incubator-hugegraph] branch zy_dev2 created (now 061bbaa2b)

This is an automated email from the ASF dual-hosted git repository.

vaughn pushed a change to branch zy_dev2
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git


      at 061bbaa2b chore: cmn algorithm optimization

This branch includes the following new commits:

     new 061bbaa2b chore: cmn algorithm optimization

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-hugegraph] 01/01: chore: cmn algorithm optimization

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vaughn pushed a commit to branch zy_dev2
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git

commit 061bbaa2b5d43c42176239f5182a4d0e7521b4b8
Author: vaughn <va...@apache.org>
AuthorDate: Mon Feb 27 16:41:53 2023 +0800

    chore: cmn algorithm optimization
---
 .../org/apache/hugegraph/backend/tx/GraphIndexTransaction.java    | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphIndexTransaction.java b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphIndexTransaction.java
index 3bf9a7c81..f4ff8b32e 100644
--- a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphIndexTransaction.java
+++ b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphIndexTransaction.java
@@ -1120,13 +1120,18 @@ public class GraphIndexTransaction extends AbstractTransaction {
             result = new ArrayList<>(n);
         }
 
+        int index = result.size();
         if (m == n) {
             result.addAll(all.subList(current, all.size()));
             n = 0;
         }
         if (n == 0) {
             // All n items are selected
-            return callback.apply(result);
+            Boolean apply = callback.apply(result);
+            while (index < result.size()) {
+                result.remove(index);
+            }
+            return apply;
         }
         if (current >= all.size()) {
             // Reach the end of items
@@ -1134,7 +1139,6 @@ public class GraphIndexTransaction extends AbstractTransaction {
         }
 
         // Select current item, continue to select C(m-1, n-1)
-        int index = result.size();
         result.add(all.get(current));
         if (cmn(all, m - 1, n - 1, ++current, result, callback)) {
             return true;