cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [2/3] cassandra git commit: Fix bug in schema conversion of index options to thrift format
Date Fri, 09 Oct 2015 10:40:09 GMT
Fix bug in schema conversion of index options to thrift format

Patch by Sam Tunnicliffe; reviewed by Sylvain Lebresne for
CASSANDRA-10483


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

Branch: refs/heads/trunk
Commit: cf365e30216d28b587493d07875182515d21bcad
Parents: 5a808ad
Author: Sam Tunnicliffe <sam@beobal.com>
Authored: Thu Oct 8 18:37:27 2015 +0100
Committer: Sam Tunnicliffe <sam@beobal.com>
Committed: Fri Oct 9 11:28:39 2015 +0100

----------------------------------------------------------------------
 .../apache/cassandra/thrift/ThriftConversion.java  |  2 +-
 .../apache/cassandra/config/CFMetaDataTest.java    | 17 +++++++++++++----
 2 files changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/cf365e30/src/java/org/apache/cassandra/thrift/ThriftConversion.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/ThriftConversion.java b/src/java/org/apache/cassandra/thrift/ThriftConversion.java
index 3794fe0..4a1ff76 100644
--- a/src/java/org/apache/cassandra/thrift/ThriftConversion.java
+++ b/src/java/org/apache/cassandra/thrift/ThriftConversion.java
@@ -611,7 +611,7 @@ public class ThriftConversion
                                                                   s -> !IndexTarget.TARGET_OPTION_NAME.equals(s));
             cd.setIndex_options(filteredOptions.isEmpty()
                                 ? null
-                                : Maps.newHashMap(matchedIndex.options));
+                                : Maps.newHashMap(filteredOptions));
         }
 
         return cd;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/cf365e30/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/config/CFMetaDataTest.java b/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
index 567d516..3deb5fa 100644
--- a/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
+++ b/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
@@ -18,13 +18,12 @@
  */
 package org.apache.cassandra.config;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.HashSet;
+import java.util.*;
 
 import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.marshal.AsciiType;
+import org.apache.cassandra.db.marshal.Int32Type;
 import org.apache.cassandra.db.marshal.UTF8Type;
 import org.apache.cassandra.db.rows.UnfilteredRowIterators;
 import org.apache.cassandra.db.partitions.PartitionUpdate;
@@ -62,6 +61,14 @@ public class CFMetaDataTest
         columnDefs.add(new ColumnDef(ByteBufferUtil.bytes("col2"), UTF8Type.class.getCanonicalName())
                                     .setIndex_name("col2Index")
                                     .setIndex_type(IndexType.KEYS));
+
+        Map<String, String> customIndexOptions = new HashMap<>();
+        customIndexOptions.put("option1", "value1");
+        customIndexOptions.put("option2", "value2");
+        columnDefs.add(new ColumnDef(ByteBufferUtil.bytes("col3"), Int32Type.class.getCanonicalName())
+                                    .setIndex_name("col3Index")
+                                    .setIndex_type(IndexType.CUSTOM)
+                                    .setIndex_options(customIndexOptions));
     }
 
     @BeforeClass
@@ -97,7 +104,9 @@ public class CFMetaDataTest
             c.name = ByteBufferUtil.clone(columnDef.name);
             c.validation_class = columnDef.getValidation_class();
             c.index_name = columnDef.getIndex_name();
-            c.index_type = IndexType.KEYS;
+            c.index_type = columnDef.getIndex_type();
+            if (columnDef.isSetIndex_options())
+                c.setIndex_options(columnDef.getIndex_options());
             thriftCfDef.column_metadata.add(c);
         }
 


Mime
View raw message