cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Avoid NPE (and cleanups)
Date Tue, 11 Sep 2012 08:31:02 GMT
Updated Branches:
  refs/heads/trunk c4692a171 -> c20b33c93


Avoid NPE (and cleanups)


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

Branch: refs/heads/trunk
Commit: c20b33c93775f62a638a8725dc07b00142aae252
Parents: c4692a1
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Tue Sep 11 10:30:36 2012 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Tue Sep 11 10:30:56 2012 +0200

----------------------------------------------------------------------
 .../cassandra/cql3/statements/BatchStatement.java  |    4 ++--
 .../cassandra/cql3/statements/DeleteStatement.java |    2 +-
 .../cql3/statements/ModificationStatement.java     |   11 ++++++++---
 .../cassandra/cql3/statements/UpdateStatement.java |    8 ++++----
 4 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c20b33c9/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
index 3a286fc..ac78c89 100644
--- a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
@@ -103,7 +103,7 @@ public class BatchStatement extends ModificationStatement
         for (ModificationStatement statement : statements)
         {
             if (isSetTimestamp())
-                statement.timestamp = timestamp;
+                statement.setTimestamp(getTimestamp(clientState));
 
             List<IMutation> lm = statement.getMutations(clientState, variables);
             // Group mutation together, otherwise they won't get applied atomically
@@ -164,7 +164,7 @@ public class BatchStatement extends ModificationStatement
 
     public String toString()
     {
-        return String.format("BatchStatement(statements=%s, consistency=%s)", statements,
cLevel);
+        return String.format("BatchStatement(statements=%s, consistency=%s)", statements,
getConsistencyLevel());
     }
 
     private static class RowAndCounterMutation

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c20b33c9/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
index cd0293a..73f7c0f 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
@@ -231,7 +231,7 @@ public class DeleteStatement extends ModificationStatement
         return String.format("DeleteStatement(name=%s, columns=%s, consistency=%s keys=%s)",
                              cfName,
                              columns,
-                             cLevel,
+                             getConsistencyLevel(),
                              whereClause);
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c20b33c9/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
index 00674e9..291ecd9 100644
--- a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
@@ -42,9 +42,9 @@ public abstract class ModificationStatement extends CFStatement implements
CQLSt
 {
     public static final ConsistencyLevel defaultConsistency = ConsistencyLevel.ONE;
 
-    protected final ConsistencyLevel cLevel;
-    protected Long timestamp;
-    protected final int timeToLive;
+    private final ConsistencyLevel cLevel;
+    private Long timestamp;
+    private final int timeToLive;
 
     public ModificationStatement(CFName name, Attributes attrs)
     {
@@ -98,6 +98,11 @@ public abstract class ModificationStatement extends CFStatement implements
CQLSt
         return timestamp == null ? clientState.getTimestamp() : timestamp;
     }
 
+    public void setTimestamp(long timestamp)
+    {
+        this.timestamp = timestamp;
+    }
+
     public boolean isSetTimestamp()
     {
         return timestamp != null;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c20b33c9/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java b/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
index 7d49988..a31d7cb 100644
--- a/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
@@ -130,7 +130,7 @@ public class UpdateStatement extends ModificationStatement
         Map<ByteBuffer, ColumnGroupMap> rows = needsReading ? readRows(keys, builder,
(CompositeType)cfDef.cfm.comparator) : null;
 
         List<IMutation> rowMutations = new LinkedList<IMutation>();
-        UpdateParameters params = new UpdateParameters(variables, getTimestamp(clientState),
timeToLive);
+        UpdateParameters params = new UpdateParameters(variables, getTimestamp(clientState),
getTimeToLive());
 
         for (ByteBuffer key: keys)
             rowMutations.add(mutationForKey(cfDef, key, builder, params, rows == null ? null
: rows.get(key)));
@@ -304,7 +304,7 @@ public class UpdateStatement extends ModificationStatement
         // Deal here with the keyspace overwrite thingy to avoid mistake
         CFMetaData metadata = validateColumnFamily(keyspace(), columnFamily(), hasCommutativeOperation);
         if (hasCommutativeOperation)
-            cLevel.validateCounterForWrite(metadata);
+            getConsistencyLevel().validateCounterForWrite(metadata);
 
         cfDef = metadata.getCfDef();
 
@@ -429,7 +429,7 @@ public class UpdateStatement extends ModificationStatement
                              whereClause,
                              columns,
                              getConsistencyLevel(),
-                             timestamp,
-                             timeToLive);
+                             isSetTimestamp() ? getTimestamp(null) : "<now>",
+                             getTimeToLive());
     }
 }


Mime
View raw message