gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djkevi...@apache.org
Subject [3/3] gora git commit: Fix the error in removing a bin value while updating in aerospike module
Date Tue, 22 Aug 2017 04:15:45 GMT
Fix the error in removing a bin value while updating in aerospike module


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

Branch: refs/heads/master
Commit: 31af406eb992beebcb8c0f6908df8031ef179aeb
Parents: 18c6426
Author: nishadi <ndimeshi@gmail.com>
Authored: Mon Aug 21 20:55:46 2017 +0530
Committer: nishadi <ndimeshi@gmail.com>
Committed: Mon Aug 21 20:55:46 2017 +0530

----------------------------------------------------------------------
 .../gora/aerospike/store/AerospikeStore.java    | 39 ++++++++------------
 1 file changed, 16 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/gora/blob/31af406e/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 677302d..53545f1 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,37 +187,30 @@ public class AerospikeStore<K, T extends PersistentBase> extends
DataStoreBase<K
 
     List<Field> fields = persistent.getSchema().getFields();
 
-    // 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;
       }
       Object persistentValue = persistent.get(i);
+
+      String mappingBinName = aerospikeParameters.getAerospikeMapping().getBinMapping()
+              .get(fields.get(i).name());
+      if (mappingBinName == null) {
+        LOG.error("Aerospike mapping for field {}#{} not found. Wrong gora-aerospike-mapping.xml?",
+                persistent.getClass().getName(), fields.get(i).name());
+        throw new RuntimeException(
+                "Aerospike mapping for field [" + persistent.getClass().getName() + "#" +
fields
+                        .get(i).name() + "] not found. Wrong gora-aerospike-mapping.xml?");
+      }
+      Bin bin;
       if (persistentValue != null) {
-        String mappingBinName = aerospikeParameters.getAerospikeMapping().getBinMapping()
-                .get(fields.get(i).name());
-        if (mappingBinName == null) {
-          LOG.error(
-                  "Aerospike mapping for field {}#{} not found. Wrong gora-aerospike-mapping.xml?",
-                  persistent.getClass().getName(), fields.get(i).name());
-          throw new RuntimeException(
-                  "Aerospike mapping for field [" + persistent.getClass().getName() + "#"
+ fields
-                          .get(i).name() + "] not found. Wrong gora-aerospike-mapping.xml?");
-        }
-        Bin bin = new Bin(mappingBinName,
+        bin = new Bin(mappingBinName,
                 getSerializableValue(persistentValue, fields.get(i).schema()));
-        aerospikeClient
-                .put(aerospikeParameters.getAerospikeMapping().getWritePolicy(), recordKey,
bin);
+      } else {
+        bin = Bin.asNull(mappingBinName);
       }
+      aerospikeClient
+              .put(aerospikeParameters.getAerospikeMapping().getWritePolicy(), recordKey,
bin);
     }
   }
 


Mime
View raw message