git commit: Fix collection element access in IF

2014-04-02 Thread slebresne
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 d4ec31f21 - 5aafa9876


Fix collection element access in IF

patch by slebresne; reviewed by thobbs for CASSANDRA-6914


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

Branch: refs/heads/cassandra-2.0
Commit: 5aafa98768d0e309c2b19f3a20bdf46e114b0c94
Parents: d4ec31f
Author: Sylvain Lebresne sylv...@datastax.com
Authored: Tue Mar 25 08:48:38 2014 +0100
Committer: Sylvain Lebresne sylv...@datastax.com
Committed: Wed Apr 2 21:28:03 2014 +0200

--
 CHANGES.txt |   1 +
 .../apache/cassandra/cql3/ColumnCondition.java  | 126 +--
 src/java/org/apache/cassandra/cql3/Cql.g|   4 +-
 .../cql3/statements/CQL3CasConditions.java  |   5 +-
 4 files changed, 123 insertions(+), 13 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5aafa987/CHANGES.txt
--
diff --git a/CHANGES.txt b/CHANGES.txt
index 9bbcf07..3a08c33 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -43,6 +43,7 @@
  * Fix error with super columns in mixed 1.2-2.0 clusters (CASSANDRA-6966)
  * Fix bad skip of sstables on slice query with composite start/finish 
(CASSANDRA-6825)
  * Fix unintended update with conditional statement (CASSANDRA-6893)
+ * Fix map element access in IF (CASSANDRA-6914)
 Merged from 1.2:
  * Add UNLOGGED, COUNTER options to BATCH documentation (CASSANDRA-6816)
  * add extra SSL cipher suites (CASSANDRA-6613)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5aafa987/src/java/org/apache/cassandra/cql3/ColumnCondition.java
--
diff --git a/src/java/org/apache/cassandra/cql3/ColumnCondition.java 
b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
index e6cdf43..9fb3390 100644
--- a/src/java/org/apache/cassandra/cql3/ColumnCondition.java
+++ b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
@@ -28,6 +28,7 @@ import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.filter.ColumnSlice;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.utils.ByteBufferUtil;
 
 /**
  * A CQL3 condition.
@@ -35,18 +36,27 @@ import 
org.apache.cassandra.exceptions.InvalidRequestException;
 public class ColumnCondition
 {
 public final CFDefinition.Name column;
+
+// For collection, when testing the equality of a specific element, null 
otherwise.
+private final Term collectionElement;
+
 private final Term value;
 
-private ColumnCondition(CFDefinition.Name column, Term value)
+private ColumnCondition(CFDefinition.Name column, Term collectionElement, 
Term value)
 {
 this.column = column;
+this.collectionElement = collectionElement;
 this.value = value;
 }
 
-// The only ones we support so far
 public static ColumnCondition equal(CFDefinition.Name column, Term value)
 {
-return new ColumnCondition(column, value);
+return new ColumnCondition(column, null, value);
+}
+
+public static ColumnCondition equal(CFDefinition.Name column, Term 
collectionElement, Term value)
+{
+return new ColumnCondition(column, collectionElement, value);
 }
 
 /**
@@ -57,6 +67,8 @@ public class ColumnCondition
  */
 public void collectMarkerSpecification(VariableSpecifications boundNames)
 {
+if (collectionElement != null)
+collectionElement.collectMarkerSpecification(boundNames);
 value.collectMarkerSpecification(boundNames);
 }
 
@@ -74,12 +86,26 @@ public class ColumnCondition
 this.variables = variables;
 }
 
-// Not overriding equals() because we need the variables to have been 
attached when this is
-// called and so having a non standard method name might help avoid 
mistakes
 public boolean equalsTo(WithVariables other) throws 
