Skip to content

Commit

Permalink
Configuration improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Bailey committed Oct 6, 2010
1 parent 0386f53 commit 3317313
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/com/yahoo/ycsb/CommandLine.java
Expand Up @@ -46,7 +46,7 @@ public static void usageMessage()
System.out.println(" -P filename: Specify a property file");
System.out.println(" -p name=value: Specify a property value");
System.out.println(" -db classname: Use a specified DB class (can also set the \"db\" property)");
System.out.println(" -table tablename: Use the table name instead of the default \""+CoreWorkload.TABLENAME+"\"");
System.out.println(" -table tablename: Use the table name instead of the default \""+CoreWorkload.TABLENAME_PROPERTY_DEFAULT+"\"");
System.out.println();
}

Expand All @@ -68,7 +68,7 @@ public static void main(String[] args)

Properties props=new Properties();
Properties fileprops=new Properties();
String table=CoreWorkload.TABLENAME;
String table=CoreWorkload.TABLENAME_PROPERTY_DEFAULT;

while ( (argindex<args.length) && (args[argindex].startsWith("-")) )
{
Expand Down
30 changes: 20 additions & 10 deletions src/com/yahoo/ycsb/workloads/CoreWorkload.java
Expand Up @@ -61,7 +61,15 @@ public class CoreWorkload extends Workload
/**
* The name of the database table to run queries against.
*/
public static final String TABLENAME="usertable";
public static final String TABLENAME_PROPERTY="table";

/**
* The default name of the database table to run queries against.
*/
public static final String TABLENAME_PROPERTY_DEFAULT="usertable";

public static String table;


/**
* The name of the property for the number of fields in a record.
Expand Down Expand Up @@ -224,6 +232,7 @@ public class CoreWorkload extends Workload
*/
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));
fieldlength=Integer.parseInt(p.getProperty(FIELD_LENGTH_PROPERTY,FIELD_LENGTH_PROPERTY_DEFAULT));
double readproportion=Double.parseDouble(p.getProperty(READ_PROPORTION_PROPERTY,READ_PROPORTION_PROPERTY_DEFAULT));
Expand Down Expand Up @@ -342,9 +351,10 @@ public boolean doInsert(DB db, Object threadstate)
String data=Utils.ASCIIString(fieldlength);
values.put(fieldkey,data);
}
db.insert(TABLENAME,dbkey,values);

return true;
if (db.insert(table,dbkey,values) == 0)
return true;
else
return false;
}

/**
Expand Down Expand Up @@ -408,7 +418,7 @@ public void doTransactionRead(DB db)
fields.add(fieldname);
}

db.read(TABLENAME,keyname,fields,new HashMap<String,String>());
db.read(table,keyname,fields,new HashMap<String,String>());
}

public void doTransactionReadModifyWrite(DB db)
Expand Down Expand Up @@ -462,9 +472,9 @@ public void doTransactionReadModifyWrite(DB db)

long st=System.currentTimeMillis();

db.read(TABLENAME,keyname,fields,new HashMap<String,String>());
db.read(table,keyname,fields,new HashMap<String,String>());

db.update(TABLENAME,keyname,values);
db.update(table,keyname,values);

long en=System.currentTimeMillis();

Expand Down Expand Up @@ -501,7 +511,7 @@ public void doTransactionScan(DB db)
fields.add(fieldname);
}

db.scan(TABLENAME,startkeyname,len,fields,new Vector<HashMap<String,String>>());
db.scan(table,startkeyname,len,fields,new Vector<HashMap<String,String>>());
}

public void doTransactionUpdate(DB db)
Expand Down Expand Up @@ -540,7 +550,7 @@ public void doTransactionUpdate(DB db)
values.put(fieldname,data);
}

db.update(TABLENAME,keyname,values);
db.update(table,keyname,values);
}

public void doTransactionInsert(DB db)
Expand All @@ -560,6 +570,6 @@ public void doTransactionInsert(DB db)
String data=Utils.ASCIIString(fieldlength);
values.put(fieldkey,data);
}
db.insert(TABLENAME,dbkey,values);
db.insert(table,dbkey,values);
}
}

0 comments on commit 3317313

Please sign in to comment.