Search in sources :

Example 1 with Generator

use of org.apache.cassandra.stress.generate.values.Generator in project cassandra by apache.

the class PartitionIterator method setSeed.

void setSeed(Seed seed) {
    long idseed = 0;
    for (int i = 0; i < partitionKey.length; i++) {
        Generator generator = this.generator.partitionKey.get(i);
        // set the partition key seed based on the current work item we're processing
        generator.setSeed(seed.seed);
        Object key = generator.generate();
        partitionKey[i] = key;
        // then contribute this value to the data seed
        idseed = seed(key, generator.type, idseed);
    }
    this.seed = seed;
    this.idseed = idseed;
}
Also used : Generator(org.apache.cassandra.stress.generate.values.Generator)

Example 2 with Generator

use of org.apache.cassandra.stress.generate.values.Generator 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);
}
Also used : HexBytes(org.apache.cassandra.stress.generate.values.HexBytes) Bytes(org.apache.cassandra.stress.generate.values.Bytes) PartitionGenerator(org.apache.cassandra.stress.generate.PartitionGenerator) ArrayList(java.util.ArrayList) HexBytes(org.apache.cassandra.stress.generate.values.HexBytes) GeneratorConfig(org.apache.cassandra.stress.generate.values.GeneratorConfig) PartitionGenerator(org.apache.cassandra.stress.generate.PartitionGenerator) Generator(org.apache.cassandra.stress.generate.values.Generator)

Aggregations

Generator (org.apache.cassandra.stress.generate.values.Generator)2 ArrayList (java.util.ArrayList)1 PartitionGenerator (org.apache.cassandra.stress.generate.PartitionGenerator)1 Bytes (org.apache.cassandra.stress.generate.values.Bytes)1 GeneratorConfig (org.apache.cassandra.stress.generate.values.GeneratorConfig)1 HexBytes (org.apache.cassandra.stress.generate.values.HexBytes)1