cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [2/2] git commit: Fix ALTER TABLE overriding compression options with defaults; patch by Aleksey Yeschenko, reviewed by Jonathan Ellis for CASSANDRA-4996
Date Thu, 13 Dec 2012 20:04:14 GMT
Fix ALTER TABLE overriding compression options with defaults;
patch by Aleksey Yeschenko, reviewed by Jonathan Ellis for
CASSANDRA-4996


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

Branch: refs/heads/cassandra-1.2.0
Commit: 01fcb8cac25b1f617d16a3f72672ecafc02fe458
Parents: 3e27a32
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Thu Dec 13 22:07:58 2012 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Thu Dec 13 22:07:58 2012 +0300

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 src/java/org/apache/cassandra/cql/CFPropDefs.java  |   24 +++++---------
 .../cassandra/cql/CreateColumnFamilyStatement.java |    3 ++
 src/java/org/apache/cassandra/cql3/CFPropDefs.java |   12 ++-----
 .../statements/CreateColumnFamilyStatement.java    |    7 ++--
 5 files changed, 20 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/01fcb8ca/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index e6b1b95..75c715c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -5,6 +5,7 @@
  * Fall back to old describe_splits if d_s_ex is not available (CASSANDRA-4803)
  * Improve error reporting when streaming ranges fail (CASSANDRA-5009)
  * cqlsh: fix timestamp formatting on some platforms (CASSANDRA-5046)
+ * Fix ALTER TABLE overriding compression options with defaults (CASSANDRA-4996)
 
 
 1.1.7

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01fcb8ca/src/java/org/apache/cassandra/cql/CFPropDefs.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql/CFPropDefs.java b/src/java/org/apache/cassandra/cql/CFPropDefs.java
index 7350b3f..b7c6a92 100644
--- a/src/java/org/apache/cassandra/cql/CFPropDefs.java
+++ b/src/java/org/apache/cassandra/cql/CFPropDefs.java
@@ -21,22 +21,22 @@
 
 package org.apache.cassandra.cql;
 
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
 import com.google.common.collect.Sets;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.db.compaction.AbstractCompactionStrategy;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.TypeParser;
 import org.apache.cassandra.io.compress.CompressionParameters;
