cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [2/3] git commit: Merge branch 'cassandra-2.0' into cassandra-2.1.0
Date Wed, 09 Jul 2014 16:23:12 GMT
Merge branch 'cassandra-2.0' into cassandra-2.1.0

Conflicts:
	CHANGES.txt
	src/java/org/apache/cassandra/cql3/statements/SelectStatement.java


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

Branch: refs/heads/cassandra-2.1
Commit: ce46d6619b05465a89ffaaf8fb3e4c2c1f1e547b
Parents: eb4032e 6893130
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Jul 9 18:22:04 2014 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Wed Jul 9 18:22:04 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |   2 +
 .../cql3/statements/SelectStatement.java        |  17 +-
 .../cassandra/cql3/StaticColumnsQueryTest.java  | 263 +++++++++++++++++++
 3 files changed, 277 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ce46d661/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 7fff2d4,3553e4a..e459638
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,25 -1,4 +1,27 @@@
 -2.0.10
 +2.1.0-final
 + * (Windows) fix startup when WMI memory query fails (CASSANDRA-7505)
 + * Anti-compaction proceeds if any part of the repair failed (CASANDRA-7521)
++Merged from 2.0:
++ * Fix error when doing reversed queries with static columns (CASSANDRA-7490)
 +
 +
 +2.1.0-rc3
 + * Consider expiry when reconciling otherwise equal cells (CASSANDRA-7403)
 + * Introduce CQL support for stress tool (CASSANDRA-6146)
 + * Fix ClassCastException processing expired messages (CASSANDRA-7496)
 + * Fix prepared marker for collections inside UDT (CASSANDRA-7472)
 + * Remove left-over populate_io_cache_on_flush and replicate_on_write
 +   uses (CASSANDRA-7493)
 + * (Windows) handle spaces in path names (CASSANDRA-7451)
 + * Ensure writes have completed after dropping a table, before recycling
 +   commit log segments (CASSANDRA-7437)
 + * Remove left-over rows_per_partition_to_cache (CASSANDRA-7493)
 + * Fix error when CONTAINS is used with a bind marker (CASSANDRA-7502)
 + * Properly reject unknown UDT field (CASSANDRA-7484)
 +Merged from 2.0:
 + * Fix CC#collectTimeOrderedData() tombstone optimisations (CASSANDRA-7394)
 + * Support DISTINCT for static columns and fix behaviour when DISTINC is
 +   not use (CASSANDRA-7305).
   * Workaround JVM NPE on JMX bind failure (CASSANDRA-7254)
   * Fix race in FileCacheService RemovalListener (CASSANDRA-7278)
   * Fix inconsistent use of consistencyForCommit that allowed LOCAL_QUORUM

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ce46d661/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index c9572c2,523302f..e4ef0a8
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@@ -460,13 -469,20 +460,20 @@@ public class SelectStatement implement
              if (startBounds.size() == 1)
              {
                  ColumnSlice slice = new ColumnSlice(startBounds.get(0), endBounds.get(0));
 -                if (slice.isAlwaysEmpty(cfDef.cfm.comparator, isReversed))
 +                if (slice.isAlwaysEmpty(cfm.comparator, isReversed))
                      return staticSlice == null ? null : sliceFilter(staticSlice, limit,
toGroup);
  
-                 return staticSlice == null
-                      ? sliceFilter(slice, limit, toGroup)
-                      : (slice.includes(cfm.comparator, staticSlice.finish) ? sliceFilter(new
ColumnSlice(staticSlice.start, slice.finish), limit, toGroup)
-                                                                            : sliceFilter(new
ColumnSlice[]{ staticSlice, slice }, limit, toGroup));
+                 if (staticSlice == null)
+                     return sliceFilter(slice, limit, toGroup);
+ 
+                 if (isReversed)
 -                    return slice.includes(cfDef.cfm.comparator.reverseComparator, staticSlice.start)
++                    return slice.includes(cfm.comparator.reverseComparator(), staticSlice.start)
+                             ? sliceFilter(new ColumnSlice(slice.start, staticSlice.finish),
limit, toGroup)
+                             : sliceFilter(new ColumnSlice[]{ slice, staticSlice }, limit,
toGroup);
+                 else
 -                    return slice.includes(cfDef.cfm.comparator, staticSlice.finish)
++                    return slice.includes(cfm.comparator, staticSlice.finish)
+                             ? sliceFilter(new ColumnSlice(staticSlice.start, slice.finish),
limit, toGroup)
+                             : sliceFilter(new ColumnSlice[]{ staticSlice, slice }, limit,
toGroup);
              }
  
              List<ColumnSlice> l = new ArrayList<ColumnSlice>(startBounds.size());
