Skip to content

Commit 212e89a

Browse files
committed
fix(hstore): keep range ordering in index layer
1 parent 9eb75e8 commit 212e89a

17 files changed

Lines changed: 383 additions & 1735 deletions

File tree

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/page/IdHolder.java

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,11 @@
3535
public abstract class IdHolder {
3636

3737
protected final Query query;
38-
private final boolean keepOrder;
3938
protected boolean exhausted;
4039

4140
public IdHolder(Query query) {
42-
this(query, false);
43-
}
44-
45-
public IdHolder(Query query, boolean keepOrder) {
4641
E.checkNotNull(query, "query");
4742
this.query = query;
48-
this.keepOrder = keepOrder;
4943
this.exhausted = false;
5044
}
5145

@@ -54,10 +48,6 @@ public Query query() {
5448
}
5549

5650
public boolean keepOrder() {
57-
return this.keepOrder;
58-
}
59-
60-
public boolean continueEmptyPage() {
6151
return false;
6252
}
6353

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

10696
private final Function<ConditionQuery, PageIds> fetcher;
107-
private final boolean continueEmptyPage;
108-
private final boolean continuePartialPage;
10997

11098
public PagingIdHolder(ConditionQuery query,
11199
Function<ConditionQuery, PageIds> fetcher) {
112-
this(query, fetcher, false);
113-
}
114-
115-
public PagingIdHolder(ConditionQuery query,
116-
Function<ConditionQuery, PageIds> fetcher,
117-
boolean keepOrder) {
118-
this(query, fetcher, keepOrder, false, false);
119-
}
120-
121-
public PagingIdHolder(ConditionQuery query,
122-
Function<ConditionQuery, PageIds> fetcher,
123-
boolean keepOrder,
124-
boolean continueEmptyPage) {
125-
this(query, fetcher, keepOrder, continueEmptyPage,
126-
continueEmptyPage);
127-
}
128-
129-
public PagingIdHolder(ConditionQuery query,
130-
Function<ConditionQuery, PageIds> fetcher,
131-
boolean keepOrder,
132-
boolean continueEmptyPage,
133-
boolean continuePartialPage) {
134-
super(query.copy(), keepOrder);
100+
super(query.copy());
135101
E.checkArgument(query.paging(),
136102
"Query '%s' must include page info", query);
137103
this.fetcher = fetcher;
138-
this.continueEmptyPage = continueEmptyPage;
139-
this.continuePartialPage = continuePartialPage;
140104
}
141105

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

156120
PageIds result = this.fetcher.apply((ConditionQuery) this.query);
157121
assert result != null;
158-
if (result.empty() && !this.continueEmptyPage) {
159-
this.exhausted = true;
160-
return PageIds.EMPTY;
161-
}
162-
if (result.page() == null ||
163-
(!this.continuePartialPage &&
164-
result.ids().size() < pageSize)) {
122+
if (result.ids().size() < pageSize || result.page() == null) {
165123
this.exhausted = true;
166124
}
167125
return result;
168126
}
169127

170-
@Override
171-
public boolean continueEmptyPage() {
172-
return this.continueEmptyPage;
173-
}
174-
175128
@Override
176129
public Set<Id> all() {
177130
throw new NotImplementedException("PagingIdHolder.all");
@@ -189,14 +142,7 @@ public static class BatchIdHolder extends IdHolder
189142
public BatchIdHolder(ConditionQuery query,
190143
Iterator<BackendEntry> entries,
191144
Function<Long, Set<Id>> fetcher) {
192-
this(query, entries, fetcher, false);
193-
}
194-
195-
public BatchIdHolder(ConditionQuery query,
196-
Iterator<BackendEntry> entries,
197-
Function<Long, Set<Id>> fetcher,
198-
boolean keepOrder) {
199-
super(query, keepOrder);
145+
super(query);
200146
this.entries = entries;
201147
this.fetcher = fetcher;
202148
this.count = 0L;

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/page/PageEntryIterator.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,7 @@ private boolean fetch() {
8787
this.remaining -= this.pageResults.total();
8888
return true;
8989
} else {
90-
if (this.pageResults.continueOnEmpty() &&
91-
this.pageResults.hasNextPage() &&
92-
!this.pageResults.page().equals(this.pageInfo.page())) {
93-
this.pageInfo.page(this.pageResults.page());
94-
} else {
95-
this.pageInfo.increase();
96-
}
90+
this.pageInfo.increase();
9791
return this.fetch();
9892
}
9993
}

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/page/QueryList.java

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,7 @@ public PageResults<R> iterator(int index, String page, long pageSize) {
272272
this.updateResultsFilter(bindQuery);
273273
PageIds pageIds = holder.fetchNext(page, pageSize);
274274
if (pageIds.empty()) {
275-
return PageResults.emptyIterator(bindQuery,
276-
pageIds.pageState(),
277-
holder.continueEmptyPage());
275+
return PageResults.emptyIterator();
278276
}
279277

280278
QueryResults<R> results = this.queryByIndexIds(pageIds.ids(),
@@ -333,17 +331,10 @@ public static class PageResults<R> {
333331

334332
private final QueryResults<R> results;
335333
private final PageState pageState;
336-
private final boolean continueOnEmpty;
337334

338335
public PageResults(QueryResults<R> results, PageState pageState) {
339-
this(results, pageState, false);
340-
}
341-
342-
public PageResults(QueryResults<R> results, PageState pageState,
343-
boolean continueOnEmpty) {
344336
this.results = results;
345337
this.pageState = pageState;
346-
this.continueOnEmpty = continueOnEmpty;
347338
}
348339

349340
public Iterator<R> get() {
@@ -355,10 +346,6 @@ public boolean hasNextPage() {
355346
PageState.EMPTY_BYTES);
356347
}
357348

358-
public boolean continueOnEmpty() {
359-
return this.continueOnEmpty;
360-
}
361-
362349
public Query query() {
363350
List<Query> queries = this.results.queries();
364351
E.checkState(queries.size() == 1,
@@ -378,18 +365,5 @@ public long total() {
378365
public static <R> PageResults<R> emptyIterator() {
379366
return (PageResults<R>) EMPTY;
380367
}
381-
382-
public static <R> PageResults<R> emptyIterator(Query query,
383-
PageState pageState) {
384-
return emptyIterator(query, pageState, false);
385-
}
386-
387-
public static <R> PageResults<R> emptyIterator(Query query,
388-
PageState pageState,
389-
boolean continueOnEmpty) {
390-
return new PageResults<>(
391-
new QueryResults<>(QueryResults.emptyIterator(), query),
392-
pageState, continueOnEmpty);
393-
}
394368
}
395369
}

0 commit comments

Comments
 (0)