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 <[email protected]> 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;
