cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [2/6] git commit: Handle null correctly in CqlStorage Patch by Alex Liu, reviewed by brandonwilliams for CASSANDRA-6180
Date Fri, 25 Oct 2013 16:13:19 GMT
Handle null correctly in CqlStorage
Patch by Alex Liu, reviewed by brandonwilliams for CASSANDRA-6180


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

Branch: refs/heads/cassandra-2.0
Commit: cb506b793ced3563e5671f0ad5b92c4d8655d45d
Parents: dcbf35c
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Fri Oct 25 11:10:09 2013 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Fri Oct 25 11:10:09 2013 -0500

----------------------------------------------------------------------
 .../cassandra/hadoop/pig/AbstractCassandraStorage.java       | 4 +++-
 .../org/apache/cassandra/hadoop/pig/CassandraStorage.java    | 5 +++++
 src/java/org/apache/cassandra/hadoop/pig/CqlStorage.java     | 8 ++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/cb506b79/src/java/org/apache/cassandra/hadoop/pig/AbstractCassandraStorage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/pig/AbstractCassandraStorage.java b/src/java/org/apache/cassandra/hadoop/pig/AbstractCassandraStorage.java
index a02e309..98b3a6c 100644
--- a/src/java/org/apache/cassandra/hadoop/pig/AbstractCassandraStorage.java
+++ b/src/java/org/apache/cassandra/hadoop/pig/AbstractCassandraStorage.java
@@ -403,11 +403,13 @@ public abstract class AbstractCassandraStorage extends LoadFunc implements
Store
         // we don't care about types, they all get casted to ByteBuffers
     }
 
+    protected abstract ByteBuffer nullToBB();
+
     /** convert object to ByteBuffer */
     protected ByteBuffer objToBB(Object o)
     {
         if (o == null)
-            return (ByteBuffer)o;
+            return nullToBB();
         if (o instanceof java.lang.String)
             return ByteBuffer.wrap(new DataByteArray((String)o).get());
         if (o instanceof Integer)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/cb506b79/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java b/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java
index 0512a37..853a052 100644
--- a/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java
+++ b/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java
@@ -824,5 +824,10 @@ public class CassandraStorage extends AbstractCassandraStorage
                     "[&init_address=<host>][&rpc_port=<port>]]': " +
e.getMessage());
         }
     }
+    
+    public ByteBuffer nullToBB()
+    {
+        return (ByteBuffer) null;
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/cb506b79/src/java/org/apache/cassandra/hadoop/pig/CqlStorage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/pig/CqlStorage.java b/src/java/org/apache/cassandra/hadoop/pig/CqlStorage.java
index 0d01383..7b31565 100644
--- a/src/java/org/apache/cassandra/hadoop/pig/CqlStorage.java
+++ b/src/java/org/apache/cassandra/hadoop/pig/CqlStorage.java
@@ -710,5 +710,13 @@ public class CqlStorage extends AbstractCassandraStorage
             return validator.getString(validator.decompose(obj));
         return obj;
     }
+
+    /**
+     * Thrift API can't handle null, so use empty byte array
+     */
+    public ByteBuffer nullToBB()
+    {
+        return ByteBuffer.wrap(new byte[0]);
+    }
 }
 


Mime
View raw message