From 121886bc0c92389610408e3b415abb992ad8a212 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Wed, 4 May 2011 00:20:02 +0000 Subject: Add support for Query controller and timeouts; remove vestigial support for interrupts. --- .../carbonado/repo/sleepycat/BDBStorage.java | 56 +++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/amazon/carbonado/repo/sleepycat') diff --git a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java index f4d8f24..c0f882e 100644 --- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java +++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java @@ -45,6 +45,7 @@ import com.amazon.carbonado.UniqueConstraintException; import com.amazon.carbonado.capability.IndexInfo; +import com.amazon.carbonado.cursor.ControllerCursor; import com.amazon.carbonado.cursor.EmptyCursor; import com.amazon.carbonado.cursor.MergeSortBuffer; import com.amazon.carbonado.cursor.SingletonCursor; @@ -263,22 +264,45 @@ abstract class BDBStorage implements Storage, Storag return new MergeSortBuffer(); } + public SortBuffer createSortBuffer(Query.Controller controller) { + return new MergeSortBuffer(controller); + } + public long countAll() throws FetchException { // Return -1 to indicate default algorithm should be used. return -1; } + public long countAll(Query.Controller controller) throws FetchException { + // Return -1 to indicate default algorithm should be used. + return -1; + } + public Cursor fetchAll() throws FetchException { + return fetchAll(null); + } + + public Cursor fetchAll(Query.Controller controller) throws FetchException { return fetchSubset(null, null, BoundaryType.OPEN, null, BoundaryType.OPEN, null, - false, false); + false, false, + controller); } public Cursor fetchOne(StorableIndex index, Object[] identityValues) throws FetchException { + return fetchOne(index, identityValues, null); + } + + public Cursor fetchOne(StorableIndex index, + Object[] identityValues, + Query.Controller controller) + throws FetchException + { + // Note: Controller is never called. byte[] key = mStorableCodec.encodePrimaryKey(identityValues); byte[] value = mRawSupport.tryLoad(null, key); if (value == null) { @@ -296,6 +320,13 @@ abstract class BDBStorage implements Storage, Storag throw new UnsupportedOperationException(); } + public Cursor fetchFromIndexEntryQuery(StorableIndex index, Query indexEntryQuery, + Query.Controller controller) + { + // This method should never be called since null was returned by indexEntryQuery. + throw new UnsupportedOperationException(); + } + public Cursor fetchSubset(StorableIndex index, Object[] identityValues, BoundaryType rangeStartBoundary, @@ -378,6 +409,7 @@ abstract class BDBStorage implements Storage, Storag getPrimaryDatabase()); cursor.open(); + return cursor; } catch (Exception e) { throw toFetchException(e); @@ -387,6 +419,28 @@ abstract class BDBStorage implements Storage, Storag } } + public Cursor fetchSubset(StorableIndex index, + Object[] identityValues, + BoundaryType rangeStartBoundary, + Object rangeStartValue, + BoundaryType rangeEndBoundary, + Object rangeEndValue, + boolean reverseRange, + boolean reverseOrder, + Query.Controller controller) + throws FetchException + { + return ControllerCursor.apply(fetchSubset(index, + identityValues, + rangeStartBoundary, + rangeStartValue, + rangeEndBoundary, + rangeEndValue, + reverseRange, + reverseOrder), + controller); + } + private byte[] createBound(Object[] exactValues, byte[] exactKey, Object rangeValue, StorableCodec codec) { Object[] values = {rangeValue}; -- cgit v1.2.3