diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2008-04-07 01:16:19 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2008-04-07 01:16:19 +0000 |
commit | 36c23fee82392014557ff06d4cf7ca42db39f2d3 (patch) | |
tree | b2ce2206630031e0d489146b12d425ba2b783a13 /src/main/java/com/amazon/carbonado/qe | |
parent | 96c1a940cf1c91b389ee39872ec3ab0444252b2d (diff) |
Clean up use of MergeSortBuffer.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/qe')
-rw-r--r-- | src/main/java/com/amazon/carbonado/qe/SortedQueryExecutor.java | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/main/java/com/amazon/carbonado/qe/SortedQueryExecutor.java b/src/main/java/com/amazon/carbonado/qe/SortedQueryExecutor.java index 5419fe6..8202301 100644 --- a/src/main/java/com/amazon/carbonado/qe/SortedQueryExecutor.java +++ b/src/main/java/com/amazon/carbonado/qe/SortedQueryExecutor.java @@ -27,6 +27,7 @@ import com.amazon.carbonado.FetchException; import com.amazon.carbonado.Storable;
import com.amazon.carbonado.cursor.ArraySortBuffer;
+import com.amazon.carbonado.cursor.MergeSortBuffer;
import com.amazon.carbonado.cursor.SortBuffer;
import com.amazon.carbonado.cursor.SortedCursor;
@@ -62,8 +63,12 @@ public class SortedQueryExecutor<S extends Storable> extends AbstractQueryExecut OrderingList<S> handledOrdering,
OrderingList<S> remainderOrdering)
{
- if (support == null && this instanceof Support) {
- support = (Support<S>) this;
+ if (support == null) {
+ if (this instanceof Support) {
+ support = (Support<S>) this;
+ } else {
+ support = new ArraySortSupport<S>();
+ }
}
if (executor == null) {
throw new IllegalArgumentException();
@@ -97,8 +102,7 @@ public class SortedQueryExecutor<S extends Storable> extends AbstractQueryExecut public Cursor<S> fetch(FilterValues<S> values) throws FetchException {
Cursor<S> cursor = mExecutor.fetch(values);
- SortBuffer<S> buffer =
- mSupport == null ? new ArraySortBuffer<S>() : mSupport.createSortBuffer();
+ SortBuffer<S> buffer = mSupport.createSortBuffer();
return new SortedCursor<S>(cursor, buffer, mHandledComparator, mFinisherComparator);
}
@@ -149,4 +153,28 @@ public class SortedQueryExecutor<S extends Storable> extends AbstractQueryExecut */
SortBuffer<S> createSortBuffer();
}
+
+ /**
+ * @since 1.2
+ */
+ public static class ArraySortSupport<S extends Storable> implements Support<S> {
+ /**
+ * Returns a new ArraySortBuffer.
+ */
+ public SortBuffer<S> createSortBuffer() {
+ return new ArraySortBuffer<S>();
+ }
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static class MergeSortSupport<S extends Storable> implements Support<S> {
+ /**
+ * Returns a new MergeSortBuffer.
+ */
+ public SortBuffer<S> createSortBuffer() {
+ return new MergeSortBuffer<S>();
+ }
+ }
}
|