cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [2/5] git commit: Fix potential AssertionError with 2ndary indexes
Date Thu, 07 Aug 2014 16:36:41 GMT
Fix potential AssertionError with 2ndary indexes

patch by slebresne; reviewed by beobal for CASSANDRA-6612


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

Branch: refs/heads/trunk
Commit: 3970c650d43f8b8bb9aa1c153055fd838a9b4bb6
Parents: 6e6a6c3
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Thu Aug 7 18:09:57 2014 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Thu Aug 7 18:23:52 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                             |  1 +
 .../db/index/AbstractSimplePerColumnSecondaryIndex.java |  6 ++++++
 .../org/apache/cassandra/db/index/SecondaryIndex.java   | 10 ++++++++++
 .../cassandra/db/index/SecondaryIndexManager.java       | 12 +++++-------
 4 files changed, 22 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/3970c650/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 915aeea..df40933 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.10
+ * Fix potential AssertionError with 2ndary indexes (CASSANDRA-6612)
  * Avoid logging CompactionInterrupted at ERROR (CASSANDRA-7694)
  * Minor leak in sstable2jon (CASSANDRA-7709)
  * Add cassandra.auto_bootstrap system property (CASSANDRA-7650)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3970c650/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
b/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
index 8b12575..87e87cb 100644
--- a/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
+++ b/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
@@ -55,6 +55,12 @@ public abstract class AbstractSimplePerColumnSecondaryIndex extends PerColumnSec
                                                              indexedCfMetadata);
     }
 
+    @Override
+    String indexTypeForGrouping()
+    {
+        return "_internal_";
+    }
+
     protected abstract ByteBuffer makeIndexColumnName(ByteBuffer rowKey, Column column);
 
     protected abstract ByteBuffer getIndexedValue(ByteBuffer rowKey, Column column);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3970c650/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/SecondaryIndex.java b/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
index fda28f0..64266c4 100644
--- a/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
+++ b/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
@@ -94,6 +94,16 @@ public abstract class SecondaryIndex
      */
     abstract public String getIndexName();
 
+    /**
+     * All internal 2ndary indexes will return "_internal_" for this. Custom
+     * 2ndary indexes will return their class name. This only matter for
+     * SecondaryIndexManager.groupByIndexType.
+     */
+    String indexTypeForGrouping()
+    {
+        // Our internal indexes overwrite this
+        return getClass().getCanonicalName();
+    }
 
     /**
      * Return the unique name for this index and column

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3970c650/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
index 2c0d611..a15464a 100644
--- a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
+++ b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
@@ -198,17 +198,15 @@ public class SecondaryIndexManager
         if (clause == null || clause.isEmpty())
             return false;
 
-        // It doesn't seem a clause can have multiple searchers, but since
-        // getIndexSearchersForQuery returns a list ...
         List<SecondaryIndexSearcher> searchers = getIndexSearchersForQuery(clause);
         if (searchers.isEmpty())
             return false;
 
         for (SecondaryIndexSearcher searcher : searchers)
-            if (!searcher.isIndexing(clause))
-                return false;
+            if (searcher.isIndexing(clause))
+                return true;
 
-        return true;
+        return false;
     }
 
     /**
@@ -515,12 +513,12 @@ public class SecondaryIndexManager
             if (index == null)
                 continue;
 
-            Set<ByteBuffer> columns = groupByIndexType.get(index.getClass().getCanonicalName());
+            Set<ByteBuffer> columns = groupByIndexType.get(index.indexTypeForGrouping());
 
             if (columns == null)
             {
                 columns = new HashSet<>();
-                groupByIndexType.put(index.getClass().getCanonicalName(), columns);
+                groupByIndexType.put(index.indexTypeForGrouping(), columns);
             }
 
             columns.add(ix.column_name);


Mime
View raw message