contrueCT commented on code in PR #3243:
URL: https://github.com/apache/hugegraph/pull/3243#discussion_r4130164196
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphIndexTransaction.java:
##########
@@ -805,9 +814,57 @@ private Set<MatchedIndex>
collectMatchedIndexes(ConditionQuery query) {
matchedIndexes.add(index);
}
}
+ // An invalid value returns no results after an index is found. Keep
+ // that result before deciding whether index coverage is complete.
+ if (requireCompleteCoverage && !matchedIndexes.isEmpty() &&
+ validQueryConditionValues(this.graph(), query)) {
+ this.checkIndexCoverage(query, schemaLabels, matchedIndexes);
Review Comment:
Addressed in 0de33eda. TestGraph now indexes the previously uncovered Modern
candidates (animal.name, animal.age, and createdBy.weight), plus shared indexed
properties in the Basic and Sink fixtures. SourceIndexCoverageTest exercises
unlabeled name, age, weight, edge-name, and partition-property queries against
those schemas, including labels without matching data. The final test class
passed on Memory (19 run, 2 skipped) and RocksDB (19 run, 0 skipped), with zero
failures/errors. A test-* push at the same SHA has started the full TinkerPop
CI; its result is pending, not claimed as passing. The manual Structure run was
stopped after 30 minutes of slow fixture setup; HStore could not reach PD at
127.0.0.1:8686. These limits are recorded in the PR description.
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/SourceIndexCoverageTest.java:
##########
@@ -0,0 +1,407 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hugegraph.core;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.hugegraph.backend.page.PageInfo;
+import org.apache.hugegraph.backend.query.Condition;
+import org.apache.hugegraph.backend.query.ConditionQuery;
+import org.apache.hugegraph.exception.NoIndexException;
+import org.apache.hugegraph.schema.IndexLabel;
+import org.apache.hugegraph.schema.SchemaManager;
+import org.apache.hugegraph.testutil.Assert;
+import org.apache.hugegraph.traversal.optimize.Text;
+import org.apache.hugegraph.type.HugeType;
+import org.apache.hugegraph.type.define.GraphReadMode;
+import org.apache.hugegraph.type.define.SchemaStatus;
+import org.apache.hugegraph.type.define.WriteType;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
+public class SourceIndexCoverageTest extends BaseCoreTest {
+
+ @Before
+ public void initSchema() {
+ SchemaManager schema = graph().schema();
+ schema.propertyKey("coverageName").asText().create();
+ schema.propertyKey("coverageScore").asInt().create();
+ schema.propertyKey("coverageBody").asText().create();
+ schema.vertexLabel("coverageA")
+ .properties("coverageName", "coverageScore", "coverageBody")
+ .useAutomaticId().create();
+ schema.vertexLabel("coverageB")
+ .properties("coverageName", "coverageScore", "coverageBody")
+ .enableLabelIndex(false).useAutomaticId().create();
+
schema.vertexLabel("unrelated").properties("coverageBody").useAutomaticId().create();
+ }
+
+ private Set<Vertex> addVertices() {
+ Vertex a = graph().addVertex(T.label, "coverageA", "coverageName",
"same",
+ "coverageScore", 10, "coverageBody",
"gold silver");
+ Vertex b = graph().addVertex(T.label, "coverageB", "coverageName",
"same",
+ "coverageScore", 20, "coverageBody",
"gold bronze");
+ this.commitTx();
+ return ImmutableSet.of(a, b);
+ }
+
+ private void nameIndex(String label) {
+ graph().schema().indexLabel(label + "ByName").onV(label)
+ .by("coverageName").secondary().create();
+ }
+
+ @Test
+ public void testCompleteCandidatesOrExplicitFailure() {
+ this.nameIndex("coverageA");
+ Set<Vertex> expected = this.addVertices();
+ Set<Vertex> actual;
+ try {
+ actual = graph().traversal().V().has("coverageName",
"same").toSet();
+ } catch (NoIndexException e) {
Review Comment:
Fixed in 0de33eda. testCompleteCandidatesReturnAllResults now creates
compatible name indexes for both candidate labels and unconditionally asserts
the complete two-vertex result. The separate partial-coverage test still
asserts NoIndexException before adding the second index. Both ran in
SourceIndexCoverageTest on Memory and RocksDB with zero failures/errors.
--
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]