Permalink
Browse files

Configurable column families

  • Loading branch information...
1 parent e23b9ae commit 6675a2a83e6c669e3d46fa05c596961d12432ad5 @stuhood stuhood committed Jan 18, 2011
Showing with 9 additions and 4 deletions.
  1. +9 −4 db/cassandra-0.6/src/com/yahoo/ycsb/db/CassandraClient6.java
@@ -44,9 +44,13 @@
public static final int Ok=0;
public static final int Error=-1;
+ public String ColumnFamily;
public int ConnectionRetries;
public int OperationRetries;
+ public static final String COLUMN_FAMILY_PROPERTY="cassandra.columnfamily";
+ public static final String COLUMN_FAMILY_PROPERTY_DEFAULT="data";
+
public static final String CONNECTION_RETRY_PROPERTY="cassandra.connectionretries";
public static final String CONNECTION_RETRY_PROPERTY_DEFAULT="300";
@@ -71,6 +75,7 @@ public void init() throws DBException
throw new DBException("Required property \"hosts\" missing for CassandraClient");
}
+ ColumnFamily=getProperties().getProperty(COLUMN_FAMILY_PROPERTY,COLUMN_FAMILY_PROPERTY_DEFAULT);
ConnectionRetries=Integer.parseInt(getProperties().getProperty(CONNECTION_RETRY_PROPERTY,CONNECTION_RETRY_PROPERTY_DEFAULT));
OperationRetries=Integer.parseInt(getProperties().getProperty(OPERATION_RETRY_PROPERTY,OPERATION_RETRY_PROPERTY_DEFAULT));
@@ -166,7 +171,7 @@ public int read(String table, String key, Set<String> fields, HashMap<String,Str
predicate.setColumn_names(fieldlist);
}
- ColumnParent parent = new ColumnParent("data");
+ ColumnParent parent = new ColumnParent(ColumnFamily);
List<ColumnOrSuperColumn> results = client.get_slice(table, key, parent, predicate, ConsistencyLevel.ONE);
if (_debug)
@@ -250,7 +255,7 @@ public int scan(String table, String startkey, int recordcount, Set<String> fiel
predicate = new SlicePredicate();
predicate.setColumn_names(fieldlist);
}
- ColumnParent parent = new ColumnParent("data");
+ ColumnParent parent = new ColumnParent(ColumnFamily);
List<KeySlice> results = client.get_range_slice(table,parent,predicate,startkey,"",recordcount,ConsistencyLevel.ONE);
@@ -334,7 +339,7 @@ public int insert(String table, String key, HashMap<String,String> values)
HashMap<String, List<ColumnOrSuperColumn>> batch_mutation=new HashMap<String, List<ColumnOrSuperColumn>>();
Vector<ColumnOrSuperColumn> v=new Vector<ColumnOrSuperColumn>();
- batch_mutation.put("data",v);
+ batch_mutation.put(ColumnFamily,v);
try
{
@@ -395,7 +400,7 @@ public int delete(String table, String key)
{
try
{
- client.remove(table,key,new ColumnPath("data"),System.currentTimeMillis(),ConsistencyLevel.ONE);
+ client.remove(table,key,new ColumnPath(ColumnFamily),System.currentTimeMillis(),ConsistencyLevel.ONE);
if (_debug)
{

0 comments on commit 6675a2a

Please sign in to comment.