Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions libcassandra/cassandra.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ void Cassandra::insertColumn(const string& key,
Column col;
col.name.assign(column_name);
col.value.assign(value);
col.timestamp= createTimestamp();
col.__isset.value = true;
col.timestamp = createTimestamp();
col.__isset.timestamp = true;
if (ttl)
{
col.ttl=ttl;
Expand Down Expand Up @@ -343,6 +345,9 @@ vector<Column> Cassandra::getSliceNames(const string& key,
return result;
}

void Cassandra::truncate(const string& cf_name) {
thrift_client->truncate(cf_name);
}

vector<Column> Cassandra::getSliceNames(const string& key,
const ColumnParent& col_parent,
Expand Down Expand Up @@ -534,7 +539,6 @@ vector<KeyspaceDefinition> Cassandra::getKeyspaces()
KeyspaceDefinition entry(thrift_entry.name,
thrift_entry.strategy_class,
thrift_entry.strategy_options,
thrift_entry.replication_factor,
thrift_entry.cf_defs);
key_spaces.push_back(entry);
}
Expand Down
6 changes: 6 additions & 0 deletions libcassandra/cassandra.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@ class Cassandra
const std::string& column_family,
const std::string& super_column_name);

/**
* Truncate a column family
* @param[in] cf_name Column family name
*/
void truncate(const std::string& cf_name);

std::vector<org::apache::cassandra::Column> getSliceNames(const std::string& key,
const org::apache::cassandra::ColumnParent& col_parent,
org::apache::cassandra::SlicePredicate& pred,
Expand Down
10 changes: 6 additions & 4 deletions libcassandra/cassandra_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <transport/TSocket.h>
#include <transport/TTransportUtils.h>

#include <boost/shared_ptr.hpp>

#include "libgenthrift/Cassandra.h"

#include "libcassandra/cassandra.h"
Expand Down Expand Up @@ -63,18 +65,18 @@ CassandraFactory::CassandraFactory(const string& in_host, int in_port)
CassandraFactory::~CassandraFactory() {}


tr1::shared_ptr<Cassandra> CassandraFactory::create()
boost::shared_ptr<Cassandra> CassandraFactory::create()
{
CassandraClient *thrift_client= createThriftClient(host, port);
tr1::shared_ptr<Cassandra> ret(new Cassandra(thrift_client, host, port));
boost::shared_ptr<Cassandra> ret(new Cassandra(thrift_client, host, port));
return ret;
}


tr1::shared_ptr<Cassandra> CassandraFactory::create(const string& keyspace)
boost::shared_ptr<Cassandra> CassandraFactory::create(const string& keyspace)
{
CassandraClient *thrift_client= createThriftClient(host, port);
tr1::shared_ptr<Cassandra> ret(new Cassandra(thrift_client, host, port, keyspace));
boost::shared_ptr<Cassandra> ret(new Cassandra(thrift_client, host, port, keyspace));
return ret;
}

Expand Down
7 changes: 4 additions & 3 deletions libcassandra/cassandra_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

#include <string>
#include <vector>
#include <tr1/memory>

#include <boost/shared_ptr.hpp>

namespace org
{
Expand Down Expand Up @@ -44,13 +45,13 @@ class CassandraFactory
/**
* @return a shared ptr which points to a Cassandra client
*/
std::tr1::shared_ptr<Cassandra> create();
boost::shared_ptr<Cassandra> create();

/**
* @param[in] keyspace name of keyspace to associate this instance with
* @return a shared ptr which points to a Cassandra client
*/
std::tr1::shared_ptr<Cassandra> create(const std::string& keyspace);
boost::shared_ptr<Cassandra> create(const std::string& keyspace);

/**
* @return port number associated with cassandra instances created
Expand Down
17 changes: 1 addition & 16 deletions libcassandra/keyspace_definition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,18 @@ KeyspaceDefinition::KeyspaceDefinition()
name(),
strategy_class("org.apache.cassandra.locator.SimpleStrategy"),
strategy_options(),
replication_factor(1),
col_family_defs()
{}


KeyspaceDefinition::KeyspaceDefinition(const string& in_name,
const string& in_strategy_class,
const map<string, string>& in_strategy_options,
const int32_t in_replication_factor,
vector<CfDef>& in_cf_defs)
:
name(in_name),
strategy_class(in_strategy_class),
strategy_options(in_strategy_options),
replication_factor(in_replication_factor),
col_family_defs()
{
for (vector<CfDef>::iterator it= in_cf_defs.begin();
Expand Down Expand Up @@ -103,19 +100,7 @@ map<string, string> KeyspaceDefinition::getStrategyOptions() const

void KeyspaceDefinition::setStrategyOptions(const map<string, string>& opts)
{
(void) opts;
}


int32_t KeyspaceDefinition::getReplicationFactor() const
{
return replication_factor;
}


void KeyspaceDefinition::setReplicationFactor(int32_t rep_factor)
{
replication_factor= rep_factor;
strategy_options.insert(opts.begin(), opts.end());
}


Expand Down
8 changes: 0 additions & 8 deletions libcassandra/keyspace_definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class KeyspaceDefinition
KeyspaceDefinition(const std::string& in_name,
const std::string& in_strategy_class,
const std::map<std::string, std::string>& in_strategy_options,
const int32_t in_replication_factor,
std::vector<org::apache::cassandra::CfDef>& in_cf_defs);
~KeyspaceDefinition() {}

Expand All @@ -57,13 +56,6 @@ class KeyspaceDefinition

void setStrategyOptions(const std::map<std::string, std::string>& opts);

/**
* @return replication factor for this keyspace
*/
int32_t getReplicationFactor() const;

void setReplicationFactor(int32_t rep_factor);

/**
* @return the column families in this keyspace
*/
Expand Down
7 changes: 6 additions & 1 deletion libcassandra/util_functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ KsDef createKsDefObject(const KeyspaceDefinition& ks_def)
KsDef thrift_ks_def;
thrift_ks_def.name.assign(ks_def.getName());
thrift_ks_def.strategy_class.assign(ks_def.getStrategyClass());
if (!ks_def.getStrategyOptions().empty()) {
thrift_ks_def.__isset.strategy_options = true;
const map<string, string>& strategy_options = ks_def.getStrategyOptions();
thrift_ks_def.strategy_options.insert(strategy_options.begin(),
strategy_options.end());
}
vector<ColumnFamilyDefinition> cf_defs= ks_def.getColumnFamilies();
for (vector<ColumnFamilyDefinition>::iterator it= cf_defs.begin();
it != cf_defs.end();
Expand All @@ -79,7 +85,6 @@ KsDef createKsDefObject(const KeyspaceDefinition& ks_def)
CfDef entry= createCfDefObject(*it);
thrift_ks_def.cf_defs.push_back(entry);
}
thrift_ks_def.replication_factor= ks_def.getReplicationFactor();
return thrift_ks_def;
}

Expand Down
Loading