lokidundun commented on code in PR #2982:
URL: https://github.com/apache/hugegraph/pull/2982#discussion_r3356928576
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/EdgeCoreTest.java:
##########
@@ -2683,6 +2683,28 @@ public void testQueryEdgesByIdWithGraphAPI() {
Assert.assertEquals(2, edges.size());
}
+ @Test
+ public void testQueryEdgesByNonConsecutiveDuplicateIds() {
+ HugeGraph graph = graph();
+ init18Edges();
+
+ List<Edge> allEdges = graph.traversal().E().toList();
+ Assert.assertTrue("need at least 2 edges", allEdges.size() >= 2);
+
+ Object id1 = allEdges.get(0).id();
+ Object id2 = allEdges.get(1).id();
+
+ // Graph API does not guarantee duplicate results for duplicate ids
+ List<Edge> edges = ImmutableList.copyOf(graph.edges(id1, id2, id1));
+ Assert.assertTrue(edges.size() >= 2);
Review Comment:
Root cause: query.idsSize() == ids.size() in
GraphTransaction.queryEdgesByIds() is the fast-path guard meant to detect
duplicate IDs, but IdQuery.query(Id) only skips consecutive duplicates (same ID
as the immediately previous one). For [id1, id2, id1], all three are added
to the query because id1 ≠ id2 (the last element), so query.idsSize() returns 3
matching ids.size() — the fast path is
incorrectly taken, and the backend iterator returns only 2 unique edges.
--
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]