Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ac25ec5
improve(query): clarify condition resolution semantics
contrueCT Apr 12, 2026
c4cf3d5
test(core): avoid unnecessary data setup in label index regression
contrueCT Apr 13, 2026
ed3b788
improve(query): consolidate unique label resolution
contrueCT Apr 23, 2026
a326f44
test(core): cover edge label query semantics
contrueCT Jun 4, 2026
b10e3c2
fix(core): tolerate missing related index labels
contrueCT Jun 5, 2026
a183571
fix(core): skip stale index entries
contrueCT Jun 5, 2026
ebc31c8
fix(core): stabilize hstore range index ordering
contrueCT Jun 5, 2026
2df4802
fix(core): reset hstore range scan offset
contrueCT Jun 7, 2026
939cc12
fix(core): preserve sorted hstore range ordering
contrueCT Jun 8, 2026
9300691
fix(core): handle non-eq label-only traversals
contrueCT Jun 11, 2026
7c85cca
fix(hstore): preserve range index paging order
contrueCT Jun 13, 2026
9e24432
fix(hstore): scope ordered range scan to indexes
contrueCT Jun 14, 2026
3646a14
fix(hstore): route order-sensitive range scans through ordered merge
contrueCT Jun 15, 2026
9eb75e8
fix(hstore): stream ordered range scans lazily
contrueCT Jun 15, 2026
212e89a
fix(hstore): keep range ordering in index layer
contrueCT Jun 15, 2026
b16f5f1
fix(hstore): defer ordered range paging follow-up
contrueCT Jun 16, 2026
18fe87f
Merge branch 'master' into task/improve-condition-query-semantics
imbajin Jun 18, 2026
057b390
Merge branch 'master' into task/improve-condition-query-semantics
imbajin Jun 23, 2026
2627903
fix(hstore): restore backend range page state
contrueCT Jun 24, 2026
c35b389
fix(core): remove hstore range paging workaround
contrueCT Jun 24, 2026
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 @@ -35,11 +35,17 @@
public abstract class IdHolder {

protected final Query query;
private final boolean keepOrder;
protected boolean exhausted;

public IdHolder(Query query) {
this(query, false);
}

public IdHolder(Query query, boolean keepOrder) {
E.checkNotNull(query, "query");
this.query = query;
this.keepOrder = keepOrder;
this.exhausted = false;
}

Expand All @@ -48,6 +54,10 @@ public Query query() {
}

public boolean keepOrder() {
return this.keepOrder;
}

public boolean continueEmptyPage() {
return false;
}

Expand Down Expand Up @@ -94,13 +104,39 @@ public PageIds fetchNext(String page, long pageSize) {
public static class PagingIdHolder extends IdHolder {

private final Function<ConditionQuery, PageIds> fetcher;
private final boolean continueEmptyPage;
private final boolean continuePartialPage;

public PagingIdHolder(ConditionQuery query,
Function<ConditionQuery, PageIds> fetcher) {
super(query.copy());
this(query, fetcher, false);
}

public PagingIdHolder(ConditionQuery query,
Function<ConditionQuery, PageIds> fetcher,
boolean keepOrder) {
this(query, fetcher, keepOrder, false, false);
}

public PagingIdHolder(ConditionQuery query,
Function<ConditionQuery, PageIds> fetcher,
boolean keepOrder,
boolean continueEmptyPage) {
this(query, fetcher, keepOrder, continueEmptyPage,
continueEmptyPage);
}

public PagingIdHolder(ConditionQuery query,
Function<ConditionQuery, PageIds> fetcher,
boolean keepOrder,
boolean continueEmptyPage,
boolean continuePartialPage) {
super(query.copy(), keepOrder);
E.checkArgument(query.paging(),
"Query '%s' must include page info", query);
this.fetcher = fetcher;
this.continueEmptyPage = continueEmptyPage;
this.continuePartialPage = continuePartialPage;
}

@Override
Expand All @@ -119,12 +155,23 @@ public PageIds fetchNext(String page, long pageSize) {

PageIds result = this.fetcher.apply((ConditionQuery) this.query);
assert result != null;
if (result.ids().size() < pageSize || result.page() == null) {
if (result.empty() && !this.continueEmptyPage) {
this.exhausted = true;
return PageIds.EMPTY;
}
if (result.page() == null ||
(!this.continuePartialPage &&
result.ids().size() < pageSize)) {
this.exhausted = true;
}
return result;
}

@Override
public boolean continueEmptyPage() {
return this.continueEmptyPage;
}

@Override
public Set<Id> all() {
throw new NotImplementedException("PagingIdHolder.all");
Expand All @@ -142,7 +189,14 @@ public static class BatchIdHolder extends IdHolder
public BatchIdHolder(ConditionQuery query,
Iterator<BackendEntry> entries,
Function<Long, Set<Id>> fetcher) {
super(query);
this(query, entries, fetcher, false);
}

public BatchIdHolder(ConditionQuery query,
Iterator<BackendEntry> entries,
Function<Long, Set<Id>> fetcher,
boolean keepOrder) {
super(query, keepOrder);
this.entries = entries;
this.fetcher = fetcher;
this.count = 0L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ private boolean fetch() {
this.remaining -= this.pageResults.total();
return true;
} else {
this.pageInfo.increase();
if (this.pageResults.continueOnEmpty() &&
this.pageResults.hasNextPage() &&
!this.pageResults.page().equals(this.pageInfo.page())) {
this.pageInfo.page(this.pageResults.page());
} else {
this.pageInfo.increase();
}
return this.fetch();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private QueryResults<R> each(IdHolder holder) {
return null;
}

return this.queryByIndexIds(ids);
return this.queryByIndexIds(ids, holder.keepOrder());
});
}

Expand All @@ -272,10 +272,13 @@ public PageResults<R> iterator(int index, String page, long pageSize) {
this.updateResultsFilter(bindQuery);
PageIds pageIds = holder.fetchNext(page, pageSize);
if (pageIds.empty()) {
return PageResults.emptyIterator();
return PageResults.emptyIterator(bindQuery,
pageIds.pageState(),
holder.continueEmptyPage());
}

QueryResults<R> results = this.queryByIndexIds(pageIds.ids());
QueryResults<R> results = this.queryByIndexIds(pageIds.ids(),
holder.keepOrder());

return new PageResults<>(results, pageIds.pageState());
}
Expand Down Expand Up @@ -330,10 +333,17 @@ public static class PageResults<R> {

private final QueryResults<R> results;
private final PageState pageState;
private final boolean continueOnEmpty;

public PageResults(QueryResults<R> results, PageState pageState) {
this(results, pageState, false);
}

public PageResults(QueryResults<R> results, PageState pageState,
boolean continueOnEmpty) {
this.results = results;
this.pageState = pageState;
this.continueOnEmpty = continueOnEmpty;
}

public Iterator<R> get() {
Expand All @@ -345,6 +355,10 @@ public boolean hasNextPage() {
PageState.EMPTY_BYTES);
}

public boolean continueOnEmpty() {
return this.continueOnEmpty;
}

public Query query() {
List<Query> queries = this.results.queries();
E.checkState(queries.size() == 1,
Expand All @@ -364,5 +378,18 @@ public long total() {
public static <R> PageResults<R> emptyIterator() {
return (PageResults<R>) EMPTY;
}

public static <R> PageResults<R> emptyIterator(Query query,
PageState pageState) {
return emptyIterator(query, pageState, false);
}

public static <R> PageResults<R> emptyIterator(Query query,
PageState pageState,
boolean continueOnEmpty) {
return new PageResults<>(
new QueryResults<>(QueryResults.emptyIterator(), query),
pageState, continueOnEmpty);
}
}
}
Loading
Loading