InvalidRequestException
 {
-return column.equals(other.column())
- 
value.bindAndGet(variables).equals(other.value().bindAndGet(other.variables));
+if (!column().equals(other.column()))
+return false;
+
+if ((collectionElement() == null) != (other.collectionElement() == 
null))
+return false;
+
+if (collectionElement() != null)
+{
+assert column.type instanceof ListType || column.type 
instanceof MapType;
+AbstractType? comparator = column.type instanceof ListType

[1/2] git commit: Fix collection element access in IF

2014-04-02 Thread slebresne
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 8234bc15f - 13510d414


Fix collection element access in IF

patch by slebresne; reviewed by thobbs for CASSANDRA-6914


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

Branch: refs/heads/cassandra-2.1
Commit: 5aafa98768d0e309c2b19f3a20bdf46e114b0c94
Parents: d4ec31f
Author: Sylvain Lebresne sylv...@datastax.com
Authored: Tue Mar 25 08:48:38 2014 +0100
Committer: Sylvain Lebresne sylv...@datastax.com
Committed: Wed Apr 2 21:28:03 2014 +0200

--
 CHANGES.txt |   1 +
 .../apache/cassandra/cql3/ColumnCondition.java  | 126 +--
 src/java/org/apache/cassandra/cql3/Cql.g|   4 +-
 .../cql3/statements/CQL3CasConditions.java  |   5 +-
 4 files changed, 123 insertions(+), 13 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5aafa987/CHANGES.txt
--
diff --git a/CHANGES.txt b/CHANGES.txt
index 9bbcf07..3a08c33 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -43,6 +43,7 @@
  * Fix error with super columns in mixed 1.2-2.0 clusters (CASSANDRA-6966)
  * Fix bad skip of sstables on slice query with composite start/finish 
(CASSANDRA-6825)
  * Fix unintended update with conditional statement (CASSANDRA-6893)
+ * Fix map element access in IF (CASSANDRA-6914)
 Merged from 1.2:
  * Add UNLOGGED, COUNTER options to BATCH documentation (CASSANDRA-6816)
  * add extra SSL cipher suites (CASSANDRA-6613)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5aafa987/src/java/org/apache/cassandra/cql3/ColumnCondition.java
--
diff --git a/src/java/org/apache/cassandra/cql3/ColumnCondition.java 
b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
index e6cdf43..9fb3390 100644
--- a/src/java/org/apache/cassandra/cql3/ColumnCondition.java
+++ b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
@@ -28,6 +28,7 @@ import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.filter.ColumnSlice;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.utils.ByteBufferUtil;
 
 /**
  * A CQL3 condition.
@@ -35,18 +36,27 @@ import 
org.apache.cassandra.exceptions.InvalidRequestException;
 public class ColumnCondition
 {
 public final CFDefinition.Name column;
+
+// For collection, when testing the equality of a specific element, null 
otherwise.
+private final Term collectionElement;
+
 private final Term value;
 
-private ColumnCondition(CFDefinition.Name column, Term value)
+private ColumnCondition(CFDefinition.Name column, Term collectionElement, 
Term value)
 {
 this.column = column;
+this.collectionElement = collectionElement;
 this.value = value;
 }
 
-// The only ones we support so far
 public static ColumnCondition equal(CFDefinition.Name column, Term value)
 {
-return new ColumnCondition(column, value);
+return new ColumnCondition(column, null, value);
+}
+
+public static ColumnCondition equal(CFDefinition.Name column, Term 
collectionElement, Term value)
+{
+return new ColumnCondition(column, collectionElement, value);
 }
 
 /**
@@ -57,6 +67,8 @@ public class ColumnCondition
  */
 public void collectMarkerSpecification(VariableSpecifications boundNames)
 {
+if (collectionElement != null)
+collectionElement.collectMarkerSpecification(boundNames);
 value.collectMarkerSpecification(boundNames);
 }
 
@@ -74,12 +86,26 @@ public class ColumnCondition
 this.variables = variables;
 }
 
-// Not overriding equals() because we need the variables to have been 
attached when this is
-// called and so having a non standard method name might help avoid 
mistakes
 public boolean equalsTo(WithVariables other) throws 
InvalidRequestException
 {
-return column.equals(other.column())
- 
value.bindAndGet(variables).equals(other.value().bindAndGet(other.variables));
+if (!column().equals(other.column()))
+return false;
+
+if ((collectionElement() == null) != (other.collectionElement() == 
null))
+return false;
+
+if (collectionElement() != null)
+{
+assert column.type instanceof ListType || column.type 
instanceof MapType;
+AbstractType? comparator = column.type instanceof ListType

[1/3] git commit: Fix collection element access in IF

2014-04-02 Thread slebresne
Repository: cassandra
Updated Branches:
  refs/heads/trunk 90387f63b - 705171074


Fix collection element access in IF

patch by slebresne; reviewed by thobbs for CASSANDRA-6914


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

Branch: refs/heads/trunk
Commit: 5aafa98768d0e309c2b19f3a20bdf46e114b0c94
Parents: d4ec31f
Author: Sylvain Lebresne sylv...@datastax.com
Authored: Tue Mar 25 08:48:38 2014 +0100
Committer: Sylvain Lebresne sylv...@datastax.com
Committed: Wed Apr 2 21:28:03 2014 +0200

--
 CHANGES.txt |   1 +
 .../apache/cassandra/cql3/ColumnCondition.java  | 126 +--
 src/java/org/apache/cassandra/cql3/Cql.g|   4 +-
 .../cql3/statements/CQL3CasConditions.java  |   5 +-
 4 files changed, 123 insertions(+), 13 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5aafa987/CHANGES.txt
--
diff --git a/CHANGES.txt b/CHANGES.txt
index 9bbcf07..3a08c33 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -43,6 +43,7 @@
  * Fix error with super columns in mixed 1.2-2.0 clusters (CASSANDRA-6966)
  * Fix bad skip of sstables on slice query with composite start/finish 
(CASSANDRA-6825)
  * Fix unintended update with conditional statement (CASSANDRA-6893)
+ * Fix map element access in IF (CASSANDRA-6914)
 Merged from 1.2:
  * Add UNLOGGED, COUNTER options to BATCH documentation (CASSANDRA-6816)
  * add extra SSL cipher suites (CASSANDRA-6613)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5aafa987/src/java/org/apache/cassandra/cql3/ColumnCondition.java
--
diff --git a/src/java/org/apache/cassandra/cql3/ColumnCondition.java 
b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
index e6cdf43..9fb3390 100644
--- a/src/java/org/apache/cassandra/cql3/ColumnCondition.java
+++ b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
@@ -28,6 +28,7 @@ import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.filter.ColumnSlice;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.utils.ByteBufferUtil;
 
 /**
  * A CQL3 condition.
@@ -35,18 +36,27 @@ import 
org.apache.cassandra.exceptions.InvalidRequestException;
 public class ColumnCondition
 {
 public final CFDefinition.Name column;
+
+// For collection, when testing the equality of a specific element, null 
otherwise.
+private final Term collectionElement;
+
 private final Term value;
 
-private ColumnCondition(CFDefinition.Name column, Term value)
+private ColumnCondition(CFDefinition.Name column, Term collectionElement, 
Term value)
 {
 this.column = column;
+this.collectionElement = collectionElement;
 this.value = value;
 }
 
-// The only ones we support so far
 public static ColumnCondition equal(CFDefinition.Name column, Term value)
 {
-return new ColumnCondition(column, value);
+return new ColumnCondition(column, null, value);
+}
+
+public static ColumnCondition equal(CFDefinition.Name column, Term 
collectionElement, Term value)
+{
+return new ColumnCondition(column, collectionElement, value);
 }
 
 /**
@@ -57,6 +67,8 @@ public class ColumnCondition
  */
 public void collectMarkerSpecification(VariableSpecifications boundNames)
 {
+if (collectionElement != null)
+collectionElement.collectMarkerSpecification(boundNames);
 value.collectMarkerSpecification(boundNames);
 }
 
@@ -74,12 +86,26 @@ public class ColumnCondition
 this.variables = variables;
 }
 
-// Not overriding equals() because we need the variables to have been 
attached when this is
-// called and so having a non standard method name might help avoid 
mistakes
 public boolean equalsTo(WithVariables other) throws 
InvalidRequestException
 {
-return column.equals(other.column())
- 
value.bindAndGet(variables).equals(other.value().bindAndGet(other.variables));
+if (!column().equals(other.column()))
+return false;
+
+if ((collectionElement() == null) != (other.collectionElement() == 
null))
+return false;
+
+if (collectionElement() != null)
+{
+assert column.type instanceof ListType || column.type 
instanceof MapType;
+AbstractType? comparator = column.type instanceof ListType
+