summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/amazon/carbonado/raw/RawStorableGenerator.java9
-rw-r--r--src/main/java/com/amazon/carbonado/raw/RawSupport.java10
-rw-r--r--src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java6
3 files changed, 15 insertions, 10 deletions
diff --git a/src/main/java/com/amazon/carbonado/raw/RawStorableGenerator.java b/src/main/java/com/amazon/carbonado/raw/RawStorableGenerator.java
index 07f38a7..8a23bde 100644
--- a/src/main/java/com/amazon/carbonado/raw/RawStorableGenerator.java
+++ b/src/main/java/com/amazon/carbonado/raw/RawStorableGenerator.java
@@ -308,12 +308,14 @@ public class RawStorableGenerator {
mi.addException(TypeDesc.forClass(FetchException.class));
CodeBuilder b = new CodeBuilder(mi);
+ // return rawSupport.tryLoad(this, this.encodeKey$());
b.loadThis();
b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, triggerSupportType);
b.checkCast(rawSupportType);
+ b.loadThis(); // pass this to load method
b.loadThis();
b.invokeVirtual(ENCODE_KEY_METHOD_NAME, byteArrayType, null);
- TypeDesc[] params = {byteArrayType};
+ TypeDesc[] params = {storableType, byteArrayType};
b.invokeInterface(rawSupportType, "tryLoad", byteArrayType, params);
LocalVariable encodedDataVar = b.createLocalVariable(null, byteArrayType);
b.storeLocal(encodedDataVar);
@@ -385,14 +387,15 @@ public class RawStorableGenerator {
mi.addException(TypeDesc.forClass(PersistException.class));
CodeBuilder b = new CodeBuilder(mi);
- // return rawSupport.tryDelete(this.encodeKey$());
+ // return rawSupport.tryDelete(this, this.encodeKey$());
b.loadThis();
b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, triggerSupportType);
b.checkCast(rawSupportType);
+ b.loadThis(); // pass this to delete method
b.loadThis();
b.invokeVirtual(ENCODE_KEY_METHOD_NAME, byteArrayType, null);
- TypeDesc[] params = {byteArrayType};
+ TypeDesc[] params = {storableType, byteArrayType};
b.invokeInterface(rawSupportType, "tryDelete", TypeDesc.BOOLEAN, params);
b.returnValue(TypeDesc.BOOLEAN);
}
diff --git a/src/main/java/com/amazon/carbonado/raw/RawSupport.java b/src/main/java/com/amazon/carbonado/raw/RawSupport.java
index f29b750..0a4d34a 100644
--- a/src/main/java/com/amazon/carbonado/raw/RawSupport.java
+++ b/src/main/java/com/amazon/carbonado/raw/RawSupport.java
@@ -38,16 +38,17 @@ public interface RawSupport<S extends Storable> extends MasterSupport<S> {
* Try to load the entry referenced by the given key, but return null
* if not found.
*
+ * @param storable user storable which will have its properties set
* @param key non-null key to search for
* @return non-null value that was found, or null if not found
*/
- byte[] tryLoad(byte[] key) throws FetchException;
+ byte[] tryLoad(S storable, byte[] key) throws FetchException;
/**
* Try to insert the entry referenced by the given key with the given
* value.
*
- * @param storable storable object that key and value were derived from
+ * @param storable user storable that key and value were derived from
* @param key non-null key to insert
* @param value non-null value to insert
* @return false if unique constraint prevents insert
@@ -58,7 +59,7 @@ public interface RawSupport<S extends Storable> extends MasterSupport<S> {
* Try to store the entry referenced by the given key with the given
* value. If the entry does not exist, insert it. Otherwise, update it.
*
- * @param storable storable object that key and value were derived from
+ * @param storable user storable that key and value were derived from
* @param key non-null key to store
* @param value non-null value to store
*/
@@ -67,10 +68,11 @@ public interface RawSupport<S extends Storable> extends MasterSupport<S> {
/**
* Try to delete the entry referenced by the given key.
*
+ * @param storable user supplied storable object
* @param key non-null key to delete
* @return true if entry existed and is now deleted
*/
- boolean tryDelete(byte[] key) throws PersistException;
+ boolean tryDelete(S storable, byte[] key) throws PersistException;
/**
* Returns the Blob for the given locator, returning null if not found.
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 0d1b92d..4f1ff29 100644
--- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java
+++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java
@@ -279,7 +279,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
throws FetchException
{
byte[] key = mStorableCodec.encodePrimaryKey(identityValues);
- byte[] value = mRawSupport.tryLoad(key);
+ byte[] value = mRawSupport.tryLoad(null, key);
if (value == null) {
return EmptyCursor.the();
}
@@ -1033,7 +1033,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
return mProperties.containsKey(name);
}
- public byte[] tryLoad(byte[] key) throws FetchException {
+ public byte[] tryLoad(S storable, byte[] key) throws FetchException {
TransactionScope<Txn> scope = mStorage.localTransactionScope();
byte[] result;
// Lock out shutdown task.
@@ -1096,7 +1096,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
}
}
- public boolean tryDelete(byte[] key) throws PersistException {
+ public boolean tryDelete(S storable, byte[] key) throws PersistException {
TransactionScope<Txn> scope = mStorage.localTransactionScope();
// Lock out shutdown task.
scope.getLock().lock();