Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,13 @@ private ConditionQuery prepareConditionQuery(ConditionQuery conditionQuery) {
}
}
if (newConditions.size() > 0) {
conditionQuery.resetConditions(newConditions);
return conditionQuery;
// NOTE: copy before reset, the origin query is still used by core
// for result filtering after the backend scan returns; drop the
// back reference so the serialized payload stays flat
ConditionQuery pushdown = conditionQuery.copy();
Comment thread
imbajin marked this conversation as resolved.
pushdown.resetConditions(newConditions);
pushdown.setOriginQuery(null);
return pushdown;
} else {
return null;
}
Expand All @@ -594,8 +599,11 @@ private ConditionQuery prepareConditionQueryList(ConditionQuery conditionQuery)
}
}
if (newConditions.size() > 0) {
conditionQuery.resetConditions(newConditions);
return conditionQuery;
// NOTE: copy before reset, see prepareConditionQuery()
ConditionQuery pushdown = conditionQuery.copy();
Comment thread
imbajin marked this conversation as resolved.
pushdown.resetConditions(newConditions);
pushdown.setOriginQuery(null);
Comment thread
imbajin marked this conversation as resolved.
return pushdown;
} else {
return null;
}
Expand Down Expand Up @@ -623,7 +631,6 @@ protected BackendColumnIterator queryByRange(Session session,
type |= query.inclusiveEnd() ?
Session.SCAN_LTE_END : Session.SCAN_LT_END;
}
ConditionQuery cq;
Query origin = query.originQuery();
byte[] position = null;
byte[] ownerStart = this.ownerByQueryDelegate.apply(query.resultType(),
Expand All @@ -640,21 +647,24 @@ protected BackendColumnIterator queryByRange(Session session,
if (query.paging() && !query.page().isEmpty()) {
position = PageState.fromString(query.page()).position();
}
byte[] queryBytes = null;
if (origin instanceof ConditionQuery &&
(query.resultType().isEdge() || query.resultType().isVertex())) {
cq = (ConditionQuery) query.originQuery();

// LOG.debug("query {} with ownerKeyFrom: {}, ownerKeyTo: {}, " +
// "keyFrom: {}, keyTo: {}, " +
// "scanType: {}, conditionQuery: {}",
// this.table(), bytes2String(ownerStart),
// bytes2String(ownerEnd), bytes2String(start),
// bytes2String(end), type, cq.bytes());
return session.scan(this.table(), ownerStart,
ownerEnd, start, end, type, cq.bytes(), position);
}
return session.scan(this.table(), ownerStart,
ownerEnd, start, end, type, null, position);
// Same guard as queryByPrefix(): only push the query down to the
// store when user-prop conditions remain. A sort-key prefix/range
// query keeps sysprop conditions only (owner vertex, direction,
// label, sort values), which are already enforced by the key
// range, and the store-side row decoder cannot parse the raw
// property layout written by the server (see issue #3090).
// The guard applies to the range path only because the key range
// already covers its sysprops; the full-scan path (queryAll and
// the shard overload of queryByRange) still needs the pushdown to
// filter, so it keeps pushing the whole query.
ConditionQuery cq = prepareConditionQuery((ConditionQuery) origin);
Comment thread
imbajin marked this conversation as resolved.
queryBytes = cq == null ? null : cq.bytes();
}
return session.scan(this.table(), ownerStart, ownerEnd, start, end,
type, queryBytes, position);
}

static boolean shouldUseOrderedRangeScan(IdRangeQuery query) {
Expand Down
Loading
Loading