@@@ -487,10 -504,10 +494,10 @@@
              ColumnSlice[] slices;
              if (isReversed)
              {
-                 if (l.get(l.size() - 1).includes(cfm.comparator, staticSlice.start))
 -                if (l.get(l.size() - 1).includes(cfDef.cfm.comparator.reverseComparator,
staticSlice.start))
++                if (l.get(l.size() - 1).includes(cfm.comparator.reverseComparator(), staticSlice.start))
                  {
                      slices = l.toArray(new ColumnSlice[l.size()]);
 -                    slices[slices.length-1] = new ColumnSlice(slices[slices.length-1].start,
ByteBufferUtil.EMPTY_BYTE_BUFFER);
 +                    slices[slices.length-1] = new ColumnSlice(slices[slices.length-1].start,
Composites.EMPTY);
                  }
                  else
                  {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ce46d661/test/unit/org/apache/cassandra/cql3/StaticColumnsQueryTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/StaticColumnsQueryTest.java
index 0000000,0000000..b386026
new file mode 100644
--- /dev/null
+++ b/test/unit/org/apache/cassandra/cql3/StaticColumnsQueryTest.java
@@@ -1,0 -1,0 +1,263 @@@
++package org.apache.cassandra.cql3;
++
++import org.junit.Test;
++
++/**
++ * Test column ranges and ordering with static column in table
++ */
++public class StaticColumnsQueryTest extends CQLTester
++{
++    @Test
++    public void testSingleClustering() throws Throwable
++    {
++        createTable("CREATE TABLE %s (p text, c text, v text, s text static, PRIMARY KEY
(p, c))");
++
++        execute("INSERT INTO %s(p, c, v, s) values (?, ?, ?, ?)", "p1", "k1", "v1", "sv1");
++        execute("INSERT INTO %s(p, c, v) values (?, ?, ?)", "p1", "k2", "v2");
++        execute("INSERT INTO %s(p, s) values (?, ?)", "p2", "sv2");
++
++        assertRows(execute("SELECT * FROM %s WHERE p=?", "p1"),
++            row("p1", "k1", "sv1", "v1"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=?", "p2"),
++            row("p2", null, "sv2", null)
++        );
++
++        // Ascending order
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c ASC", "p1"),
++            row("p1", "k1", "sv1", "v1"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c ASC", "p2"),
++            row("p2", null, "sv2", null)
++        );
++
++        // Descending order
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c DESC", "p1"),
++            row("p1", "k2", "sv1", "v2"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c DESC", "p2"),
++            row("p2", null, "sv2", null)
++        );
++
++        // No order with one relation
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=?", "p1", "k1"),
++            row("p1", "k1", "sv1", "v1"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=?", "p1", "k2"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c>=?", "p1", "k3"));
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c =?", "p1", "k1"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c<=?", "p1", "k1"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c<=?", "p1", "k0"));
++
++        // Ascending with one relation
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c ASC", "p1",
"k1"),
++            row("p1", "k1", "sv1", "v1"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c ASC", "p1",
"k2"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c ASC", "p1",
"k3"));
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c =? ORDER BY c ASC", "p1", "k1"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c ASC", "p1",
"k1"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c ASC", "p1",
"k0"));
++
++        // Descending with one relation
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c DESC", "p1",
"k1"),
++            row("p1", "k2", "sv1", "v2"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c DESC", "p1",
"k2"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c DESC", "p1",
"k3"));
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c =? ORDER BY c DESC", "p1",
"k1"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c DESC", "p1",
"k1"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c DESC", "p1",
"k0"));
++
++        // IN
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c IN (?, ?)", "p1", "k1", "k2"),
++            row("p1", "k1", "sv1", "v1"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c IN (?, ?) ORDER BY c ASC",
"p1", "k1", "k2"),
++            row("p1", "k1", "sv1", "v1"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c IN (?, ?) ORDER BY c DESC",
"p1", "k1", "k2"),
++            row("p1", "k2", "sv1", "v2"),
++            row("p1", "k1", "sv1", "v1")
++        );
++    }
++
++    @Test
++    public void testSingleClusteringReversed() throws Throwable
++    {
++        createTable("CREATE TABLE %s (p text, c text, v text, s text static, PRIMARY KEY
(p, c)) WITH CLUSTERING ORDER BY (c DESC)");
++
++        execute("INSERT INTO %s(p, c, v, s) values (?, ?, ?, ?)", "p1", "k1", "v1", "sv1");
++        execute("INSERT INTO %s(p, c, v) values (?, ?, ?)", "p1", "k2", "v2");
++        execute("INSERT INTO %s(p, s) values (?, ?)", "p2", "sv2");
++
++        assertRows(execute("SELECT * FROM %s WHERE p=?", "p1"),
++            row("p1", "k2", "sv1", "v2"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=?", "p2"),
++            row("p2", null, "sv2", null)
++        );
++
++        // Ascending order
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c ASC", "p1"),
++            row("p1", "k1", "sv1", "v1"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c ASC", "p2"),
++            row("p2", null, "sv2", null)
++        );
++
++        // Descending order
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c DESC", "p1"),
++            row("p1", "k2", "sv1", "v2"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c DESC", "p2"),
++            row("p2", null, "sv2", null)
++        );
++
++        // No order with one relation
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=?", "p1", "k1"),
++            row("p1", "k2", "sv1", "v2"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=?", "p1", "k2"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c>=?", "p1", "k3"));
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c=?", "p1", "k1"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c<=?", "p1", "k1"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c<=?", "p1", "k0"));
++
++        // Ascending with one relation
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c ASC", "p1",
"k1"),
++            row("p1", "k1", "sv1", "v1"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c ASC", "p1",
"k2"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c ASC", "p1",
"k3"));
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c=? ORDER BY c ASC", "p1", "k1"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c ASC", "p1",
"k1"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c ASC", "p1",
"k0"));
++
++        // Descending with one relation
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c DESC", "p1",
"k1"),
++            row("p1", "k2", "sv1", "v2"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c DESC", "p1",
"k2"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c DESC", "p1",
"k3"));
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c=? ORDER BY c DESC", "p1", "k1"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c DESC", "p1",
"k1"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c DESC", "p1",
"k0"));
++
++        // IN
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c IN (?, ?)", "p1", "k1", "k2"),
++            row("p1", "k2", "sv1", "v2"),
++            row("p1", "k1", "sv1", "v1")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c IN (?, ?) ORDER BY c ASC",
"p1", "k1", "k2"),
++            row("p1", "k1", "sv1", "v1"),
++            row("p1", "k2", "sv1", "v2")
++        );
++
++        assertRows(execute("SELECT * FROM %s WHERE p=? AND c IN (?, ?) ORDER BY c DESC",
"p1", "k1", "k2"),
++            row("p1", "k2", "sv1", "v2"),
++            row("p1", "k1", "sv1", "v1")
++        );
++    }
++}


Mime
View raw message