gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djkevi...@apache.org
Subject [1/3] gora git commit: Fix the put method to delete the existing records only if certain fields have been removed
Date Tue, 22 Aug 2017 04:15:43 GMT
Repository: gora
Updated Branches:
  refs/heads/master 460f9f5b0 -> 31af406eb


Fix the put method to delete the existing records only if certain fields have been removed


Project: http://git-wip-us.apache.org/repos/asf/gora/repo
Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/bebc7a8a
Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/bebc7a8a
Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/bebc7a8a

Branch: refs/heads/master
Commit: bebc7a8a524e19739f6128437bab06212a35e75b
Parents: 460f9f5
Author: nishadi <ndimeshi@gmail.com>
Authored: Sun Aug 20 20:02:27 2017 +0530
Committer: nishadi <ndimeshi@gmail.com>
Committed: Sun Aug 20 20:02:27 2017 +0530

----------------------------------------------------------------------
 .../apache/gora/aerospike/store/AerospikeStore.java    | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/gora/blob/bebc7a8a/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
----------------------------------------------------------------------
diff --git a/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
b/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
index 0d5e23f..4ff1a53 100644
--- a/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
+++ b/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
@@ -187,9 +187,16 @@ public class AerospikeStore<K, T extends PersistentBase> extends
DataStoreBase<K
 
     List<Field> fields = persistent.getSchema().getFields();
 
-    if (aerospikeClient.exists(null, recordKey)) {
-      this.delete(key);
+    // Delete the record, if the record exists and a field has been removed
+    for (int i = 0; i < fields.size(); i++) {
+      if (persistent.isDirty(i)) {
+        Object persistentValue = persistent.get(i);
+        if (persistentValue == null && aerospikeClient.exists(null, recordKey)) {
+          this.delete(key);
+        }
+      }
     }
+
     for (int i = 0; i < fields.size(); i++) {
       if (!persistent.isDirty(i)) {
         continue;
@@ -447,7 +454,6 @@ public class AerospikeStore<K, T extends PersistentBase> extends
DataStoreBase<K
     for (String field : fields) {
       setPersistentField(field, record, persistent);
     }
-    persistent.setDirty();
     return persistent;
   }
 
@@ -475,6 +481,7 @@ public class AerospikeStore<K, T extends PersistentBase> extends
DataStoreBase<K
 
     persistent.put(fieldName,
             getDeserializedObject(binValue, binDataType, fieldMap.get(fieldName).schema()));
+    persistent.setDirty(fieldMap.get(fieldName).pos());
   }
 
   /**


Mime
View raw message