[NO ISSUE][ING] Only delete records if found
- user model changes: no
- storage format changes: no
- interface changes: no
details:
- Previously, change feeds that perform upserts and deletes
used to blindly upsert a record for upserts and upsert
an anti-matter for deletes in the absense of secondary
indexes or filters.
- This lead to size blow out when there are a lot of deletes
for keys that don't have values in the index.
- In this change, we only apply deletes strictly when a prevous
value with the same key is found.
Change-Id: Iac32ef87f9da2725bc1b6381a65dba6390b0d3ae
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2327
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java
index 0d74e30..21259cc 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java
@@ -136,8 +136,9 @@
tb.reset();
boolean recordWasInserted = false;
boolean recordWasDeleted = false;
+ boolean isDelete = isDeleteOperation(tuple, numOfPrimaryKeys);
resetSearchPredicate(index);
- if (isFiltered || hasSecondaries) {
+ if (isFiltered || isDelete || hasSecondaries) {
lsmAccessor.search(cursor, searchPred);
if (cursor.hasNext()) {
cursor.next();
@@ -154,12 +155,13 @@
searchCallback.before(key); // lock
appendPreviousTupleAsMissing();
}
- if (isDeleteOperation(tuple, numOfPrimaryKeys)) {
+ if (isDelete && prevTuple != null) {
// Only delete if it is a delete and not upsert
+ // And previous tuple with the same key was found
abstractModCallback.setOp(Operation.DELETE);
lsmAccessor.forceDelete(tuple);
recordWasDeleted = true;
- } else {
+ } else if (!isDelete) {
abstractModCallback.setOp(Operation.UPSERT);
lsmAccessor.forceUpsert(tuple);
recordWasInserted = true;