com.yahoo.ycsb.database
Class DB

java.lang.Object
  extended by com.yahoo.ycsb.DataStore
      extended by com.yahoo.ycsb.database.DB
Direct Known Subclasses:
BasicDB, DBWrapper

public abstract class DB
extends DataStore

A layer for accessing a database to be benchmarked. Each thread in the client will be given its own instance of whatever DB class is to be used in the test. This class should be constructed using a no-argument constructor, so we can load it dynamically. Any argument-based initialization should be done by init(). Note that YCSB does not make any use of the return codes returned by this class. Instead, it keeps a count of the return values and presents them to the user. The semantics of methods such as insert, update and delete vary from database to database. In particular, operations may or may not be durable once these methods commit, and some systems may return 'success' regardless of whether or not a tuple with a matching key existed before the call. Rather than dictate the exact semantics of these methods, we recommend you either implement them to match the database's default semantics, or the semantics of your target application. For the sake of comparison between experiments we also recommend you explain the semantics you chose when presenting performance results.


Constructor Summary
DB()
           
 
Method Summary
abstract  int delete(java.lang.String table, java.lang.String key)
          Delete a record from the database.
abstract  int insert(java.lang.String table, java.lang.String key, java.util.HashMap<java.lang.String,java.lang.String> values)
          Insert a record in the database.
abstract  int read(java.lang.String table, java.lang.String key, java.util.Set<java.lang.String> fields, java.util.HashMap<java.lang.String,java.lang.String> result)
          Read a record from the database.
abstract  int scan(java.lang.String table, java.lang.String startkey, int recordcount, java.util.Set<java.lang.String> fields, java.util.Vector<java.util.HashMap<java.lang.String,java.lang.String>> result)
          Perform a range scan for a set of records in the database.
abstract  int update(java.lang.String table, java.lang.String key, java.util.HashMap<java.lang.String,java.lang.String> values)
          Update a record in the database.
 
Methods inherited from class com.yahoo.ycsb.DataStore
cleanup, getProperties, init, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DB

public DB()
Method Detail

read

public abstract int read(java.lang.String table,
                         java.lang.String key,
                         java.util.Set<java.lang.String> fields,
                         java.util.HashMap<java.lang.String,java.lang.String> result)
Read a record from the database. Each field/value pair from the result will be stored in a HashMap.

Parameters:
table - The name of the table
key - The record key of the record to read.
fields - The list of fields to read, or null for all of them
result - A HashMap of field/value pairs for the result
Returns:
Zero on success, a non-zero error code on error or "not found".

scan

public abstract int scan(java.lang.String table,
                         java.lang.String startkey,
                         int recordcount,
                         java.util.Set<java.lang.String> fields,
                         java.util.Vector<java.util.HashMap<java.lang.String,java.lang.String>> result)
Perform a range scan for a set of records in the database. Each field/value pair from the result will be stored in a HashMap.

Parameters:
table - The name of the table
startkey - The record key of the first record to read.
recordcount - The number of records to read
fields - The list of fields to read, or null for all of them
result - A Vector of HashMaps, where each HashMap is a set field/value pairs for one record
Returns:
Zero on success, a non-zero error code on error. See this class's description for a discussion of error codes.

update

public abstract int update(java.lang.String table,
                           java.lang.String key,
                           java.util.HashMap<java.lang.String,java.lang.String> values)
Update a record in the database. Any field/value pairs in the specified values HashMap will be written into the record with the specified record key, overwriting any existing values with the same field name.

Parameters:
table - The name of the table
key - The record key of the record to write.
values - A HashMap of field/value pairs to update in the record
Returns:
Zero on success, a non-zero error code on error. See this class's description for a discussion of error codes.

insert

public abstract int insert(java.lang.String table,
                           java.lang.String key,
                           java.util.HashMap<java.lang.String,java.lang.String> values)
Insert a record in the database. Any field/value pairs in the specified values HashMap will be written into the record with the specified record key.

Parameters:
table - The name of the table
key - The record key of the record to insert.
values - A HashMap of field/value pairs to insert in the record
Returns:
Zero on success, a non-zero error code on error. See this class's description for a discussion of error codes.

delete

public abstract int delete(java.lang.String table,
                           java.lang.String key)
Delete a record from the database.

Parameters:
table - The name of the table
key - The record key of the record to delete.
Returns:
Zero on success, a non-zero error code on error. See this class's description for a discussion of error codes.