summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/repo
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2009-03-24 19:15:57 +0000
committerBrian S. O'Neill <bronee@gmail.com>2009-03-24 19:15:57 +0000
commit816705790c92d4bfac11e1b5fdd60df940cae839 (patch)
tree178e9a20a9bd93ee9e355794ccd64495ee348ee4 /src/main/java/com/amazon/carbonado/repo
parentd0684a34f12a3533343e7b1a2a81cbad3c6c7221 (diff)
Derived index update must tolerate inconsistencies.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/indexed/DerivedIndexesTrigger.java15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/DerivedIndexesTrigger.java b/src/main/java/com/amazon/carbonado/repo/indexed/DerivedIndexesTrigger.java
index 23e2837..ef5c710 100644
--- a/src/main/java/com/amazon/carbonado/repo/indexed/DerivedIndexesTrigger.java
+++ b/src/main/java/com/amazon/carbonado/repo/indexed/DerivedIndexesTrigger.java
@@ -89,15 +89,6 @@ class DerivedIndexesTrigger<S extends Storable, D extends Storable> extends Trig
@Override
public void afterDelete(S storable, Object state) throws PersistException {
updateValues(storable, state);
- /* FIXME: Deleting of derived index entries needs more thought.
- if (state != null) {
- List<Storable> oldIndexEntries = (List<Storable>) state;
- int size = oldIndexEntries.size();
- for (int i=0; i<size; i++) {
- oldIndexEntries.get(i).delete();
- }
- }
- */
}
@Override
@@ -171,9 +162,11 @@ class DerivedIndexesTrigger<S extends Storable, D extends Storable> extends Trig
Storable oldIndexEntry = oldIndexEntries.get(i);
Storable newIndexEntry = newIndexEntries.get(i);
if (!oldIndexEntry.equalProperties(newIndexEntry)) {
- oldIndexEntry.delete();
- newIndexEntry.tryInsert();
+ // Try delete old entry, just in case it is missing.
+ oldIndexEntry.tryDelete();
}
+ // Always try to insert index entry, just in case it is missing.
+ newIndexEntry.tryInsert();
}
}
}