Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make 0.8 client not set_keyspace on every call

  • Loading branch information...
commit c2b92249e511cf565b6a634ca6ce9844e94898aa 1 parent 7896322
Chris Goffinet authored
Showing with 6 additions and 39 deletions.
  1. +6 −39 db/cassandra-0.8/src/com/yahoo/ycsb/db/CassandraClient8.java
View
45 db/cassandra-0.8/src/com/yahoo/ycsb/db/CassandraClient8.java
@@ -79,6 +79,10 @@
public static final String CONSISTENCY_WRITE_PROPERTY = "cassandra.consistency_write";
public static final String CONSISTENCY_WRITE_PROPERTY_DEFAULT = "1"; // ONE
+ public static final String TABLENAME_PROPERTY = "table";
+ public static final String TABLENAME_PROPERTY_DEFAULT = "usertable";
+ public static String table;
+
TTransport tr;
Cassandra.Client client;
@@ -96,6 +100,7 @@ public void init() throws DBException
throw new DBException("Required property \"hosts\" missing for CassandraClient");
}
+ table = getProperties().getProperty(TABLENAME_PROPERTY,TABLENAME_PROPERTY_DEFAULT);
column_family = getProperties().getProperty(COLUMN_FAMILY_PROPERTY, COLUMN_FAMILY_PROPERTY_DEFAULT);
consistency_read = ConsistencyLevel.findByValue(Integer.parseInt(getProperties().getProperty(CONSISTENCY_READ_PROPERTY, CONSISTENCY_READ_PROPERTY_DEFAULT)));
consistency_write = ConsistencyLevel.findByValue(Integer.parseInt(getProperties().getProperty(CONSISTENCY_WRITE_PROPERTY, CONSISTENCY_WRITE_PROPERTY_DEFAULT)));
@@ -124,6 +129,7 @@ public void init() throws DBException
try
{
tr.open();
+ client.set_keyspace(table);
connectexception = null;
break;
} catch (Exception e)
@@ -229,15 +235,6 @@ public static String tos(ByteBuffer buffer)
public int read(String table, String key, Set<String> fields, HashMap<String, String> result)
{
Exception errorexception = null;
- try
- {
- client.set_keyspace(table);
- } catch (Exception e)
- {
- e.printStackTrace();
- e.printStackTrace(System.out);
- return Error;
- }
for (int i = 0; i < OperationRetries; i++)
{
@@ -348,16 +345,6 @@ public int scan(String table, String startkey, int recordcount, Set<String> fiel
{
Exception errorexception = null;
- try
- {
- client.set_keyspace(table);
- } catch (Exception e)
- {
- e.printStackTrace();
- e.printStackTrace(System.out);
- return Error;
- }
-
for (int i = 0; i < OperationRetries; i++)
{
@@ -467,16 +454,6 @@ public int insert(String table, String key, HashMap<String, String> values)
{
Exception errorexception = null;
- try
- {
- client.set_keyspace(table);
- } catch (Exception e)
- {
- e.printStackTrace();
- e.printStackTrace(System.out);
- return Error;
- }
-
for (int i = 0; i < OperationRetries; i++)
{
// insert data
@@ -562,16 +539,6 @@ public int delete(String table, String key)
{
Exception errorexception = null;
- try
- {
- client.set_keyspace(table);
- } catch (Exception e)
- {
- e.printStackTrace();
- e.printStackTrace(System.out);
- return Error;
- }
-
for (int i = 0; i < OperationRetries; i++)
{
try
Please sign in to comment.
Something went wrong with that request. Please try again.