You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by be...@apache.org on 2015/08/23 12:31:24 UTC

[03/10] cassandra git commit: Support BigDecimal in cassanra-stress

Support BigDecimal in cassanra-stress

patch by Sebastian Estevez; reviewed by Benedict for CASSANDRA-10048


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

Branch: refs/heads/cassandra-3.0
Commit: 5bee617fea68e7b745c18d14b9b7076ab6fe219b
Parents: df9e798
Author: phact <sd...@gmail.com>
Authored: Fri Aug 21 09:50:43 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Sun Aug 23 11:27:16 2015 +0100

----------------------------------------------------------------------
 .../apache/cassandra/stress/StressProfile.java  |  3 +-
 .../stress/generate/values/BigDecimals.java     | 39 ++++++++++++++++++++
 2 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5bee617f/tools/stress/src/org/apache/cassandra/stress/StressProfile.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/StressProfile.java b/tools/stress/src/org/apache/cassandra/stress/StressProfile.java
index 49c4682..192b535 100644
--- a/tools/stress/src/org/apache/cassandra/stress/StressProfile.java
+++ b/tools/stress/src/org/apache/cassandra/stress/StressProfile.java
@@ -502,6 +502,7 @@ public class StressProfile implements Serializable
                 case BOOLEAN:
                     return new Booleans(name, config);
                 case DECIMAL:
+                    return new BigDecimals(name, config);
                 case DOUBLE:
                     return new Doubles(name, config);
                 case FLOAT:
@@ -523,7 +524,7 @@ public class StressProfile implements Serializable
                 case LIST:
                     return new Lists(name, getGenerator(name, type.getTypeArguments().get(0), config), config);
                 default:
-                    throw new UnsupportedOperationException();
+                    throw new UnsupportedOperationException("Because of this name: "+name+" if you removed it from the yaml and are still seeing this, make sure to drop table");
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5bee617f/tools/stress/src/org/apache/cassandra/stress/generate/values/BigDecimals.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/generate/values/BigDecimals.java b/tools/stress/src/org/apache/cassandra/stress/generate/values/BigDecimals.java
new file mode 100644
index 0000000..42758ed
--- /dev/null
+++ b/tools/stress/src/org/apache/cassandra/stress/generate/values/BigDecimals.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.cassandra.stress.generate.values;
+
+import org.apache.cassandra.db.marshal.DecimalType;
+
+import java.math.BigDecimal;
+
+public class BigDecimals extends Generator<BigDecimal>
+{
+    public BigDecimals(String name, GeneratorConfig config)
+    {
+        super(DecimalType.instance, config, name, BigDecimal.class);
+    }
+
+    @Override
+    public BigDecimal generate()
+    {
+        return BigDecimal.valueOf(identityDistribution.next());
+    }
+}