diff --git a/core/src/main/java/site/ycsb/workloads/CoreWorkload.java b/core/src/main/java/site/ycsb/workloads/CoreWorkload.java index 082cb0dc2b..5109e13de7 100644 --- a/core/src/main/java/site/ycsb/workloads/CoreWorkload.java +++ b/core/src/main/java/site/ycsb/workloads/CoreWorkload.java @@ -41,6 +41,7 @@ *
  • readproportion: what proportion of operations should be reads (default: 0.95) *
  • updateproportion: what proportion of operations should be updates (default: 0.05) *
  • insertproportion: what proportion of operations should be inserts (default: 0) + *
  • deleteproportion: what proportion of operations should be deletes (default: 0) *
  • scanproportion: what proportion of operations should be scans (default: 0) *
  • readmodifywriteproportion: what proportion of operations should be read a record, * modify it, write it back (default: 0) @@ -240,6 +241,16 @@ public class CoreWorkload extends Workload { */ public static final String SCAN_PROPORTION_PROPERTY_DEFAULT = "0.0"; + /** + * The name of the property for the proportion of transactions that are deletes. + */ + public static final String DELETE_PROPORTION_PROPERTY = "deleteproportion"; + + /** + * The default proportion of transactions that are delete. + */ + public static final String DELETE_PROPORTION_PROPERTY_DEFAULT = "0.0"; + /** * The name of the property for the proportion of transactions that are read-modify-write. */ @@ -488,7 +499,7 @@ public void init(Properties p) throws WorkloadException { keysequence = new CounterGenerator(insertstart); operationchooser = createOperationGenerator(p); - transactioninsertkeysequence = new AcknowledgedCounterGenerator(recordcount); + transactioninsertkeysequence = new AcknowledgedCounterGenerator(insertstart); if (requestdistrib.compareTo("uniform") == 0) { keychooser = new UniformLongGenerator(insertstart, insertstart + insertcount - 1); } else if (requestdistrib.compareTo("exponential") == 0) { @@ -500,7 +511,7 @@ public void init(Properties p) throws WorkloadException { ExponentialGenerator.EXPONENTIAL_FRAC_DEFAULT)); keychooser = new ExponentialGenerator(percentile, recordcount * frac); } else if (requestdistrib.compareTo("sequential") == 0) { - keychooser = new SequentialGenerator(insertstart, insertstart + insertcount - 1); + keychooser = new SequentialGenerator(insertstart, insertstart + recordcount - 1); } else if (requestdistrib.compareTo("zipfian") == 0) { // it does this by generating a random "next key" in part by taking the modulus over the // number of keys. @@ -669,6 +680,9 @@ public boolean doTransaction(DB db, Object threadstate) { case "INSERT": doTransactionInsert(db); break; + case "DELETE": + doTransactionDelete(db); + break; case "SCAN": doTransactionScan(db); break; @@ -711,6 +725,8 @@ long nextKeynum() { do { keynum = transactioninsertkeysequence.lastValue() - keychooser.nextValue().intValue(); } while (keynum < 0); + } else if (keychooser instanceof SequentialGenerator) { + keynum = keychooser.nextValue().intValue(); } else { do { keynum = keychooser.nextValue().intValue(); @@ -720,7 +736,6 @@ long nextKeynum() { } public void doTransactionRead(DB db) { - // choose a random key long keynum = nextKeynum(); String keyname = CoreWorkload.buildKeyName(keynum, zeropadding, orderedinserts); @@ -747,7 +762,6 @@ public void doTransactionRead(DB db) { } public void doTransactionReadModifyWrite(DB db) { - // choose a random key long keynum = nextKeynum(); String keyname = CoreWorkload.buildKeyName(keynum, zeropadding, orderedinserts); @@ -794,7 +808,6 @@ public void doTransactionReadModifyWrite(DB db) { } public void doTransactionScan(DB db) { - // choose a random key long keynum = nextKeynum(); String startkeyname = CoreWorkload.buildKeyName(keynum, zeropadding, orderedinserts); @@ -816,7 +829,6 @@ public void doTransactionScan(DB db) { } public void doTransactionUpdate(DB db) { - // choose a random key long keynum = nextKeynum(); String keyname = CoreWorkload.buildKeyName(keynum, zeropadding, orderedinserts); @@ -848,11 +860,19 @@ public void doTransactionInsert(DB db) { } } + public void doTransactionDelete(DB db) { + long keynum = nextKeynum(); + + String keyname = CoreWorkload.buildKeyName(keynum, zeropadding, orderedinserts); + + db.delete(table, keyname); + } + /** * Creates a weighted discrete values with database operations for a workload to perform. * Weights/proportions are read from the properties list and defaults are used * when values are not configured. - * Current operations are "READ", "UPDATE", "INSERT", "SCAN" and "READMODIFYWRITE". + * Current operations are "READ", "UPDATE", "INSERT", "SCAN", "READMODIFYWRITE", "DELETE". * * @param p The properties list to pull weights from. * @return A generator that can be used to determine the next operation to perform. @@ -868,6 +888,8 @@ protected static DiscreteGenerator createOperationGenerator(final Properties p) p.getProperty(UPDATE_PROPORTION_PROPERTY, UPDATE_PROPORTION_PROPERTY_DEFAULT)); final double insertproportion = Double.parseDouble( p.getProperty(INSERT_PROPORTION_PROPERTY, INSERT_PROPORTION_PROPERTY_DEFAULT)); + final double deleteproportion = Double.parseDouble( + p.getProperty(DELETE_PROPORTION_PROPERTY, DELETE_PROPORTION_PROPERTY_DEFAULT)); final double scanproportion = Double.parseDouble( p.getProperty(SCAN_PROPORTION_PROPERTY, SCAN_PROPORTION_PROPERTY_DEFAULT)); final double readmodifywriteproportion = Double.parseDouble(p.getProperty( @@ -886,6 +908,10 @@ protected static DiscreteGenerator createOperationGenerator(final Properties p) operationchooser.addValue(insertproportion, "INSERT"); } + if (deleteproportion > 0) { + operationchooser.addValue(deleteproportion, "DELETE"); + } + if (scanproportion > 0) { operationchooser.addValue(scanproportion, "SCAN"); } diff --git a/workloads/workloadg b/workloads/workloadg new file mode 100644 index 0000000000..bd136b7eba --- /dev/null +++ b/workloads/workloadg @@ -0,0 +1,40 @@ +# Copyright (c) 2010 Yahoo! Inc. 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 +# may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. See accompanying +# LICENSE file. + + +# Yahoo! Cloud System Benchmark +# Workload A: Update heavy workload +# Application example: Session store recording recent actions +# +# Read/update ratio: 50/50 +# Default data size: 1 KB records (10 fields, 100 bytes each, plus key) +# Request distribution: zipfian + +recordcount=1000 +operationcount=1000 +workload=site.ycsb.workloads.CoreWorkload + +readallfields=true +insertorder=ordered +insertstart=0 + +readproportion=0 +updateproportion=0 +scanproportion=0 +insertproportion=0.8 +deleteproportion=0.2 + +requestdistribution=sequential +