From c8dd302fe527f6beb0901ccecfe8e07acb546021 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Mon, 26 Oct 2009 18:46:59 +0000 Subject: Pass Storable to RawSupport when loading and deleting. --- .../java/com/amazon/carbonado/raw/RawStorableGenerator.java | 9 ++++++--- src/main/java/com/amazon/carbonado/raw/RawSupport.java | 10 ++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/raw') 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 extends MasterSupport { * 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 extends MasterSupport { * 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 extends MasterSupport { /** * 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. -- cgit v1.2.3