-import org.apache.cassandra.io.compress.SnappyCompressor;
 import org.apache.cassandra.thrift.InvalidRequestException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
 
 public class CFPropDefs {
     private static Logger logger = LoggerFactory.getLogger(CFPropDefs.class);
@@ -63,8 +63,6 @@ public class CFPropDefs {
     public static final String COMPACTION_OPTIONS_PREFIX = "compaction_strategy_options";
     public static final String COMPRESSION_PARAMETERS_PREFIX = "compression_parameters";
 
-    private static final String DEFAULT_COMPRESSOR = SnappyCompressor.isAvailable() ? SnappyCompressor.class.getCanonicalName()
: null;
-
     static
     {
         comparators.put("ascii", "AsciiType");
@@ -111,11 +109,7 @@ public class CFPropDefs {
     public final Map<String, String> properties = new HashMap<String, String>();
     public Class<? extends AbstractCompactionStrategy> compactionStrategyClass;
     public final Map<String, String> compactionStrategyOptions = new HashMap<String,
String>();
-    public final Map<String, String> compressionParameters = new HashMap<String,
String>()
-    {{
-        if (CFMetaData.DEFAULT_COMPRESSOR != null)
-            put(CompressionParameters.SSTABLE_COMPRESSION, CFMetaData.DEFAULT_COMPRESSOR);
-    }};
+    public final Map<String, String> compressionParameters = new HashMap<String,
String>();
 
     public void validate() throws InvalidRequestException
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01fcb8ca/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java b/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
index 0895e02..bf02035 100644
--- a/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
+++ b/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
@@ -169,6 +169,9 @@ public class CreateColumnFamilyStatement
                                      comparator,
                                      null);
 
+            if (CFMetaData.DEFAULT_COMPRESSOR != null && cfProps.compressionParameters.isEmpty())
+                cfProps.compressionParameters.put(CompressionParameters.SSTABLE_COMPRESSION,
CFMetaData.DEFAULT_COMPRESSOR);
+
             newCFMD.comment(cfProps.getProperty(CFPropDefs.KW_COMMENT))
                    .readRepairChance(getPropertyDouble(CFPropDefs.KW_READREPAIRCHANCE, CFMetaData.DEFAULT_READ_REPAIR_CHANCE))
                    .dcLocalReadRepairChance(getPropertyDouble(CFPropDefs.KW_DCLOCALREADREPAIRCHANCE,
CFMetaData.DEFAULT_DCLOCAL_READ_REPAIR_CHANCE))

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01fcb8ca/src/java/org/apache/cassandra/cql3/CFPropDefs.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/CFPropDefs.java b/src/java/org/apache/cassandra/cql3/CFPropDefs.java
index ec8bd5a..721ef72 100644
--- a/src/java/org/apache/cassandra/cql3/CFPropDefs.java
+++ b/src/java/org/apache/cassandra/cql3/CFPropDefs.java
@@ -18,7 +18,6 @@
  */
 package org.apache.cassandra.cql3;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -35,8 +34,6 @@ import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.TypeParser;
 import org.apache.cassandra.io.compress.CompressionParameters;
 import org.apache.cassandra.thrift.InvalidRequestException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class CFPropDefs extends PropertyDefinitions
 {
@@ -95,11 +92,7 @@ public class CFPropDefs extends PropertyDefinitions
 
     private Class<? extends AbstractCompactionStrategy> compactionStrategyClass = null;
     public final Map<String, String> compactionStrategyOptions = new HashMap<String,
String>();
-    public final Map<String, String> compressionParameters = new HashMap<String,
String>()
-    {{
-        if (CFMetaData.DEFAULT_COMPRESSOR != null)
-            put(CompressionParameters.SSTABLE_COMPRESSION, CFMetaData.DEFAULT_COMPRESSOR);
-    }};
+    public final Map<String, String> compressionParameters = new HashMap<String,
String>();
 
     public static AbstractType<?> parseType(String type) throws InvalidRequestException
     {
@@ -169,7 +162,8 @@ public class CFPropDefs extends PropertyDefinitions
             cfm.compactionStrategyOptions(new HashMap<String, String>(compactionStrategyOptions));
         }
 
-        cfm.compressionParameters(CompressionParameters.create(compressionParameters));
+        if (!compressionParameters.isEmpty())
+            cfm.compressionParameters(CompressionParameters.create(compressionParameters));
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01fcb8ca/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
b/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
index 1f0e0d3..cffb006 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
@@ -24,11 +24,11 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.cassandra.auth.Permission;
-import org.apache.commons.lang.StringUtils;
 import com.google.common.collect.HashMultiset;
 import com.google.common.collect.Multiset;
+import org.apache.commons.lang.StringUtils;
 
+import org.apache.cassandra.auth.Permission;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.config.CFMetaData;
@@ -44,7 +44,6 @@ import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.thrift.CqlResult;
 import org.apache.cassandra.thrift.InvalidRequestException;
 import org.apache.cassandra.io.compress.CompressionParameters;
-import org.apache.cassandra.utils.Pair;
 
 /** A <code>CREATE COLUMNFAMILY</code> parsed from a CQL query statement. */
 public class CreateColumnFamilyStatement extends SchemaAlteringStatement
@@ -64,6 +63,8 @@ public class CreateColumnFamilyStatement extends SchemaAlteringStatement
     {
         super(name);
         this.properties = properties;
+        if (CFMetaData.DEFAULT_COMPRESSOR != null && this.properties.compressionParameters.isEmpty())
+            this.properties.compressionParameters.put(CompressionParameters.SSTABLE_COMPRESSION,
CFMetaData.DEFAULT_COMPRESSOR);
     }
 
     public void checkAccess(ClientState state) throws InvalidRequestException


Mime
View raw message