cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xe...@apache.org
Subject [4/4] git commit: fix setting compaction_strategy_class using CQL
Date Sun, 29 Jan 2012 01:37:26 GMT
fix setting compaction_strategy_class using CQL


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

Branch: refs/heads/trunk
Commit: 2c62adab36a589e9ff9e9169fd2125272e067918
Parents: b10d5bd
Author: Pavel Yaskevich <povel.y@gmail.com>
Authored: Sat Jan 28 00:03:12 2012 +0200
Committer: Pavel Yaskevich <povel.y@gmail.com>
Committed: Sun Jan 29 01:54:53 2012 +0200

----------------------------------------------------------------------
 .../cassandra/cql/CreateColumnFamilyStatement.java |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2c62adab/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 1095a72..c0568b9 100644
--- a/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
+++ b/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
@@ -37,6 +37,7 @@ import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.db.ColumnFamilyType;
+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.thrift.InvalidRequestException;
@@ -114,6 +115,7 @@ public class CreateColumnFamilyStatement
     private final Map<String, String> properties = new HashMap<String, String>();
     private List<String> keyValidator = new ArrayList<String>();
     private ByteBuffer keyAlias = null;
+    private Class<? extends AbstractCompactionStrategy> compactionStrategyClass;
     private final Map<String, String> compactionStrategyOptions = new HashMap<String,
String>();
     private final Map<String, String> compressionParameters = new HashMap<String,
String>();
 
@@ -125,6 +127,17 @@ public class CreateColumnFamilyStatement
     /** Perform validation of parsed params */
     private void validate() throws InvalidRequestException
     {
+        String compStrategy = getPropertyString(KW_COMPACTION_STRATEGY_CLASS, CFMetaData.DEFAULT_COMPACTION_STRATEGY_CLASS);
+
+        try
+        {
+            compactionStrategyClass = CFMetaData.createCompactionStrategy(compStrategy);
+        }
+        catch (ConfigurationException e)
+        {
+            throw new InvalidRequestException(e.getMessage());
+        }
+
         // we need to remove parent:key = value pairs from the main properties
         Set<String> propsToRemove = new HashSet<String>();
 
@@ -338,6 +351,7 @@ public class CreateColumnFamilyStatement
                    .keyValidator(TypeParser.parse(comparators.get(getKeyType())))
                    .rowCacheProvider(FBUtilities.newCacheProvider(getPropertyString(KW_ROW_CACHE_PROVIDER,
CFMetaData.DEFAULT_ROW_CACHE_PROVIDER.getClass().getName())))
                    .keyAlias(keyAlias)
+                   .compactionStrategyClass(compactionStrategyClass)
                    .compactionStrategyOptions(compactionStrategyOptions)
                    .compressionParameters(CompressionParameters.create(compressionParameters))
                    .validate();


Mime
View raw message