cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject svn commit: r1091911 - in /cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress: Session.java operations/IndexedRangeSlicer.java util/Operation.java
Date Wed, 13 Apr 2011 20:36:41 GMT
Author: brandonwilliams
Date: Wed Apr 13 20:36:41 2011
New Revision: 1091911

URL: http://svn.apache.org/viewvc?rev=1091911&view=rev
Log:
Use old value generation behavior by default in stress.java to allow
indexed range slices to work.
Patch by Pavel Yaskevich, reviewed by brandonwilliams for CASSANDRA-2326

Modified:
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/Session.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/IndexedRangeSlicer.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/Operation.java

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/Session.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/Session.java?rev=1091911&r1=1091910&r2=1091911&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/Session.java
(original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/Session.java
Wed Apr 13 20:36:41 2011
@@ -72,6 +72,7 @@ public class Session
         availableOptions.addOption("x",  "create-index",         true,   "Type of index to
create on needed column families (KEYS)");
         availableOptions.addOption("R",  "replication-strategy", true,   "Replication strategy
to use (only on insert if keyspace does not exist), default:org.apache.cassandra.locator.SimpleStrategy");
         availableOptions.addOption("O",  "strategy-properties",  true,   "Replication strategy
properties in the following format <dc_name>:<num>,<dc_name>:<num>,...");
+        availableOptions.addOption("V",  "average-size-values",  false,  "Generate column
values of average rather than specific size");
     }
 
     private int numKeys          = 1000 * 1000;
@@ -101,6 +102,7 @@ public class Session
     private String replicationStrategy = "org.apache.cassandra.locator.SimpleStrategy";
     private Map<String, String> replicationStrategyOptions = new HashMap<String,
String>();
 
+    public final boolean averageSizeValues;
 
     // required by Gaussian distribution.
     protected int   mean;
@@ -247,6 +249,8 @@ public class Session
                     replicationStrategyOptions.put(keyAndValue[0], keyAndValue[1]);
                 }
             }
+
+            averageSizeValues = cmd.hasOption("V");
         }
         catch (ParseException e)
         {

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/IndexedRangeSlicer.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/IndexedRangeSlicer.java?rev=1091911&r1=1091910&r2=1091911&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/IndexedRangeSlicer.java
(original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/IndexedRangeSlicer.java
Wed Apr 13 20:36:41 2011
@@ -48,8 +48,8 @@ public class IndexedRangeSlicer extends 
 
         int received = 0;
 
-        String startOffset = "0";
-        ByteBuffer value = values.get(index % values.size());
+        String startOffset = String.format(format, 0);
+        ByteBuffer value = values.get(1); // only C1 column is indexed
 
         IndexExpression expression = new IndexExpression(columnName, IndexOperator.EQ, value);
 

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/Operation.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/Operation.java?rev=1091911&r1=1091910&r2=1091911&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/Operation.java
(original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/Operation.java
Wed Apr 13 20:36:41 2011
@@ -55,11 +55,33 @@ public abstract class Operation
 
     // Utility methods
 
+    protected List<ByteBuffer> generateValues()
+    {
+        if (session.averageSizeValues)
+        {
+            return generateRandomizedValues();
+        }
+
+        List<ByteBuffer> values = new ArrayList<ByteBuffer>();
+
+        for (int i = 0; i < session.getCardinality(); i++)
+        {
+            String hash = getMD5(Integer.toString(i));
+            int times = session.getColumnSize() / hash.length();
+            int sumReminder = session.getColumnSize() % hash.length();
+
+            String value = new StringBuilder(multiplyString(hash, times)).append(hash.substring(0,
sumReminder)).toString();
+            values.add(ByteBuffer.wrap(value.getBytes()));
+        }
+
+        return values;
+    }
+
     /**
      * Generate values of average size specified by -S, up to cardinality specified by -C
      * @return Collection of the values
      */
-    protected List<ByteBuffer> generateValues()
+    protected List<ByteBuffer> generateRandomizedValues()
     {
         List<ByteBuffer> values = new ArrayList<ByteBuffer>();
 



Mime
View raw message