diff --git a/tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java b/tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java index baab867458..0d0cba157b 100644 --- a/tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java +++ b/tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java @@ -169,7 +169,6 @@ public abstract class PartitionIterator implements Iterator // so that we know with what chance we reached there, and we adjust our roll at that level by that amount final double[] chancemodifier = new double[generator.clusteringComponents.size()]; final double[] rollmodifier = new double[generator.clusteringComponents.size()]; - final ThreadLocalRandom random = ThreadLocalRandom.current(); // track where in the partition we are, and where we are limited to final int[] position = new int[generator.clusteringComponents.size()]; @@ -240,7 +239,7 @@ public abstract class PartitionIterator implements Iterator } // seek to our start position - switch (seek(isWrite ? position : null)) + switch (seek(isWrite ? position : 0)) { case END_OF_PARTITION: return false; @@ -382,6 +381,7 @@ public abstract class PartitionIterator implements Iterator private boolean advance(int depth, boolean first) { + ThreadLocalRandom random = ThreadLocalRandom.current(); // advance the leaf component clusteringComponents[depth].poll(); position[depth]++; @@ -548,9 +548,9 @@ public abstract class PartitionIterator implements Iterator private State setHasNext(boolean hasNext) { + this.hasNext = hasNext; if (!hasNext) { - this.hasNext = false; boolean isLast = finishedPartition(); if (isWrite) { @@ -562,7 +562,6 @@ public abstract class PartitionIterator implements Iterator } return isLast ? State.END_OF_PARTITION : State.AFTER_LIMIT; } - this.hasNext = hasNext; return State.SUCCESS; } } diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaInsert.java b/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaInsert.java index 61237f1cd7..a915d93113 100644 --- a/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaInsert.java +++ b/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaInsert.java @@ -44,15 +44,10 @@ public class SchemaInsert extends SchemaStatement public SchemaInsert(Timer timer, StressSettings settings, PartitionGenerator generator, SeedManager seedManager, Distribution batchSize, RatioDistribution useRatio, Integer thriftId, PreparedStatement statement, ConsistencyLevel cl, BatchStatement.Type batchType) { - super(timer, settings, spec(generator, seedManager, batchSize, useRatio), statement, thriftId, cl, ValidationType.NOT_FAIL); + super(timer, settings, new DataSpec(generator, seedManager, batchSize, useRatio), statement, thriftId, cl, ValidationType.NOT_FAIL); this.batchType = batchType; } - private static DataSpec spec(PartitionGenerator generator, SeedManager seedManager, Distribution partitionCount, RatioDistribution useRatio) - { - return new DataSpec(generator, seedManager, partitionCount, useRatio); - } - private class JavaDriverRun extends Runner { final JavaDriverClient client; diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaQuery.java b/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaQuery.java index 72db2f71a2..a51bac4777 100644 --- a/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaQuery.java +++ b/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaQuery.java @@ -54,16 +54,11 @@ public class SchemaQuery extends SchemaStatement public SchemaQuery(Timer timer, StressSettings settings, PartitionGenerator generator, SeedManager seedManager, Integer thriftId, PreparedStatement statement, ConsistencyLevel cl, ValidationType validationType, ArgSelect argSelect) { - super(timer, settings, spec(generator, seedManager, statement.getVariables().size(), argSelect), statement, thriftId, cl, validationType); + super(timer, settings, new DataSpec(generator, seedManager, new DistributionFixed(1), argSelect == ArgSelect.MULTIROW ? statement.getVariables().size() : 1), statement, thriftId, cl, validationType); this.argSelect = argSelect; randomBuffer = new Object[argumentIndex.length][argumentIndex.length]; } - static DataSpec spec(PartitionGenerator generator, SeedManager seedManager, int argCount, ArgSelect argSelect) - { - return new DataSpec(generator, seedManager, new DistributionFixed(1), argSelect == ArgSelect.MULTIROW ? argCount : 1); - } - private class JavaDriverRun extends Runner { final JavaDriverClient client;