use of org.apache.cassandra.stress.generate.PartitionGenerator in project cassandra by apache.
the class SampledOpDistributionFactory method get.
public OpDistribution get(boolean isWarmup, MeasurementSink sink) {
PartitionGenerator generator = newGenerator();
List<Pair<Operation, Double>> operations = new ArrayList<>();
for (Map.Entry<T, Double> ratio : ratios.entrySet()) {
List<? extends Operation> ops = get(new Timer(ratio.getKey().toString(), sink), generator, ratio.getKey(), isWarmup);
for (Operation op : ops) operations.add(new Pair<>(op, ratio.getValue() / ops.size()));
}
return new SampledOpDistribution(new EnumeratedDistribution<>(operations), clustering.get());
}
use of org.apache.cassandra.stress.generate.PartitionGenerator in project cassandra by apache.
the class SettingsCommandUser method getFactory.
public OpDistributionFactory getFactory(final StressSettings settings) {
final SeedManager seeds = new SeedManager(settings);
final Map<String, TokenRangeIterator> tokenRangeIterators = new LinkedHashMap<>();
profiles.forEach((k, v) -> tokenRangeIterators.put(k, (v.tokenRangeQueries.isEmpty() ? null : new TokenRangeIterator(settings, v.maybeLoadTokenRanges(settings)))));
return new SampledOpDistributionFactory<String>(ratios, clustering) {
protected List<? extends Operation> get(Timer timer, String key, boolean isWarmup) {
Matcher m = EXTRACT_SPEC_CMD.matcher(key);
final String profile_name;
final String sub_key;
if (m.matches()) {
profile_name = m.group(1);
sub_key = m.group(2);
} else {
profile_name = default_profile_name;
sub_key = key;
}
if (!profiles.containsKey(profile_name)) {
throw new IllegalArgumentException(String.format("Op name %s contains an invalid profile specname: %s", key, profile_name));
}
StressProfile profile = profiles.get(profile_name);
TokenRangeIterator tokenRangeIterator = tokenRangeIterators.get(profile_name);
PartitionGenerator generator = profile.newGenerator(settings);
if (sub_key.equalsIgnoreCase("insert"))
return Collections.singletonList(profile.getInsert(timer, generator, seeds, settings));
if (sub_key.equalsIgnoreCase("validate"))
return profile.getValidate(timer, generator, seeds, settings);
if (profile.tokenRangeQueries.containsKey(sub_key))
return Collections.singletonList(profile.getBulkReadQueries(sub_key, timer, settings, tokenRangeIterator, isWarmup));
return Collections.singletonList(profile.getQuery(sub_key, timer, generator, seeds, settings, isWarmup));
}
};
}
use of org.apache.cassandra.stress.generate.PartitionGenerator in project cassandra by apache.
the class SettingsCommandPreDefined method newGenerator.
PartitionGenerator newGenerator(StressSettings settings) {
List<String> names = settings.columns.namestrs;
List<Generator> partitionKey = Collections.<Generator>singletonList(new HexBytes("key", new GeneratorConfig("randomstrkey", null, OptionDistribution.get("fixed(" + keySize + ")"), null)));
List<Generator> columns = new ArrayList<>();
for (int i = 0; i < settings.columns.maxColumnsPerKey; i++) columns.add(new Bytes(names.get(i), new GeneratorConfig("randomstr" + names.get(i), null, settings.columns.sizeDistribution, null)));
return new PartitionGenerator(partitionKey, Collections.<Generator>emptyList(), columns, PartitionGenerator.Order.ARBITRARY);
}
Aggregations