Permalink
Browse files

updated to newest version of hector, using HColumnFamily on inserts

  • Loading branch information...
1 parent 90ff926 commit 705bbc2b5aa755f43bf07ac813574157582ad340 zznate committed Mar 21, 2011
Showing with 17 additions and 7 deletions.
  1. +1 −1 pom.xml
  2. +16 −6 src/main/java/com/riptano/cassandra/stress/SliceCommand.java
View
@@ -4,7 +4,7 @@
<groupId>com.riptano.cassandra.stress</groupId>
<artifactId>cassandra-stress</artifactId>
- <version>0.7_25</version>
+ <version>0.7_28</version>
<packaging>jar</packaging>
<name>cassandra-stress</name>
@@ -8,6 +8,9 @@
import org.slf4j.LoggerFactory;
import me.prettyprint.cassandra.serializers.StringSerializer;
+import me.prettyprint.cassandra.service.CassandraHost;
+import me.prettyprint.cassandra.service.HColumnFamilyImpl;
+import me.prettyprint.hector.api.HColumnFamily;
import me.prettyprint.hector.api.Keyspace;
import me.prettyprint.hector.api.beans.ColumnSlice;
import me.prettyprint.hector.api.factory.HFactory;
@@ -18,12 +21,15 @@
private static Logger log = LoggerFactory.getLogger(SliceCommand.class);
private final SliceQuery<String, String, String> sliceQuery;
+ private final HColumnFamily<String, String> columnFamily;
private static StringSerializer se = StringSerializer.get();
public SliceCommand(int startKey, CommandArgs commandArgs, CommandRunner commandRunner) {
super(startKey, commandArgs, commandRunner);
sliceQuery = HFactory.createSliceQuery(commandArgs.keyspace, se, se, se);
+ columnFamily = new HColumnFamilyImpl<String, String>(commandArgs.keyspace, commandArgs.workingColumnFamily, se, se);
+ columnFamily.setCount(commandArgs.columnCount);
}
@Override
@@ -32,13 +38,17 @@ public Void call() throws Exception {
Random random = new Random();
sliceQuery.setColumnFamily(commandArgs.workingColumnFamily);
log.debug("Starting SliceCommand");
- try {
+ try {
while (rows < commandArgs.getKeysPerThread()) {
- sliceQuery.setKey(String.format("%010d", startKey + random.nextInt(commandArgs.getKeysPerThread())));
- sliceQuery.setRange(null, null, false, commandArgs.columnCount);
- QueryResult<ColumnSlice<String,String>> result = sliceQuery.execute();
- LatencyTracker readCount = commandRunner.latencies.get(result.getHostUsed());
- readCount.addMicro(result.getExecutionTimeMicro());
+ long nanos = System.nanoTime();
+ columnFamily.addKey(String.format("%010d", startKey + random.nextInt(commandArgs.getKeysPerThread())));
+ //sliceQuery.setKey(String.format("%010d", startKey + random.nextInt(commandArgs.getKeysPerThread())));
+ //sliceQuery.setRange(null, null, false, commandArgs.columnCount);
+ //QueryResult<ColumnSlice<String,String>> result = sliceQuery.execute();
+ columnFamily.getColumns();
+ //LatencyTracker readCount = commandRunner.latencies.get(new CassandraHost("localhost:9160"));
+ ///readCount.addMicro((System.nanoTime() - nanos) / 1000);
+ columnFamily.removeKeys().clear();
rows++;
}
} catch (Exception e) {

0 comments on commit 705bbc2

Please sign in to comment.