Search in sources :

Example 1 with ScrambledZipfianGenerator

use of site.ycsb.generator.ScrambledZipfianGenerator in project YCSB by brianfrankcooper.

the class TimeSeriesWorkload method init.

@Override
public void init(final Properties p) throws WorkloadException {
    properties = p;
    recordcount = Integer.parseInt(p.getProperty(Client.RECORD_COUNT_PROPERTY, Client.DEFAULT_RECORD_COUNT));
    if (recordcount == 0) {
        recordcount = Integer.MAX_VALUE;
    }
    timestampKey = p.getProperty(TIMESTAMP_KEY_PROPERTY, TIMESTAMP_KEY_PROPERTY_DEFAULT);
    valueKey = p.getProperty(VALUE_KEY_PROPERTY, VALUE_KEY_PROPERTY_DEFAULT);
    operationchooser = CoreWorkload.createOperationGenerator(properties);
    final int maxscanlength = Integer.parseInt(p.getProperty(CoreWorkload.MAX_SCAN_LENGTH_PROPERTY, CoreWorkload.MAX_SCAN_LENGTH_PROPERTY_DEFAULT));
    String scanlengthdistrib = p.getProperty(CoreWorkload.SCAN_LENGTH_DISTRIBUTION_PROPERTY, CoreWorkload.SCAN_LENGTH_DISTRIBUTION_PROPERTY_DEFAULT);
    if (scanlengthdistrib.compareTo("uniform") == 0) {
        scanlength = new UniformLongGenerator(1, maxscanlength);
    } else if (scanlengthdistrib.compareTo("zipfian") == 0) {
        scanlength = new ZipfianGenerator(1, maxscanlength);
    } else {
        throw new WorkloadException("Distribution \"" + scanlengthdistrib + "\" not allowed for scan length");
    }
    randomizeTimestampOrder = Boolean.parseBoolean(p.getProperty(RANDOMIZE_TIMESTAMP_ORDER_PROPERTY, RANDOMIZE_TIMESTAMP_ORDER_PROPERTY_DEFAULT));
    randomizeTimeseriesOrder = Boolean.parseBoolean(p.getProperty(RANDOMIZE_TIMESERIES_ORDER_PROPERTY, RANDOMIZE_TIMESERIES_ORDER_PROPERTY_DEFAULT));
    // setup the cardinality
    numKeys = Integer.parseInt(p.getProperty(CoreWorkload.FIELD_COUNT_PROPERTY, CoreWorkload.FIELD_COUNT_PROPERTY_DEFAULT));
    tagPairs = Integer.parseInt(p.getProperty(TAG_COUNT_PROPERTY, TAG_COUNT_PROPERTY_DEFAULT));
    sparsity = Double.parseDouble(p.getProperty(SPARSITY_PROPERTY, SPARSITY_PROPERTY_DEFAULT));
    tagCardinality = new int[tagPairs];
    final String requestdistrib = p.getProperty(CoreWorkload.REQUEST_DISTRIBUTION_PROPERTY, CoreWorkload.REQUEST_DISTRIBUTION_PROPERTY_DEFAULT);
    if (requestdistrib.compareTo("uniform") == 0) {
        keychooser = new UniformLongGenerator(0, numKeys - 1);
    } else if (requestdistrib.compareTo("sequential") == 0) {
        keychooser = new SequentialGenerator(0, numKeys - 1);
    } else if (requestdistrib.compareTo("zipfian") == 0) {
        keychooser = new ScrambledZipfianGenerator(0, numKeys - 1);
    // } else if (requestdistrib.compareTo("latest") == 0) {
    // keychooser = new SkewedLatestGenerator(transactioninsertkeysequence);
    } else if (requestdistrib.equals("hotspot")) {
        double hotsetfraction = Double.parseDouble(p.getProperty(CoreWorkload.HOTSPOT_DATA_FRACTION, CoreWorkload.HOTSPOT_DATA_FRACTION_DEFAULT));
        double hotopnfraction = Double.parseDouble(p.getProperty(CoreWorkload.HOTSPOT_OPN_FRACTION, CoreWorkload.HOTSPOT_OPN_FRACTION_DEFAULT));
        keychooser = new HotspotIntegerGenerator(0, numKeys - 1, hotsetfraction, hotopnfraction);
    } else {
        throw new WorkloadException("Unknown request distribution \"" + requestdistrib + "\"");
    }
    // figure out the start timestamp based on the units, cardinality and interval
    try {
        timestampInterval = Integer.parseInt(p.getProperty(TIMESTAMP_INTERVAL_PROPERTY, TIMESTAMP_INTERVAL_PROPERTY_DEFAULT));
    } catch (NumberFormatException nfe) {
        throw new WorkloadException("Unable to parse the " + TIMESTAMP_INTERVAL_PROPERTY, nfe);
    }
    try {
        timeUnits = TimeUnit.valueOf(p.getProperty(TIMESTAMP_UNITS_PROPERTY, TIMESTAMP_UNITS_PROPERTY_DEFAULT).toUpperCase());
    } catch (IllegalArgumentException e) {
        throw new WorkloadException("Unknown time unit type", e);
    }
    if (timeUnits == TimeUnit.NANOSECONDS || timeUnits == TimeUnit.MICROSECONDS) {
        throw new WorkloadException("YCSB doesn't support " + timeUnits + " at this time.");
    }
    tagPairDelimiter = p.getProperty(PAIR_DELIMITER_PROPERTY, PAIR_DELIMITER_PROPERTY_DEFAULT);
    deleteDelimiter = p.getProperty(DELETE_DELIMITER_PROPERTY, DELETE_DELIMITER_PROPERTY_DEFAULT);
    dataintegrity = Boolean.parseBoolean(p.getProperty(CoreWorkload.DATA_INTEGRITY_PROPERTY, CoreWorkload.DATA_INTEGRITY_PROPERTY_DEFAULT));
    if (dataintegrity) {
        System.out.println("Data integrity is enabled.");
    }
    queryTimeSpan = Integer.parseInt(p.getProperty(QUERY_TIMESPAN_PROPERTY, QUERY_TIMESPAN_PROPERTY_DEFAULT));
    queryRandomTimeSpan = Boolean.parseBoolean(p.getProperty(QUERY_RANDOM_TIMESPAN_PROPERTY, QUERY_RANDOM_TIMESPAN_PROPERTY_DEFAULT));
    queryTimeSpanDelimiter = p.getProperty(QUERY_TIMESPAN_DELIMITER_PROPERTY, QUERY_TIMESPAN_DELIMITER_PROPERTY_DEFAULT);
    groupByKey = p.getProperty(GROUPBY_KEY_PROPERTY, GROUPBY_KEY_PROPERTY_DEFAULT);
    groupByFunction = p.getProperty(GROUPBY_PROPERTY);
    if (groupByFunction != null && !groupByFunction.isEmpty()) {
        final String groupByKeys = p.getProperty(GROUPBY_KEYS_PROPERTY);
        if (groupByKeys == null || groupByKeys.isEmpty()) {
            throw new WorkloadException("Group by was enabled but no keys were specified.");
        }
        final String[] gbKeys = groupByKeys.split(",");
        if (gbKeys.length != tagKeys.length) {
            throw new WorkloadException("Only " + gbKeys.length + " group by keys " + "were specified but there were " + tagKeys.length + " tag keys given.");
        }
        groupBys = new boolean[gbKeys.length];
        for (int i = 0; i < gbKeys.length; i++) {
            groupBys[i] = Integer.parseInt(gbKeys[i].trim()) == 0 ? false : true;
        }
        groupBy = true;
    }
    downsampleKey = p.getProperty(DOWNSAMPLING_KEY_PROPERTY, DOWNSAMPLING_KEY_PROPERTY_DEFAULT);
    downsampleFunction = p.getProperty(DOWNSAMPLING_FUNCTION_PROPERTY);
    if (downsampleFunction != null && !downsampleFunction.isEmpty()) {
        final String interval = p.getProperty(DOWNSAMPLING_INTERVAL_PROPERTY);
        if (interval == null || interval.isEmpty()) {
            throw new WorkloadException("'" + DOWNSAMPLING_INTERVAL_PROPERTY + "' was missing despite '" + DOWNSAMPLING_FUNCTION_PROPERTY + "' being set.");
        }
        downsampleInterval = Integer.parseInt(interval);
        downsample = true;
    }
    delayedSeries = Double.parseDouble(p.getProperty(DELAYED_SERIES_PROPERTY, DELAYED_SERIES_PROPERTY_DEFAULT));
    delayedIntervals = Integer.parseInt(p.getProperty(DELAYED_INTERVALS_PROPERTY, DELAYED_INTERVALS_PROPERTY_DEFAULT));
    valueType = ValueType.fromString(p.getProperty(VALUE_TYPE_PROPERTY, VALUE_TYPE_PROPERTY_DEFAULT));
    table = p.getProperty(CoreWorkload.TABLENAME_PROPERTY, CoreWorkload.TABLENAME_PROPERTY_DEFAULT);
    initKeysAndTags();
    validateSettings();
}
Also used : ScrambledZipfianGenerator(site.ycsb.generator.ScrambledZipfianGenerator) ZipfianGenerator(site.ycsb.generator.ZipfianGenerator) WorkloadException(site.ycsb.WorkloadException) UniformLongGenerator(site.ycsb.generator.UniformLongGenerator) SequentialGenerator(site.ycsb.generator.SequentialGenerator) ScrambledZipfianGenerator(site.ycsb.generator.ScrambledZipfianGenerator) HotspotIntegerGenerator(site.ycsb.generator.HotspotIntegerGenerator)

Aggregations

WorkloadException (site.ycsb.WorkloadException)1 HotspotIntegerGenerator (site.ycsb.generator.HotspotIntegerGenerator)1 ScrambledZipfianGenerator (site.ycsb.generator.ScrambledZipfianGenerator)1 SequentialGenerator (site.ycsb.generator.SequentialGenerator)1 UniformLongGenerator (site.ycsb.generator.UniformLongGenerator)1 ZipfianGenerator (site.ycsb.generator.ZipfianGenerator)1