diff options
Diffstat (limited to 'src/main/java/com/amazon/carbonado')
-rw-r--r-- | src/main/java/com/amazon/carbonado/qe/FullScanQueryExecutor.java | 15 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/qe/FullScanQueryExecutor.java b/src/main/java/com/amazon/carbonado/qe/FullScanQueryExecutor.java index dbf5690..b8035f0 100644 --- a/src/main/java/com/amazon/carbonado/qe/FullScanQueryExecutor.java +++ b/src/main/java/com/amazon/carbonado/qe/FullScanQueryExecutor.java @@ -51,6 +51,15 @@ public class FullScanQueryExecutor<S extends Storable> extends AbstractQueryExec mSupport = support;
}
+ @Override
+ public long count(FilterValues<S> values) throws FetchException {
+ long count = mSupport.countAll();
+ if (count == -1) {
+ count = super.count(values);
+ }
+ return count;
+ }
+
/**
* Returns an open filter.
*/
@@ -83,6 +92,12 @@ public class FullScanQueryExecutor<S extends Storable> extends AbstractQueryExec Class<S> getStorableType();
/**
+ * Counts all Storables. Implementation may return -1 to indicate that
+ * default count algorithm should be used.
+ */
+ long countAll() throws FetchException;
+
+ /**
* Perform a full scan of all Storables.
*/
Cursor<S> fetchAll() throws FetchException;
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java index 1fa1244..2901ea0 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java @@ -297,6 +297,10 @@ class IndexedStorage<S extends Storable> implements Storage<S>, StorageAccess<S> return new MergeSortBuffer<S>(mRootStorage);
}
+ public long countAll() throws FetchException {
+ return mMasterStorage.query().count();
+ }
+
public Cursor<S> fetchAll() throws FetchException {
return mMasterStorage.query().fetch();
}
|