summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/qe
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/amazon/carbonado/qe')
-rw-r--r--src/main/java/com/amazon/carbonado/qe/EmptyQuery.java12
-rw-r--r--src/main/java/com/amazon/carbonado/qe/StandardQuery.java61
2 files changed, 31 insertions, 42 deletions
diff --git a/src/main/java/com/amazon/carbonado/qe/EmptyQuery.java b/src/main/java/com/amazon/carbonado/qe/EmptyQuery.java
index 9754019..83c09a6 100644
--- a/src/main/java/com/amazon/carbonado/qe/EmptyQuery.java
+++ b/src/main/java/com/amazon/carbonado/qe/EmptyQuery.java
@@ -205,6 +205,10 @@ public final class EmptyQuery<S extends Storable> extends AbstractQuery<S> {
return new EmptyQuery<S>(mFactory, properties);
}
+ public Query<S> after(S start) {
+ return this;
+ }
+
/**
* Always returns an {@link EmptyCursor}.
*/
@@ -228,14 +232,6 @@ public final class EmptyQuery<S extends Storable> extends AbstractQuery<S> {
}
/**
- * Always returns an {@link EmptyCursor}.
- */
- public Cursor<S> fetchAfter(S start, long from, Long to) {
- checkSliceArguments(from, to);
- return EmptyCursor.the();
- }
-
- /**
* Always throws {@link PersistNoneException}.
*/
public void deleteOne() throws PersistNoneException {
diff --git a/src/main/java/com/amazon/carbonado/qe/StandardQuery.java b/src/main/java/com/amazon/carbonado/qe/StandardQuery.java
index 1ee3acb..f8db1df 100644
--- a/src/main/java/com/amazon/carbonado/qe/StandardQuery.java
+++ b/src/main/java/com/amazon/carbonado/qe/StandardQuery.java
@@ -209,43 +209,12 @@ public abstract class StandardQuery<S extends Storable> extends AbstractQuery<S>
OrderingList.get(getStorableType(), properties), mHints);
}
- public Cursor<S> fetch() throws FetchException {
- try {
- return executor().fetch(mValues);
- } catch (RepositoryException e) {
- throw e.toFetchException();
- }
- }
-
- public Cursor<S> fetch(long from, Long to) throws FetchException {
- if (!checkSliceArguments(from, to)) {
- return fetch();
- }
- try {
- QueryHints hints = QueryHints.emptyHints().with(QueryHint.CONSUME_SLICE);
- return executorFactory().executor(mFilter, mOrdering, hints).fetch(mValues, from, to);
- } catch (RepositoryException e) {
- throw e.toFetchException();
- }
- }
-
- public Cursor<S> fetchAfter(S start) throws FetchException {
+ public Query<S> after(S start) throws FetchException {
OrderingList<S> orderings;
if (start == null || (orderings = mOrdering).size() == 0) {
- return fetch();
- }
- return buildAfter(start, orderings).fetch();
- }
-
- public Cursor<S> fetchAfter(S start, long from, Long to) throws FetchException {
- if (!checkSliceArguments(from, to)) {
- return fetchAfter(start);
- }
- OrderingList<S> orderings;
- if (start == null || (orderings = mOrdering).size() == 0) {
- return fetch(from, to);
+ return this;
}
- return buildAfter(start, orderings).fetch(from, to);
+ return buildAfter(start, orderings);
}
private Query<S> buildAfter(S start, OrderingList<S> orderings) throws FetchException {
@@ -271,6 +240,30 @@ public abstract class StandardQuery<S extends Storable> extends AbstractQuery<S>
return and(orderFilter);
}
+ public Cursor<S> fetch() throws FetchException {
+ try {
+ return executor().fetch(mValues);
+ } catch (RepositoryException e) {
+ throw e.toFetchException();
+ }
+ }
+
+ public Cursor<S> fetch(long from, Long to) throws FetchException {
+ if (!checkSliceArguments(from, to)) {
+ return fetch();
+ }
+ try {
+ QueryHints hints = QueryHints.emptyHints().with(QueryHint.CONSUME_SLICE);
+ return executorFactory().executor(mFilter, mOrdering, hints).fetch(mValues, from, to);
+ } catch (RepositoryException e) {
+ throw e.toFetchException();
+ }
+ }
+
+ public Cursor<S> fetchAfter(S start) throws FetchException {
+ return after(start).fetch();
+ }
+
public boolean tryDeleteOne() throws PersistException {
Transaction txn = enterTransaction(IsolationLevel.READ_COMMITTED);
try {