cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ble...@apache.org
Subject [1/6] cassandra git commit: Fix 2i page size calculation when there are no regular columns
Date Tue, 04 Apr 2017 12:32:23 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 462b9cf63 -> 828ca7cc9
  refs/heads/cassandra-3.11 6b87e49c3 -> e8053dd8b
  refs/heads/trunk 0f054fee5 -> 56ea68ef7


Fix 2i page size calculation when there are no regular columns

patch by Andrés de la Peña; reviewed by Benjamin Lerer for CASSANDRA-13400


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

Branch: refs/heads/cassandra-3.0
Commit: 828ca7cc925de90c3883e935c66f7beec6fa9113
Parents: 462b9cf
Author: Andrés de la Peña <a.penya.garcia@gmail.com>
Authored: Tue Apr 4 14:23:19 2017 +0200
Committer: Benjamin Lerer <b.lerer@gmail.com>
Committed: Tue Apr 4 14:23:19 2017 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/index/SecondaryIndexManager.java  |  2 +-
 .../index/internal/CassandraIndexTest.java      | 29 ++++++++++++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/828ca7cc/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 4126b07..c258203 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.13
+ * Fix 2i page size calculation when there are no regular columns (CASSANDRA-13400)
  * Fix the conversion of 2.X expired rows without regular column data (CASSANDRA-13395)
  * Fix hint delivery when using ext+internal IPs with prefer_local enabled (CASSANDRA-13020)
  * Fix possible NPE on upgrade to 3.0/3.X in case of IO errors (CASSANDRA-13389)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/828ca7cc/src/java/org/apache/cassandra/index/SecondaryIndexManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/index/SecondaryIndexManager.java b/src/java/org/apache/cassandra/index/SecondaryIndexManager.java
index d39b607..dd6dde4 100644
--- a/src/java/org/apache/cassandra/index/SecondaryIndexManager.java
+++ b/src/java/org/apache/cassandra/index/SecondaryIndexManager.java
@@ -623,7 +623,7 @@ public class SecondaryIndexManager implements IndexRegistry
             return DEFAULT_PAGE_SIZE;
 
         int columnsPerRow = baseCfs.metadata.partitionColumns().regulars.size();
-        if (meanCellsPerPartition <= 0)
+        if (columnsPerRow <= 0)
             return DEFAULT_PAGE_SIZE;
 
         int meanRowsPerPartition = meanCellsPerPartition / columnsPerRow;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/828ca7cc/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java b/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java
index 937512d..6c309ac 100644
--- a/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java
+++ b/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java
@@ -47,6 +47,7 @@ import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 /**
@@ -357,6 +358,34 @@ public class CassandraIndexTest extends CQLTester
     }
 
     @Test
+    public void indexOnClusteringColumnWithoutRegularColumns() throws Throwable
+    {
+        Object[] row1 = row("k0", "c0");
+        Object[] row2 = row("k0", "c1");
+        Object[] row3 = row("k1", "c0");
+        Object[] row4 = row("k1", "c1");
+        String tableName = createTable("CREATE TABLE %s (k text, c text, PRIMARY KEY(k, c))");
+        createIndex("CREATE INDEX no_regulars_idx ON %s(c)");
+
+        execute("INSERT INTO %s (k, c) VALUES (?, ?)", row1);
+        execute("INSERT INTO %s (k, c) VALUES (?, ?)", row2);
+        execute("INSERT INTO %s (k, c) VALUES (?, ?)", row3);
+        execute("INSERT INTO %s (k, c) VALUES (?, ?)", row4);
+
+        assertRowsIgnoringOrder(execute("SELECT * FROM %s WHERE c = ?", "c0"), row1, row3);
+        assertRowsIgnoringOrder(execute("SELECT * FROM %s WHERE c = ?", "c1"), row2, row4);
+        assertEmpty(execute("SELECT * FROM %s WHERE c = ?", "c3"));
+
+        dropIndex("DROP INDEX %s.no_regulars_idx");
+        createIndex("CREATE INDEX no_regulars_idx ON %s(c)");
+        assertTrue(waitForIndex(keyspace(), tableName, "no_regulars_idx"));
+
+        assertRowsIgnoringOrder(execute("SELECT * FROM %s WHERE c = ?", "c0"), row1, row3);
+        assertRowsIgnoringOrder(execute("SELECT * FROM %s WHERE c = ?", "c1"), row2, row4);
+        assertEmpty(execute("SELECT * FROM %s WHERE c = ?", "c3"));
+    }
+
+    @Test
     public void createIndexesOnMultipleMapDimensions() throws Throwable
     {
         Object[] row1 = row(0, 0, ImmutableMap.of("a", 10, "b", 20, "c", 30));


Mime
View raw message