From c5028b6b2d70cd5ab1a051195ade47bd6fec72f9 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Mon, 14 Apr 2008 14:09:45 +0000 Subject: Added "after" method and removed fetchAfter slice method. --- .../java/com/amazon/carbonado/qe/EmptyQuery.java | 12 ++--- .../com/amazon/carbonado/qe/StandardQuery.java | 61 ++++++++++------------ 2 files changed, 31 insertions(+), 42 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/qe') 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 extends AbstractQuery { return new EmptyQuery(mFactory, properties); } + public Query after(S start) { + return this; + } + /** * Always returns an {@link EmptyCursor}. */ @@ -227,14 +231,6 @@ public final class EmptyQuery extends AbstractQuery { return EmptyCursor.the(); } - /** - * Always returns an {@link EmptyCursor}. - */ - public Cursor fetchAfter(S start, long from, Long to) { - checkSliceArguments(from, to); - return EmptyCursor.the(); - } - /** * Always throws {@link 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 extends AbstractQuery OrderingList.get(getStorableType(), properties), mHints); } - public Cursor fetch() throws FetchException { - try { - return executor().fetch(mValues); - } catch (RepositoryException e) { - throw e.toFetchException(); - } - } - - public Cursor 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 fetchAfter(S start) throws FetchException { + public Query after(S start) throws FetchException { OrderingList orderings; if (start == null || (orderings = mOrdering).size() == 0) { - return fetch(); - } - return buildAfter(start, orderings).fetch(); - } - - public Cursor fetchAfter(S start, long from, Long to) throws FetchException { - if (!checkSliceArguments(from, to)) { - return fetchAfter(start); - } - OrderingList 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 buildAfter(S start, OrderingList orderings) throws FetchException { @@ -271,6 +240,30 @@ public abstract class StandardQuery extends AbstractQuery return and(orderFilter); } + public Cursor fetch() throws FetchException { + try { + return executor().fetch(mValues); + } catch (RepositoryException e) { + throw e.toFetchException(); + } + } + + public Cursor 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 fetchAfter(S start) throws FetchException { + return after(start).fetch(); + } + public boolean tryDeleteOne() throws PersistException { Transaction txn = enterTransaction(IsolationLevel.READ_COMMITTED); try { -- cgit v1.2.3