From 59bc986a088a508a07144b425a9389ff6fc85843 Mon Sep 17 00:00:00 2001 From: Mairbek Khadikov Date: Mon, 23 Jan 2017 18:30:47 -0800 Subject: [PATCH] [core] Use longs instead of ints to support larger key spaces. Changed int to long in Measurements code to support large scale workloads. (manolama - fixed checkstyle errors) Signed-off-by: Chris Larsen --- .../AcknowledgedCounterGenerator.java | 16 +++---- .../ycsb/generator/CounterGenerator.java | 14 +++---- .../generator/HotspotIntegerGenerator.java | 28 ++++++------- .../ycsb/generator/SequentialGenerator.java | 19 +++++---- .../ycsb/generator/UniformGenerator.java | 8 ++-- ...nerator.java => UniformLongGenerator.java} | 17 ++++---- .../measurements/OneMeasurementHistogram.java | 12 +++--- .../OneMeasurementTimeSeries.java | 6 +-- .../JSONArrayMeasurementsExporter.java | 8 ++++ .../exporter/JSONMeasurementsExporter.java | 8 ++++ .../exporter/MeasurementsExporter.java | 10 +++++ .../exporter/TextMeasurementsExporter.java | 5 +++ .../yahoo/ycsb/workloads/CoreWorkload.java | 42 +++++++++---------- .../yahoo/ycsb/workloads/RestWorkload.java | 5 ++- .../AcknowledgedCounterGeneratorTest.java | 10 ++--- 15 files changed, 121 insertions(+), 87 deletions(-) rename core/src/main/java/com/yahoo/ycsb/generator/{UniformIntegerGenerator.java => UniformLongGenerator.java} (64%) diff --git a/core/src/main/java/com/yahoo/ycsb/generator/AcknowledgedCounterGenerator.java b/core/src/main/java/com/yahoo/ycsb/generator/AcknowledgedCounterGenerator.java index fb3cd4d0ff..3bbce0f8e6 100644 --- a/core/src/main/java/com/yahoo/ycsb/generator/AcknowledgedCounterGenerator.java +++ b/core/src/main/java/com/yahoo/ycsb/generator/AcknowledgedCounterGenerator.java @@ -31,12 +31,12 @@ public class AcknowledgedCounterGenerator extends CounterGenerator { private final ReentrantLock lock; private final boolean[] window; - private volatile int limit; + private volatile long limit; /** * Create a counter that starts at countstart. */ - public AcknowledgedCounterGenerator(int countstart) { + public AcknowledgedCounterGenerator(long countstart) { super(countstart); lock = new ReentrantLock(); window = new boolean[WINDOW_SIZE]; @@ -48,15 +48,15 @@ public AcknowledgedCounterGenerator(int countstart) { * (as opposed to the highest generated counter value). */ @Override - public Integer lastValue() { + public Long lastValue() { return limit; } /** * Make a generated counter value available via lastInt(). */ - public void acknowledge(int value) { - final int currentSlot = (value & WINDOW_MASK); + public void acknowledge(long value) { + final int currentSlot = (int)(value & WINDOW_MASK); if (window[currentSlot]) { throw new RuntimeException("Too many unacknowledged insertion keys."); } @@ -68,10 +68,10 @@ public void acknowledge(int value) { // over to the "limit" variable try { // Only loop through the entire window at most once. - int beforeFirstSlot = (limit & WINDOW_MASK); - int index; + long beforeFirstSlot = (limit & WINDOW_MASK); + long index; for (index = limit + 1; index != beforeFirstSlot; ++index) { - int slot = (index & WINDOW_MASK); + int slot = (int)(index & WINDOW_MASK); if (!window[slot]) { break; } diff --git a/core/src/main/java/com/yahoo/ycsb/generator/CounterGenerator.java b/core/src/main/java/com/yahoo/ycsb/generator/CounterGenerator.java index 5666390f13..416502b52a 100644 --- a/core/src/main/java/com/yahoo/ycsb/generator/CounterGenerator.java +++ b/core/src/main/java/com/yahoo/ycsb/generator/CounterGenerator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2016 Yahoo! Inc., 2017 YCSB contributors. All rights reserved. + * Copyright (c) 2010 Yahoo! Inc., Copyright (c) 2017 YCSB contributors. All rights reserved. *

* Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -17,29 +17,29 @@ package com.yahoo.ycsb.generator; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; /** * Generates a sequence of integers. * (0, 1, ...) */ public class CounterGenerator extends NumberGenerator { - private final AtomicInteger counter; + private final AtomicLong counter; /** * Create a counter that starts at countstart. */ - public CounterGenerator(int countstart) { - counter = new AtomicInteger(countstart); + public CounterGenerator(long countstart) { + counter=new AtomicLong(countstart); } @Override - public Integer nextValue() { + public Long nextValue() { return counter.getAndIncrement(); } @Override - public Integer lastValue() { + public Long lastValue() { return counter.get() - 1; } diff --git a/core/src/main/java/com/yahoo/ycsb/generator/HotspotIntegerGenerator.java b/core/src/main/java/com/yahoo/ycsb/generator/HotspotIntegerGenerator.java index 98c8f55c68..677ebd2f2b 100644 --- a/core/src/main/java/com/yahoo/ycsb/generator/HotspotIntegerGenerator.java +++ b/core/src/main/java/com/yahoo/ycsb/generator/HotspotIntegerGenerator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2016 Yahoo! Inc., 2017 YCSB contributors. All rights reserved. + * Copyright (c) 2010 Yahoo! Inc. Copyright (c) 2017 YCSB contributors. All rights reserved. *

* Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -31,10 +31,10 @@ */ public class HotspotIntegerGenerator extends NumberGenerator { - private final int lowerBound; - private final int upperBound; - private final int hotInterval; - private final int coldInterval; + private final long lowerBound; + private final long upperBound; + private final long hotInterval; + private final long coldInterval; private final double hotsetFraction; private final double hotOpnFraction; @@ -46,7 +46,7 @@ public class HotspotIntegerGenerator extends NumberGenerator { * @param hotsetFraction percentage of data item * @param hotOpnFraction percentage of operations accessing the hot set. */ - public HotspotIntegerGenerator(int lowerBound, int upperBound, + public HotspotIntegerGenerator(long lowerBound, long upperBound, double hotsetFraction, double hotOpnFraction) { if (hotsetFraction < 0.0 || hotsetFraction > 1.0) { System.err.println("Hotset fraction out of range. Setting to 0.0"); @@ -59,29 +59,29 @@ public HotspotIntegerGenerator(int lowerBound, int upperBound, if (lowerBound > upperBound) { System.err.println("Upper bound of Hotspot generator smaller than the lower bound. " + "Swapping the values."); - int temp = lowerBound; + long temp = lowerBound; lowerBound = upperBound; upperBound = temp; } this.lowerBound = lowerBound; this.upperBound = upperBound; this.hotsetFraction = hotsetFraction; - int interval = upperBound - lowerBound + 1; + long interval = upperBound - lowerBound + 1; this.hotInterval = (int) (interval * hotsetFraction); this.coldInterval = interval - hotInterval; this.hotOpnFraction = hotOpnFraction; } @Override - public Integer nextValue() { - int value = 0; + public Long nextValue() { + long value = 0; Random random = Utils.random(); if (random.nextDouble() < hotOpnFraction) { // Choose a value from the hot set. - value = lowerBound + random.nextInt(hotInterval); + value = lowerBound + Math.abs(Utils.random().nextLong()) % hotInterval; } else { // Choose a value from the cold set. - value = lowerBound + hotInterval + random.nextInt(coldInterval); + value = lowerBound + hotInterval + Math.abs(Utils.random().nextLong()) % coldInterval; } setLastValue(value); return value; @@ -90,14 +90,14 @@ public Integer nextValue() { /** * @return the lowerBound */ - public int getLowerBound() { + public long getLowerBound() { return lowerBound; } /** * @return the upperBound */ - public int getUpperBound() { + public long getUpperBound() { return upperBound; } diff --git a/core/src/main/java/com/yahoo/ycsb/generator/SequentialGenerator.java b/core/src/main/java/com/yahoo/ycsb/generator/SequentialGenerator.java index 350c222a40..878fb8e137 100644 --- a/core/src/main/java/com/yahoo/ycsb/generator/SequentialGenerator.java +++ b/core/src/main/java/com/yahoo/ycsb/generator/SequentialGenerator.java @@ -17,38 +17,39 @@ package com.yahoo.ycsb.generator; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; /** * Generates a sequence of integers 0, 1, ... */ public class SequentialGenerator extends NumberGenerator { - protected final AtomicInteger counter; - protected int interval, countstart; + private final AtomicLong counter; + private long interval; + private long countstart; /** * Create a counter that starts at countstart. */ - public SequentialGenerator(int countstart, int countend) { - counter = new AtomicInteger(); + public SequentialGenerator(long countstart, long countend) { + counter = new AtomicLong(); setLastValue(counter.get()); this.countstart = countstart; interval = countend - countstart + 1; } /** - * If the generator returns numeric (integer) values, return the next value as an int. + * If the generator returns numeric (long) values, return the next value as an long. * Default is to return -1, which is appropriate for generators that do not return numeric values. */ - public int nextInt() { - int ret = countstart + counter.getAndIncrement() % interval; + public long nextLong() { + long ret = countstart + counter.getAndIncrement() % interval; setLastValue(ret); return ret; } @Override public Number nextValue() { - int ret = countstart + counter.getAndIncrement() % interval; + long ret = countstart + counter.getAndIncrement() % interval; setLastValue(ret); return ret; } diff --git a/core/src/main/java/com/yahoo/ycsb/generator/UniformGenerator.java b/core/src/main/java/com/yahoo/ycsb/generator/UniformGenerator.java index 7943d110fc..aeaf35cb75 100644 --- a/core/src/main/java/com/yahoo/ycsb/generator/UniformGenerator.java +++ b/core/src/main/java/com/yahoo/ycsb/generator/UniformGenerator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2016 Yahoo! Inc., 2017 YCSB contributors. All rights reserved. + * Copyright (c) 2010 Yahoo! Inc. Copyright (c) 2017 YCSB contributors. All rights reserved. *

* Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -27,7 +27,7 @@ public class UniformGenerator extends Generator { private final List values; private String laststring; - private final UniformIntegerGenerator gen; + private final UniformLongGenerator gen; /** * Creates a generator that will return strings from the specified set uniformly randomly. @@ -35,7 +35,7 @@ public class UniformGenerator extends Generator { public UniformGenerator(Collection values) { this.values = new ArrayList<>(values); laststring = null; - gen = new UniformIntegerGenerator(0, values.size() - 1); + gen = new UniformLongGenerator(0, values.size() - 1); } /** @@ -43,7 +43,7 @@ public UniformGenerator(Collection values) { */ @Override public String nextValue() { - laststring = values.get(gen.nextValue()); + laststring = values.get(gen.nextValue().intValue()); return laststring; } diff --git a/core/src/main/java/com/yahoo/ycsb/generator/UniformIntegerGenerator.java b/core/src/main/java/com/yahoo/ycsb/generator/UniformLongGenerator.java similarity index 64% rename from core/src/main/java/com/yahoo/ycsb/generator/UniformIntegerGenerator.java rename to core/src/main/java/com/yahoo/ycsb/generator/UniformLongGenerator.java index 5be015c3bf..2d1994f957 100644 --- a/core/src/main/java/com/yahoo/ycsb/generator/UniformIntegerGenerator.java +++ b/core/src/main/java/com/yahoo/ycsb/generator/UniformLongGenerator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2016 Yahoo! Inc., 2017 YCSB contributors. All rights reserved. + * Copyright (c) 2010 Yahoo! Inc. Copyright (c) 2017 YCSB contributors. All rights reserved. *

* Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -20,27 +20,28 @@ import com.yahoo.ycsb.Utils; /** - * Generates integers randomly uniform from an interval. + * Generates longs randomly uniform from an interval. */ -public class UniformIntegerGenerator extends NumberGenerator { - private final int lb, ub, interval; +public class UniformLongGenerator extends NumberGenerator { + private final long lb, ub, interval; /** - * Creates a generator that will return integers uniformly randomly from the interval [lb,ub] inclusive. + * Creates a generator that will return longs uniformly randomly from the + * interval [lb,ub] inclusive (that is, lb and ub are possible values) * (lb and ub are possible values). * * @param lb the lower bound (inclusive) of generated values * @param ub the upper bound (inclusive) of generated values */ - public UniformIntegerGenerator(int lb, int ub) { + public UniformLongGenerator(long lb, long ub) { this.lb = lb; this.ub = ub; interval = this.ub - this.lb + 1; } @Override - public Integer nextValue() { - int ret = Utils.random().nextInt(interval) + lb; + public Long nextValue() { + long ret = Math.abs(Utils.random().nextLong()) % interval + lb; setLastValue(ret); return ret; diff --git a/core/src/main/java/com/yahoo/ycsb/measurements/OneMeasurementHistogram.java b/core/src/main/java/com/yahoo/ycsb/measurements/OneMeasurementHistogram.java index 9b85518261..de550d12b2 100644 --- a/core/src/main/java/com/yahoo/ycsb/measurements/OneMeasurementHistogram.java +++ b/core/src/main/java/com/yahoo/ycsb/measurements/OneMeasurementHistogram.java @@ -39,17 +39,17 @@ public class OneMeasurementHistogram extends OneMeasurement { /** * Groups operations in discrete blocks of 1ms width. */ - private final int[] histogram; + private long[] histogram; /** * Counts all operations outside the histogram's range. */ - private int histogramoverflow; + private long histogramoverflow; /** * The total number of reported operations. */ - private int operations; + private long operations; /** * The sum of each latency measurement over all operations. @@ -65,7 +65,7 @@ public class OneMeasurementHistogram extends OneMeasurement { private double totalsquaredlatency; //keep a windowed version of these stats for printing status - private int windowoperations; + private long windowoperations; private long windowtotallatency; private int min; @@ -74,7 +74,7 @@ public class OneMeasurementHistogram extends OneMeasurement { public OneMeasurementHistogram(String name, Properties props) { super(name); buckets = Integer.parseInt(props.getProperty(BUCKETS, BUCKETS_DEFAULT)); - histogram = new int[buckets]; + histogram = new long[buckets]; histogramoverflow = 0; operations = 0; totallatency = 0; @@ -120,7 +120,7 @@ public void exportMeasurements(MeasurementsExporter exporter) throws IOException exporter.write(getName(), "MinLatency(us)", min); exporter.write(getName(), "MaxLatency(us)", max); - int opcounter = 0; + long opcounter=0; boolean done95th = false; for (int i = 0; i < buckets; i++) { opcounter += histogram[i]; diff --git a/core/src/main/java/com/yahoo/ycsb/measurements/OneMeasurementTimeSeries.java b/core/src/main/java/com/yahoo/ycsb/measurements/OneMeasurementTimeSeries.java index 678cfbe490..e6abc685da 100644 --- a/core/src/main/java/com/yahoo/ycsb/measurements/OneMeasurementTimeSeries.java +++ b/core/src/main/java/com/yahoo/ycsb/measurements/OneMeasurementTimeSeries.java @@ -54,9 +54,9 @@ public class OneMeasurementTimeSeries extends OneMeasurement { private long start = -1; private long currentunit = -1; - private int count = 0; - private int sum = 0; - private int operations = 0; + private long count = 0; + private long sum = 0; + private long operations = 0; private long totallatency = 0; //keep a windowed version of these stats for printing status diff --git a/core/src/main/java/com/yahoo/ycsb/measurements/exporter/JSONArrayMeasurementsExporter.java b/core/src/main/java/com/yahoo/ycsb/measurements/exporter/JSONArrayMeasurementsExporter.java index e45b50ef6e..ef29e18992 100644 --- a/core/src/main/java/com/yahoo/ycsb/measurements/exporter/JSONArrayMeasurementsExporter.java +++ b/core/src/main/java/com/yahoo/ycsb/measurements/exporter/JSONArrayMeasurementsExporter.java @@ -47,6 +47,14 @@ public void write(String metric, String measurement, int i) throws IOException { g.writeEndObject(); } + public void write(String metric, String measurement, long i) throws IOException { + g.writeStartObject(); + g.writeStringField("metric", metric); + g.writeStringField("measurement", measurement); + g.writeNumberField("value", i); + g.writeEndObject(); + } + public void write(String metric, String measurement, double d) throws IOException { g.writeStartObject(); g.writeStringField("metric", metric); diff --git a/core/src/main/java/com/yahoo/ycsb/measurements/exporter/JSONMeasurementsExporter.java b/core/src/main/java/com/yahoo/ycsb/measurements/exporter/JSONMeasurementsExporter.java index eb3e214754..addcb649c4 100644 --- a/core/src/main/java/com/yahoo/ycsb/measurements/exporter/JSONMeasurementsExporter.java +++ b/core/src/main/java/com/yahoo/ycsb/measurements/exporter/JSONMeasurementsExporter.java @@ -48,6 +48,14 @@ public void write(String metric, String measurement, int i) throws IOException { g.writeEndObject(); } + public void write(String metric, String measurement, long i) throws IOException { + g.writeStartObject(); + g.writeStringField("metric", metric); + g.writeStringField("measurement", measurement); + g.writeNumberField("value", i); + g.writeEndObject(); + } + public void write(String metric, String measurement, double d) throws IOException { g.writeStartObject(); g.writeStringField("metric", metric); diff --git a/core/src/main/java/com/yahoo/ycsb/measurements/exporter/MeasurementsExporter.java b/core/src/main/java/com/yahoo/ycsb/measurements/exporter/MeasurementsExporter.java index e42ea2c539..fb7da1e898 100644 --- a/core/src/main/java/com/yahoo/ycsb/measurements/exporter/MeasurementsExporter.java +++ b/core/src/main/java/com/yahoo/ycsb/measurements/exporter/MeasurementsExporter.java @@ -39,6 +39,16 @@ public interface MeasurementsExporter extends Closeable { * * @param metric Metric name, for example "READ LATENCY". * @param measurement Measurement name, for example "Average latency". + * @param i Measurement to write. + * @throws IOException if writing failed + */ + void write(String metric, String measurement, long i) throws IOException; + + /** + * Write a measurement to the exported format. + * + * @param metric Metric name, for example "READ LATENCY". + * @param measurement Measurement name, for example "Average latency". * @param d Measurement to write. * @throws IOException if writing failed */ diff --git a/core/src/main/java/com/yahoo/ycsb/measurements/exporter/TextMeasurementsExporter.java b/core/src/main/java/com/yahoo/ycsb/measurements/exporter/TextMeasurementsExporter.java index b17a0f12ac..75b24c395d 100644 --- a/core/src/main/java/com/yahoo/ycsb/measurements/exporter/TextMeasurementsExporter.java +++ b/core/src/main/java/com/yahoo/ycsb/measurements/exporter/TextMeasurementsExporter.java @@ -36,6 +36,11 @@ public void write(String metric, String measurement, int i) throws IOException { bw.newLine(); } + public void write(String metric, String measurement, long i) throws IOException { + bw.write("[" + metric + "], " + measurement + ", " + i); + bw.newLine(); + } + public void write(String metric, String measurement, double d) throws IOException { bw.write("[" + metric + "], " + measurement + ", " + d); bw.newLine(); diff --git a/core/src/main/java/com/yahoo/ycsb/workloads/CoreWorkload.java b/core/src/main/java/com/yahoo/ycsb/workloads/CoreWorkload.java index 3e4adfaa5f..6e9f79de96 100644 --- a/core/src/main/java/com/yahoo/ycsb/workloads/CoreWorkload.java +++ b/core/src/main/java/com/yahoo/ycsb/workloads/CoreWorkload.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010 Yahoo! Inc., Copyright (c) 2016 YCSB contributors. All rights reserved. + * Copyright (c) 2010 Yahoo! Inc., Copyright (c) 2016-2017 YCSB contributors. All rights reserved. *

* Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -19,6 +19,7 @@ import com.yahoo.ycsb.*; import com.yahoo.ycsb.generator.*; +import com.yahoo.ycsb.generator.UniformLongGenerator; import com.yahoo.ycsb.measurements.Measurements; import java.io.IOException; @@ -82,9 +83,7 @@ public class CoreWorkload extends Workload { * Default number of fields in a record. */ public static final String FIELD_COUNT_PROPERTY_DEFAULT = "10"; - - protected int fieldcount; - + private List fieldnames; /** @@ -315,7 +314,8 @@ public class CoreWorkload extends Workload { protected AcknowledgedCounterGenerator transactioninsertkeysequence; protected NumberGenerator scanlength; protected boolean orderedinserts; - protected int recordcount; + protected long fieldcount; + protected long recordcount; protected int zeropadding; protected int insertionRetryLimit; protected int insertionRetryInterval; @@ -333,7 +333,7 @@ protected static NumberGenerator getFieldLengthGenerator(Properties p) throws Wo if (fieldlengthdistribution.compareTo("constant") == 0) { fieldlengthgenerator = new ConstantIntegerGenerator(fieldlength); } else if (fieldlengthdistribution.compareTo("uniform") == 0) { - fieldlengthgenerator = new UniformIntegerGenerator(1, fieldlength); + fieldlengthgenerator = new UniformLongGenerator(1, fieldlength); } else if (fieldlengthdistribution.compareTo("zipfian") == 0) { fieldlengthgenerator = new ZipfianGenerator(1, fieldlength); } else if (fieldlengthdistribution.compareTo("histogram") == 0) { @@ -359,7 +359,7 @@ public void init(Properties p) throws WorkloadException { table = p.getProperty(TABLENAME_PROPERTY, TABLENAME_PROPERTY_DEFAULT); fieldcount = - Integer.parseInt(p.getProperty(FIELD_COUNT_PROPERTY, FIELD_COUNT_PROPERTY_DEFAULT)); + Long.parseLong(p.getProperty(FIELD_COUNT_PROPERTY, FIELD_COUNT_PROPERTY_DEFAULT)); fieldnames = new ArrayList<>(); for (int i = 0; i < fieldcount; i++) { fieldnames.add("field" + i); @@ -367,7 +367,7 @@ public void init(Properties p) throws WorkloadException { fieldlengthgenerator = CoreWorkload.getFieldLengthGenerator(p); recordcount = - Integer.parseInt(p.getProperty(Client.RECORD_COUNT_PROPERTY, Client.DEFAULT_RECORD_COUNT)); + Long.parseLong(p.getProperty(Client.RECORD_COUNT_PROPERTY, Client.DEFAULT_RECORD_COUNT)); if (recordcount == 0) { recordcount = Integer.MAX_VALUE; } @@ -378,9 +378,9 @@ public void init(Properties p) throws WorkloadException { String scanlengthdistrib = p.getProperty(SCAN_LENGTH_DISTRIBUTION_PROPERTY, SCAN_LENGTH_DISTRIBUTION_PROPERTY_DEFAULT); - int insertstart = - Integer.parseInt(p.getProperty(INSERT_START_PROPERTY, INSERT_START_PROPERTY_DEFAULT)); - int insertcount = + long insertstart = + Long.parseLong(p.getProperty(INSERT_START_PROPERTY, INSERT_START_PROPERTY_DEFAULT)); + long insertcount= Integer.parseInt(p.getProperty(INSERT_COUNT_PROPERTY, String.valueOf(recordcount - insertstart))); // Confirm valid values for insertstart and insertcount in relation to recordcount if (recordcount < (insertstart + insertcount)) { @@ -426,7 +426,7 @@ public void init(Properties p) throws WorkloadException { transactioninsertkeysequence = new AcknowledgedCounterGenerator(recordcount); if (requestdistrib.compareTo("uniform") == 0) { - keychooser = new UniformIntegerGenerator(insertstart, insertstart + insertcount - 1); + keychooser = new UniformLongGenerator(insertstart, insertstart + insertcount - 1); } else if (requestdistrib.compareTo("sequential") == 0) { keychooser = new SequentialGenerator(insertstart, insertstart + insertcount - 1); } else if (requestdistrib.compareTo("zipfian") == 0) { @@ -458,10 +458,10 @@ public void init(Properties p) throws WorkloadException { throw new WorkloadException("Unknown request distribution \"" + requestdistrib + "\""); } - fieldchooser = new UniformIntegerGenerator(0, fieldcount - 1); + fieldchooser = new UniformLongGenerator(0, fieldcount - 1); if (scanlengthdistrib.compareTo("uniform") == 0) { - scanlength = new UniformIntegerGenerator(1, maxscanlength); + scanlength = new UniformLongGenerator(1, maxscanlength); } else if (scanlengthdistrib.compareTo("zipfian") == 0) { scanlength = new ZipfianGenerator(1, maxscanlength); } else { @@ -646,8 +646,8 @@ protected void verifyRow(String key, HashMap cells) { measurements.reportStatus("VERIFY", verifyStatus); } - protected int nextKeynum() { - int keynum; + long nextKeynum() { + long keynum; if (keychooser instanceof ExponentialGenerator) { do { keynum = transactioninsertkeysequence.lastValue() - keychooser.nextValue().intValue(); @@ -662,7 +662,7 @@ protected int nextKeynum() { public void doTransactionRead(DB db) { // choose a random key - int keynum = nextKeynum(); + long keynum = nextKeynum(); String keyname = buildKeyName(keynum); @@ -689,7 +689,7 @@ public void doTransactionRead(DB db) { public void doTransactionReadModifyWrite(DB db) { // choose a random key - int keynum = nextKeynum(); + long keynum = nextKeynum(); String keyname = buildKeyName(keynum); @@ -736,7 +736,7 @@ public void doTransactionReadModifyWrite(DB db) { public void doTransactionScan(DB db) { // choose a random key - int keynum = nextKeynum(); + long keynum = nextKeynum(); String startkeyname = buildKeyName(keynum); @@ -758,7 +758,7 @@ public void doTransactionScan(DB db) { public void doTransactionUpdate(DB db) { // choose a random key - int keynum = nextKeynum(); + long keynum = nextKeynum(); String keyname = buildKeyName(keynum); @@ -777,7 +777,7 @@ public void doTransactionUpdate(DB db) { public void doTransactionInsert(DB db) { // choose the next key - int keynum = transactioninsertkeysequence.nextValue(); + long keynum = transactioninsertkeysequence.nextValue(); try { String dbkey = buildKeyName(keynum); diff --git a/core/src/main/java/com/yahoo/ycsb/workloads/RestWorkload.java b/core/src/main/java/com/yahoo/ycsb/workloads/RestWorkload.java index 6eb0a96eda..e215ef1650 100644 --- a/core/src/main/java/com/yahoo/ycsb/workloads/RestWorkload.java +++ b/core/src/main/java/com/yahoo/ycsb/workloads/RestWorkload.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 YCSB contributors. All rights reserved. + * Copyright (c) 2016-2017 YCSB contributors. All rights reserved. *

* Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Properties; +import com.yahoo.ycsb.generator.UniformLongGenerator; /** * Typical RESTFul services benchmarking scenario. Represents a set of client * calling REST operations like HTTP DELETE, GET, POST, PUT on a web service. @@ -171,7 +172,7 @@ private static NumberGenerator getKeyChooser(String requestDistrib, int recordCo keychooser = new ExponentialGenerator(percentile, recordCount * frac); break; case "uniform": - keychooser = new UniformIntegerGenerator(0, recordCount - 1); + keychooser = new UniformLongGenerator(0, recordCount - 1); break; case "zipfian": keychooser = new ZipfianGenerator(recordCount, zipfContant); diff --git a/core/src/test/java/com/yahoo/ycsb/generator/AcknowledgedCounterGeneratorTest.java b/core/src/test/java/com/yahoo/ycsb/generator/AcknowledgedCounterGeneratorTest.java index f4aa88b4f0..8e7752757b 100644 --- a/core/src/test/java/com/yahoo/ycsb/generator/AcknowledgedCounterGeneratorTest.java +++ b/core/src/test/java/com/yahoo/ycsb/generator/AcknowledgedCounterGeneratorTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 YCSB contributors. All rights reserved. + * Copyright (c) 2015-2017 YCSB contributors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -38,19 +38,19 @@ public void testIncrementPastIntegerMaxValue() { new AcknowledgedCounterGenerator(Integer.MAX_VALUE - 1000); Random rand = new Random(System.currentTimeMillis()); - BlockingQueue pending = new ArrayBlockingQueue(1000); + BlockingQueue pending = new ArrayBlockingQueue(1000); for (long i = 0; i < toTry; ++i) { - int value = generator.nextValue(); + long value = generator.nextValue(); while (!pending.offer(value)) { - Integer first = pending.poll(); + Long first = pending.poll(); // Don't always advance by one. if (rand.nextBoolean()) { generator.acknowledge(first); } else { - Integer second = pending.poll(); + Long second = pending.poll(); pending.add(first); generator.acknowledge(second); }