gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmarroq...@apache.org
Subject svn commit: r1579577 - in /gora/branches/GORA_94/gora-cassandra/src/main/java/org/apache/gora/cassandra/store: CassandraClient.java CassandraStore.java
Date Thu, 20 Mar 2014 09:41:16 GMT
Author: rmarroquin
Date: Thu Mar 20 09:41:15 2014
New Revision: 1579577

URL: http://svn.apache.org/r1579577
Log:
GORA-245. Fixes updated

Modified:
    gora/branches/GORA_94/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraClient.java
    gora/branches/GORA_94/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java

Modified: gora/branches/GORA_94/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraClient.java
URL: http://svn.apache.org/viewvc/gora/branches/GORA_94/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraClient.java?rev=1579577&r1=1579576&r2=1579577&view=diff
==============================================================================
--- gora/branches/GORA_94/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraClient.java
(original)
+++ gora/branches/GORA_94/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraClient.java
Thu Mar 20 09:41:15 2014
@@ -297,6 +297,10 @@ public class CassandraClient<K, T extend
     }
   }
 
+  public void deleteGenericArray(K key, String fieldName) {
+    //TODO Verify this. Everything that goes inside a genericArray will go inside a column
so let's just delete that.
+    deleteColumn(key, cassandraMapping.getFamily(fieldName), toByteBuffer(fieldName));
+  }
   public void addGenericArray(K key, String fieldName, GenericArray<?> array) {
     if (isSuper( cassandraMapping.getFamily(fieldName) )) {
       int i= 0;
@@ -321,6 +325,14 @@ public class CassandraClient<K, T extend
     }
   }
 
+  public void deleteStatefulHashMap(K key, String fieldName) {
+    if (isSuper( cassandraMapping.getFamily(fieldName) )) {
+      deleteSubColumn(key, fieldName);
+    } else {
+      deleteColumn(key, cassandraMapping.getFamily(fieldName), toByteBuffer(fieldName));
+    }
+  }
+
   public void addStatefulHashMap(K key, String fieldName, Map<CharSequence,Object>
map) {
     if (isSuper( cassandraMapping.getFamily(fieldName) )) {
       // as we don't know what has changed inside the map or If it's an empty map, then delete
its content.

Modified: gora/branches/GORA_94/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java
URL: http://svn.apache.org/viewvc/gora/branches/GORA_94/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java?rev=1579577&r1=1579576&r2=1579577&view=diff
==============================================================================
--- gora/branches/GORA_94/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java
(original)
+++ gora/branches/GORA_94/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java
Thu Mar 20 09:41:15 2014
@@ -509,6 +509,10 @@ public class CassandraStore<K, T extends
           } else {
             LOG.warn("Record with value: " + value.toString() + " not supported for field:
" + field.name());
           }
+        } else {
+          LOG.warn("Setting content of: " + field.name() + " to null.");
+          String familyName =  this.cassandraClient.getCassandraMapping().getFamily(field.name());
+          this.cassandraClient.deleteColumn(key, familyName, this.cassandraClient.toByteBuffer(field.name()));
         }
         break;
       case MAP:
@@ -544,6 +548,10 @@ public class CassandraStore<K, T extends
           } else {
             LOG.warn("Map with value: " + value.toString() + " not supported for field: "
+ field.name());
           }
+        } else {
+          // delete map
+          LOG.warn("Setting content of: " + field.name() + " to null.");
+          this.cassandraClient.deleteStatefulHashMap(key, field.name());
         }
         break;
       case ARRAY:
@@ -558,15 +566,18 @@ public class CassandraStore<K, T extends
           } else {
             LOG.warn("Array with value: " + value.toString() + " not supported for field:
" + field.name());
           }
+        } else {
+          LOG.warn("Setting content of: " + field.name() + " to null.");
+          this.cassandraClient.deleteGenericArray(key, field.name());
         }
         break;
       case UNION:
+     // adding union schema index
+        String columnName = field.name() + UNION_COL_SUFIX;
+        String familyName = this.cassandraClient.getCassandraMapping().getFamily(field.name());
         if(value != null) {
           int schemaPos = getUnionSchema(value, schema);
           LOG.debug("Union with value: " + value.toString() + " at index: " + schemaPos +
" supported for field: " + field.name());
-          // adding union schema index
-          String columnName = field.name() + UNION_COL_SUFIX;
-          String familyName = this.cassandraClient.getCassandraMapping().getFamily(field.name());
           this.cassandraClient.getCassandraMapping().addColumn(familyName, columnName, columnName);
           if (this.cassandraClient.isSuper( familyName )){
             this.cassandraClient.addSubColumn(key, columnName, columnName, schemaPos);
@@ -574,14 +585,18 @@ public class CassandraStore<K, T extends
             this.cassandraClient.addColumn(key, columnName, schemaPos);
             
           }
-//          this.cassandraClient.getCassandraMapping().addColumn(familyName, columnName,
columnName);
+          //this.cassandraClient.getCassandraMapping().addColumn(familyName, columnName,
columnName);
           // adding union value
           Schema unionSchema = schema.getTypes().get(schemaPos);
           addOrUpdateField(key, field, unionSchema, value);
           //this.cassandraClient.addColumn(key, field.name(), value);
         } else {
           LOG.warn("Setting content of: " + field.name() + " to null.");
-          delete(key);
+          if (this.cassandraClient.isSuper( familyName )){
+            this.cassandraClient.deleteSubColumn(key, field.name());
+          } else {
+            this.cassandraClient.deleteColumn(key, familyName, this.cassandraClient.toByteBuffer(field.name()));
+          }
         }
         break;
       default:



Mime
View raw message