cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject svn commit: r1078200 - in /cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress: operations/IndexedRangeSlicer.java operations/Inserter.java util/Operation.java
Date Fri, 04 Mar 2011 23:08:48 GMT
Author: brandonwilliams
Date: Fri Mar  4 23:08:48 2011
New Revision: 1078200

URL: http://svn.apache.org/viewvc?rev=1078200&view=rev
Log:
Generate column values of average rather than specific size.
Patch by Pavel Yaskevich, reviewed by brandonwilliams for CASSANDRA-2266

Modified:
    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/operations/Inserter.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/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=1078200&r1=1078199&r2=1078200&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
Fri Mar  4 23:08:48 2011
@@ -49,7 +49,7 @@ public class IndexedRangeSlicer extends 
         int received = 0;
 
         String startOffset = "0";
-        ByteBuffer value = ByteBuffer.wrap(values.get(index % values.size()).getBytes());
+        ByteBuffer value = ByteBufferUtil.bytes(values.get(index % values.size()));
 
         IndexExpression expression = new IndexExpression(columnName, IndexOperator.EQ, value);
 

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Inserter.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Inserter.java?rev=1078200&r1=1078199&r2=1078200&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Inserter.java
(original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Inserter.java
Fri Mar  4 23:08:48 2011
@@ -46,13 +46,12 @@ public class Inserter extends Operation
         // format used for keys
         String format = "%0" + session.getTotalKeysLength() + "d";
 
-        // columns = [Column('C' + str(j), 'unset', time.time() * 1000000) for j in xrange(columns_per_key)]
         for (int i = 0; i < session.getColumnsPerKey(); i++)
         {
-            String columnName  = ("C" + Integer.toString(i));
-            String columnValue = values.get(index % values.size());
+            String columnName = ("C" + Integer.toString(i));
+            ByteBuffer columnValue = ByteBufferUtil.bytes(values.get(i % values.size()));
 
-            columns.add(new Column(ByteBufferUtil.bytes(columnName), ByteBufferUtil.bytes(columnValue),
System.currentTimeMillis()));
+            columns.add(new Column(ByteBufferUtil.bytes(columnName), columnValue, System.currentTimeMillis()));
         }
 
         if (session.getColumnFamilyType() == ColumnFamilyType.Super)

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=1078200&r1=1078199&r2=1078200&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
Fri Mar  4 23:08:48 2011
@@ -19,6 +19,7 @@ package org.apache.cassandra.contrib.str
 
 import java.io.IOException;
 import java.math.BigInteger;
+import java.nio.ByteBuffer;
 import java.security.MessageDigest;
 
 import java.util.ArrayList;
@@ -29,6 +30,7 @@ import org.apache.cassandra.contrib.stre
 import org.apache.cassandra.contrib.stress.Stress;
 import org.apache.cassandra.thrift.Cassandra;
 import org.apache.cassandra.thrift.InvalidRequestException;
+import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 
 public abstract class Operation
@@ -54,26 +56,21 @@ public abstract class Operation
     // Utility methods
 
     /**
-     * def generate_values():
-     *   values = []
-     *   for i in xrange(0, options.cardinality):
-     *       h = md5(str(i)).hexdigest()
-     *       values.append(h * int(options.column_size/len(h)) + h[:options.column_size %
len(h)])
-     *   return values
-     *
+     * Generate values of average size specified by -S, up to cardinality specified by -C
      * @return Collection of the values
      */
     protected List<String> generateValues()
     {
         List<String> values = new ArrayList<String>();
 
+        int limit = 2 * session.getColumnSize();
+
         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();
+            byte[] value = new byte[Stress.randomizer.nextInt(limit)];
+            Stress.randomizer.nextBytes(value);
 
-            values.add(new StringBuilder(multiplyString(hash, times)).append(hash.substring(0,
sumReminder)).toString());
+            values.add(FBUtilities.bytesToHex(value));
         }
 
         return values;



Mime
View raw message