SebastianGruza commented on code in PR #3184:
URL: https://github.com/apache/hugegraph/pull/3184#discussion_r4014836275
##########
hugegraph-server/hugegraph-hstore/src/test/java/org/apache/hugegraph/backend/store/hstore/HstoreTableTest.java:
##########
@@ -124,6 +134,101 @@ public void
testRangeScanBudgetIncludesOneLookaheadRecord() {
Assert.assertEquals(14L, HstoreTable.rangeScanBudget(query));
}
+ @Test
+ public void testRangeQueryWithoutUserpropsDoesNotPushConditions() {
+ // Sort-key prefix/range queries keep sysprop conditions only (owner
+ // vertex, direction, label, sort values); those are enforced by the
+ // key range already and must not be pushed to the store, whose row
+ // decoder cannot parse the server's raw property layout (issue #3090)
+ ConditionQuery origin = new ConditionQuery(HugeType.EDGE);
+ origin.eq(HugeKeys.OWNER_VERTEX, IdGenerator.of("v1"));
+ origin.eq(HugeKeys.DIRECTION, Directions.OUT);
+ origin.eq(HugeKeys.LABEL, IdGenerator.of(1L));
+ origin.gte(HugeKeys.SORT_VALUES, "ETC!");
+ origin.lt(HugeKeys.SORT_VALUES, "ETC~");
+ int before = origin.conditions().size();
+
+ ScanRecordingSession session = new ScanRecordingSession();
+ this.newTestTable().queryByRange(session, edgeRangeQuery(origin));
+
+ Assert.assertTrue(session.scanCalled);
+ Assert.assertNull(session.lastQueryBytes);
+ Assert.assertEquals(before, origin.conditions().size());
+ }
+
+ @Test
+ public void testRangeQueryWithUserpropsPushesCopyAndKeepsOrigin() {
+ ConditionQuery origin = new ConditionQuery(HugeType.EDGE);
+ origin.eq(HugeKeys.OWNER_VERTEX, IdGenerator.of("v1"));
+ origin.query(Condition.eq(IdGenerator.of(7L), 100));
+ int before = origin.conditions().size();
+
+ ScanRecordingSession session = new ScanRecordingSession();
+ this.newTestTable().queryByRange(session, edgeRangeQuery(origin));
+
+ Assert.assertTrue(session.scanCalled);
+ Assert.assertNotNull(session.lastQueryBytes);
+ // the pushed-down query is a copy: the origin query keeps all its
+ // conditions for core-side filtering after the scan returns
+ Assert.assertEquals(before, origin.conditions().size());
+ // pushed payload: user-prop condition survives, owner-vertex is
+ // dropped, and the back reference to the origin query is cleared
+ ConditionQuery pushed =
ConditionQuery.fromBytes(session.lastQueryBytes);
+ Assert.assertNull(pushed.condition(HugeKeys.OWNER_VERTEX));
+ Assert.assertFalse(pushed.userpropConditions().isEmpty());
+ Assert.assertNull(pushed.originQuery());
+ }
+
+ @Test
+ public void testPrefixListQueryPushesCopyAndKeepsOrigin() {
+ // prepareConditionQueryList() is reached from queryByPrefixList() and
Review Comment:
Done in eb5e05a — the comment now says the method is called from
`queryByPrefixList()` and the streaming `query(Session, Iterator, String)`,
that neither has a live caller in the server today, and that the test pins the
method contract. Comment-only change, no code touched.
--
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]