Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Configuration improvements.

  • Loading branch information...
commit 3317313de71d433ec80fb5206d14d7af4058a1b2 1 parent 0386f53
Nick Bailey authored
View
4 src/com/yahoo/ycsb/CommandLine.java
@@ -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();
}
@@ -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("-")) )
{
View
30 src/com/yahoo/ycsb/workloads/CoreWorkload.java
@@ -61,7 +61,15 @@
/**
* 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.
@@ -224,6 +232,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));
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));
@@ -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;
}
/**
@@ -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)
@@ -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();
@@ -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)
@@ -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)
@@ -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);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.