Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fieldnameprefix property #117

Merged
merged 3 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions core/src/main/java/com/yahoo/ycsb/workloads/CoreWorkload.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
* <LI><b>maxscanlength</b>: for scans, what is the maximum number of records to scan (default: 1000)
* <LI><b>scanlengthdistribution</b>: for scans, what distribution should be used to choose the number of records to scan, for each scan, between 1 and maxscanlength (default: uniform)
* <LI><b>insertorder</b>: should records be inserted in order by key ("ordered"), or in hashed order ("hashed") (default: hashed)
* <LI><b>fieldnameprefix</b>: what should be a prefix for field names, the shorter may decrease the required storage size (default: "field")
* </ul>
*/
public class CoreWorkload extends Workload
Expand Down Expand Up @@ -252,11 +253,22 @@ public class CoreWorkload extends Workload
* Percentage operations that access the hot set.
*/
public static final String HOTSPOT_OPN_FRACTION = "hotspotopnfraction";

/**
* Default value of the percentage operations accessing the hot set.
*/
public static final String HOTSPOT_OPN_FRACTION_DEFAULT = "0.8";

/**
* Field name prefix.
*/
public static final String FIELD_NAME_PREFIX = "fieldnameprefix";

/**
* Default value of the field name prefix.
*/
public static final String FIELD_NAME_PREFIX_DEFAULT = "field";


IntegerGenerator keysequence;

Expand All @@ -273,6 +285,8 @@ public class CoreWorkload extends Workload
boolean orderedinserts;

int recordcount;

String fieldnameprefix;

protected static IntegerGenerator getFieldLengthGenerator(Properties p) throws WorkloadException{
IntegerGenerator fieldlengthgenerator;
Expand Down Expand Up @@ -307,6 +321,8 @@ public void init(Properties p) throws WorkloadException

fieldcount=Integer.parseInt(p.getProperty(FIELD_COUNT_PROPERTY,FIELD_COUNT_PROPERTY_DEFAULT));
fieldlengthgenerator = CoreWorkload.getFieldLengthGenerator(p);

fieldnameprefix = p.getProperty(FIELD_NAME_PREFIX, FIELD_NAME_PREFIX_DEFAULT);

double readproportion=Double.parseDouble(p.getProperty(READ_PROPORTION_PROPERTY,READ_PROPORTION_PROPERTY_DEFAULT));
double updateproportion=Double.parseDouble(p.getProperty(UPDATE_PROPORTION_PROPERTY,UPDATE_PROPORTION_PROPERTY_DEFAULT));
Expand Down Expand Up @@ -432,16 +448,16 @@ HashMap<String, ByteIterator> buildValues() {

for (int i=0; i<fieldcount; i++)
{
String fieldkey="field"+i;
ByteIterator data= new RandomByteIterator(fieldlengthgenerator.nextInt());
String fieldkey = fieldnameprefix + i;
ByteIterator data = new RandomByteIterator(fieldlengthgenerator.nextInt());
values.put(fieldkey,data);
}
return values;
}
HashMap<String, ByteIterator> buildUpdate() {
//update a random field
HashMap<String, ByteIterator> values=new HashMap<String,ByteIterator>();
String fieldname="field"+fieldchooser.nextString();
HashMap<String, ByteIterator> values = new HashMap<String,ByteIterator>();
String fieldname = fieldnameprefix + fieldchooser.nextString();
ByteIterator data = new RandomByteIterator(fieldlengthgenerator.nextInt());
values.put(fieldname,data);
return values;
Expand Down Expand Up @@ -528,9 +544,9 @@ public void doTransactionRead(DB db)
if (!readallfields)
{
//read a random field
String fieldname="field"+fieldchooser.nextString();
String fieldname = fieldnameprefix + fieldchooser.nextString();

fields=new HashSet<String>();
fields = new HashSet<String>();
fields.add(fieldname);
}

Expand All @@ -549,9 +565,9 @@ public void doTransactionReadModifyWrite(DB db)
if (!readallfields)
{
//read a random field
String fieldname="field"+fieldchooser.nextString();
String fieldname = fieldnameprefix + fieldchooser.nextString();

fields=new HashSet<String>();
fields = new HashSet<String>();
fields.add(fieldname);
}

Expand Down Expand Up @@ -596,7 +612,7 @@ public void doTransactionScan(DB db)
if (!readallfields)
{
//read a random field
String fieldname="field"+fieldchooser.nextString();
String fieldname = fieldnameprefix + fieldchooser.nextString();

fields=new HashSet<String>();
fields.add(fieldname);
Expand Down
5 changes: 3 additions & 2 deletions doc/coreproperties.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<HTML>
<HTML xmlns="http://www.w3.org/1999/html">
<HEAD>
<TITLE>YCSB - Core workload package properties</TITLE>
</HEAD>
Expand All @@ -22,7 +22,8 @@ <H2>Core workload package properties</h2>
<LI><b>requestdistribution</b>: what distribution should be used to select the records to operate on - uniform, zipfian or latest (default: uniform)
<LI><b>maxscanlength</b>: for scans, what is the maximum number of records to scan (default: 1000)
<LI><b>scanlengthdistribution</b>: for scans, what distribution should be used to choose the number of records to scan, for each scan, between 1 and maxscanlength (default: uniform)
<LI><b>insertorder</b>: should records be inserted in order by key ("ordered"), or in hashed order ("hashed") (default: hashed)
<LI><b>insertorder</b>: should records be inserted in order by key ("ordered"), or in hashed order ("hashed") (default: hashed)
<LI><b>fieldnameprefix</b>: string prefix for the field name (default: “field”)
</UL>
<HR>
YCSB - Yahoo! Research - Contact [email protected].
Expand Down
2 changes: 1 addition & 1 deletion hbase/src/main/java/com/yahoo/ycsb/db/HBaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public void run()
rescode=cli.read("table1", key, s, result);
*/
HashSet<String> scanFields = new HashSet<String>();
scanFields.add("field1");
scanFields.add("field1"); //TODO: remove hardcoded field prefix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gelin would it be possible to use the dynamic prefix field you added in the PR?

scanFields.add("field3");
Vector<HashMap<String,ByteIterator>> scanResults = new Vector<HashMap<String,ByteIterator>>();
rescode = cli.scan("table1","user2",20,null,scanResults);
Expand Down