Code Monkey home page Code Monkey logo

libcassandra's Introduction

== libcassandra

A C++ wrapper library for the interface to cassandra generated by thrift. This library is based on
the Java client hector.

The master branch will follow along with Cassandra trunk. Branches corresponding to stable releases
of Cassandra will be available. Downloads of these branches are also provided.

The current master and 0.7.0 branches will work with Apache Cassandra 0.7.x. 

== Install

$ ./config/autorun.sh
$ ./configure
$ make 
$ make install

== Running unit tests

If Google's C++ unit test framework, gtest, is installed on your machine, the unit tests can be run.

$ make check

The unit tests require a cassandra server with the default out of the box storage-conf.xml file to be running.

== Compiling apps with libcassandra

$ g++ file.cc -lcassandra -lthrift -I/usr/local/include/thfit

Obviously, you should modify the line for your include to be where your thrift headers are
installed.

== Copyright

Copyright (c) 2010 Padraig O'Sullivan. See COPYING for details.

libcassandra's People

Contributors

maxcom avatar posulliv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

libcassandra's Issues

surprised by the signature for Keyspace::insertSuperColumn()...

would've thought:

  • you'd accept a super column name somewhere
  • and then either a column name or a map of column names to values

haven't tried calling this function yet (just getting started here), but was trying to figure out how everything worked, so if it does work, i'll still want to know the answer to above. ;)

/**
* Insert a super column
*
* @param[in] key the column key
* @param[in] column_family the column family
* @param[in] column_name the column name
* @param[in] value the column value
*/
void insertSuperColumn(const std::string &key,
const std::string &column_family,
const std::string &column_name,
const std::string &value);

thanks,
bp

Build broken?

I am trying to build the libraries on Centos5.4.

Configuration summary for libcassandra version 0.1

  • Installation prefix: /usr/local
  • System type: pc-linux-gnu
  • Host CPU: i686
  • C Compiler: gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
  • C++ Compiler: g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
  • Assertions enabled: yes
  • Debug enabled: no
  • Warnings as failure: yes
  • C++ cstdint location: <stdint.h>
  • C++ hash_map location: <ext/hash_map>
  • C++ hash namespace: __gnu_cxx
  • C++ shared_ptr namespace:

When trying to make, I get the error

In file included from /usr/local/include/thrift/Thrift.h:40,
from /usr/local/include/thrift/transport/TTransport.h:23,
from /usr/local/include/thrift/protocol/TProtocol.h:23,
from /usr/local/include/thrift/TProcessor.h:24,
from libgenthrift/Cassandra.h:9,
from libgenthrift/Cassandra.cpp:6:
/usr/local/include/thrift/TLogging.h:69:33: error: anonymous variadic macros were introduced in C99
/usr/local/include/thrift/TLogging.h:91:35: error: anonymous variadic macros were introduced in C99
/usr/local/include/thrift/TLogging.h:102:40: error: anonymous variadic macros were introduced in C99
/usr/local/include/thrift/TLogging.h:113:31: error: anonymous variadic macros were introduced in C99
/usr/local/include/thrift/TLogging.h:130:37: error: anonymous variadic macros were introduced in C99
/usr/local/include/thrift/TLogging.h:148:36: error: anonymous variadic macros were introduced in C99

I am using thrift-0.3.0

Compilation errors.

I am trying to compile libcassandra and I cannot get beyond this error. Something wrong with the libtool?

Below is the command output for ./config/autorun.sh

config/autorun.sh: running /usr/bin/libtoolize --automake --copy --force' config/autorun.sh: running/usr/bin/aclocal-1.9 -I m4'
config/autorun.sh: running /usr/bin/autoheader' config/autorun.sh: running/usr/bin/automake-1.9 --add-missing --copy --force'

config/autorun.sh: running `/usr/bin/autoconf'

Configured with the following tools:

  • libtoolize (GNU libtool) 1.5.22
  • aclocal (GNU automake) 1.9.6
  • autoheader (GNU Autoconf) 2.59
  • automake (GNU automake) 1.9.6

* autoconf (GNU Autoconf) 2.59

then I executed ./configure
which I think went alright (not pasting output to save space, can paste it if it is needed.)

-- Then I tried running make this is what comes out.

make all-recursive
make[1]: Entering directory /root/Cass/libcass' make[2]: Entering directory/root/Cass/libcass'
if /bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -ggdb3 -I/root/boost_1_47_0 -I/include/thrift -pipe -std=gnu++98 -O3 -Werror -pedantic -Wall -Wundef -Wshadow -fdiagnostics-show-option -Wformat -fno-strict-aliasing -Wno-strict-aliasing -Wextra -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long -Wno-redundant-decls -MT libgenthrift/libgenthrift_libgenthrift_la-cassandra_constants.lo -MD -MP -MF "libgenthrift/.deps/libgenthrift_libgenthrift_la-cassandra_constants.Tpo" -c -o libgenthrift/libgenthrift_libgenthrift_la-cassandra_constants.lo test -f 'libgenthrift/cassandra_constants.cpp' || echo './'libgenthrift/cassandra_constants.cpp;
then mv -f "libgenthrift/.deps/libgenthrift_libgenthrift_la-cassandra_constants.Tpo" "libgenthrift/.deps/libgenthrift_libgenthrift_la-cassandra_constants.Plo"; else rm -f "libgenthrift/.deps/libgenthrift_libgenthrift_la-cassandra_constants.Tpo"; exit 1; fi
./libtool: line 807: X--tag=CXX: command not found
./libtool: line 840: libtool: ignoring unknown tag : command not found
./libtool: line 807: X--mode=compile: command not found
./libtool: line 973: *** Warning: inferring the mode of operation is deprecated.: command not found
./libtool: line 974: *** Future versions of Libtool will require --mode=MODE be specified.: command not found
./libtool: line 1117: Xg++: command not found
./libtool: line 1117: X-DHAVE_CONFIG_H: command not found
./libtool: line 1117: X-I.: command not found
./libtool: line 1117: X-I.: command not found
./libtool: line 1117: X-ggdb3: command not found
./libtool: line 1117: X-I/root/boost_1_47_0: No such file or directory
./libtool: line 1117: X-I/include/thrift: No such file or directory
./libtool: line 1117: X-pipe: command not found
./libtool: line 1117: X-std=gnu++98: command not found
./libtool: line 1117: X-O3: command not found
./libtool: line 1117: X-Werror: command not found
./libtool: line 1117: X-pedantic: command not found
./libtool: line 1117: X-Wall: command not found
./libtool: line 1117: X-Wundef: command not found
./libtool: line 1117: X-Wshadow: command not found
./libtool: line 1117: X-fdiagnostics-show-option: command not found
./libtool: line 1117: X-Wformat: command not found
./libtool: line 1117: X-fno-strict-aliasing: command not found
./libtool: line 1117: X-Wno-strict-aliasing: command not found
./libtool: line 1117: X-Wextra: command not found
./libtool: line 1117: X-Woverloaded-virtual: command not found
./libtool: line 1117: X-Wnon-virtual-dtor: command not found
./libtool: line 1117: X-Wctor-dtor-privacy: command not found
./libtool: line 1117: X-Wno-long-long: command not found
./libtool: line 1117: X-Wno-redundant-decls: command not found
./libtool: line 1117: X-MT: command not found
./libtool: line 1117: Xlibgenthrift/libgenthrift_libgenthrift_la-cassandra_constants.lo: No such file or directory
./libtool: line 1117: X-MD: command not found
./libtool: line 1117: X-MP: command not found
./libtool: line 1117: X-MF: command not found
./libtool: line 1117: Xlibgenthrift/.deps/libgenthrift_libgenthrift_la-cassandra_constants.Tpo: No such file or directory
./libtool: line 1117: X-c: command not found
./libtool: line 1168: Xlibgenthrift/libgenthrift_libgenthrift_la-cassandra_constants.lo: No such file or directory
./libtool: line 1173: libtool: compile: cannot determine name of library object from ': command not found make[2]: *** [libgenthrift/libgenthrift_libgenthrift_la-cassandra_constants.lo] Error 1 make[2]: Leaving directory/root/Cass/libcass'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/Cass/libcass'
make: *** [all] Error 2

I am just toying with this. I am not a big libcassandra dev or something just playing around to get a hang of it.

Did I miss something?

Thanks and Regards,
Atul.

Memory leaks in cassandra.cc

Cassandra creates Keyspace pointers and maintains them in a map. Will need to deallocate those keyspace pointers in dtor of the Cassandra.

Cassandra::~Cassandra()
{
delete thrift_client;
}

BTW, how can I contribute the project?

Build errors with gcc 4.5.2 and thrift 0.6.0

When building libcassandra with gcc 4.5.2 (which comes with Ubuntu 11.04) and libthrift 0.6.0 the following errors occur:

In file included from /tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/Thrift.h:42:0,
             from /tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/transport/TTransport.h:23,
             from /tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/protocol/TProtocol.h:23,
             from /tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/TProcessor.h:24,
             from libgenthrift/Cassandra.h:9,
             from libgenthrift/Cassandra.cpp:6:
/tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/TLogging.h:69:33: error: anonymous variadic macros were introduced in C99
/tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/TLogging.h:91:35: error: anonymous variadic macros were introduced in C99
/tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/TLogging.h:102:40: error: anonymous variadic macros were introduced in C99
/tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/TLogging.h:113:31: error: anonymous variadic macros were introduced in C99
/tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/TLogging.h:130:37: error: anonymous variadic macros were introduced in C99
/tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/TLogging.h:148:36: error: anonymous variadic macros were introduced in C99
/tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/TLogging.h:173:5: error: "T_GLOBAL_DEBUG_VIRTUAL" is not defined
/tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/TLogging.h:183:7: error: "T_GLOBAL_DEBUG_VIRTUAL" is not defined
In file included from /tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/transport/TTransport.h:23:0,
             from /tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/protocol/TProtocol.h:23,
             from /tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/TProcessor.h:24,
             from libgenthrift/Cassandra.h:9,
             from libgenthrift/Cassandra.cpp:6:
/tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/Thrift.h:168:5: error: "T_GLOBAL_DEBUG_VIRTUAL" is not defined
In file included from libgenthrift/Cassandra.cpp:6:0:
/tmp/cassandra/../thrift/linux64/thrift-0.6.0/include/thrift/TProcessor.h:141:16: error: ‘virtual bool apache::thrift::TProcessor::process(boost::shared_ptr<apache::thrift::protocol::TProtocol>, boost::shared_ptr<apache::thrift::protocol::TProtocol>, void*)’ was hidden [-Woverloaded-virtual]
libgenthrift/Cassandra.h:3315:16: error:   by ‘virtual bool org::apache::cassandra::CassandraProcessor::process(boost::shared_ptr<apache::thrift::protocol::TProtocol>, boost::shared_ptr<apache::thrift::protocol::TProtocol>)’ [-Woverloaded-virtual]

As a workaround to avoid these errors I set CXXFLAGS to run ./configure as follows:

env CXXFLAGS="-DT_GLOBAL_DEBUG_VIRTUAL=0 -Wno-variadic-macros -Wno-overloaded-virtual" ./configure ... 

But this is just a dangerous hack that ignores compile time warnings. I'm not sure what the right way to handle these is.

Unable to use TimeUUID as Column Name

I haven't been able to use a TimeUUID as a column name because TimeUUID's are supposed to be exactly 16 bytes. I've been reading through the libcassandra code and it looks like everything is getting converted into a std::string which is fine for everything except TimeUUID. Is there another way to use this as a column name or am I missing something? I'll dig deeper into the code to see if there is a quick way to fix it (although I do not think there is).

Creating ColumnFamily and Column through C++ code

Hi,
We want to create ColumnFamily and Column dynamically in cassandra database through the C++ Code.Is the posulliv libcassandra c++ client support to dynamically create ColumnFamily?Can you please explain how to create columnfamily in cassandra through C++ code?

configure warns of problems with assert.h

During the configure process this problem occurs on my Ubuntu 11.04 machine (amd64) GCC 4.5

checking assert.h usability... no
checking assert.h presence... yes
configure: WARNING: assert.h: present but cannot be compiled
configure: WARNING: assert.h:     check for missing prerequisite headers?
configure: WARNING: assert.h: see the Autoconf documentation
configure: WARNING: assert.h:     section "Present But Cannot Be Compiled"
configure: WARNING: assert.h: proceeding with the compiler's result
configure: WARNING:     ## ------------------------------------------------------ ##
configure: WARNING:     ## Report this to http://github.com/posulliv/libcassandra ##
configure: WARNING:     ## ------------------------------------------------------ ##
checking for assert.h... no

Unable to remove an entire row specified by a key

I'm trying to remove an entire row from a standard column but validateColumnPath keeps throwing an exception because col_path.column is empty. According to the Cassandra API:

Note that all the values in column_path besides column_path.column_family are truly optional:...

Is there a way around this or am I doing something wrong? The code I'm executing that is generating the exception is as follows:

CassandraFactory(DBHOST, 9160);
tr1::shared_ptr<Cassandra> client(factory.create());
Keyspace *key_space = client->getKeyspace("Keyspace1");
key_space->remove("OrgName", "Organization", "", "");
delete key_space;

Any help would be appreciated. Thanks.

Assigning columnNames to SlicePredicate

Hi,
How to assign the columnNames to Slicepredicate which is used for getting the columnCount?
Is it possible to define the slicerange as "" empty byte array.(ie) slicerange.start=""; and slicerange.finish="";

Compilation Issue on Mac OSX

  1. On osx for libcassandra, you have to had this flag when configuring: ./configure CXXFLAGS="-I/opt/local/include -Wno-variadic-macros"
  2. had to add #include<sys/time.h> to util_functions.cc. I have to fill out a bug report for libassandra i guess.

Using factory->create() on an endpoint that is down, causes a memroy leak

in the file cassandra_factory.cc , in the function.....

CassandraClient *CassandraFactory::createThriftClient(const string &in_host,
int in_port,
bool framed_transport)

In this function the open is called after the pointer to CassandraClient is created. Any exception in open causes the CassandraClient pointer to be lost resulting in a memory leak. Not being able to connect to an endpoint throws the thrift TTransport exception which therefore results in a memory leak that I am seeing.

Reversing the order like so solves the problem...

transport->open(); /* throws an exception */
CassandraClient *client= new(std::nothrow) CassandraClient(protocol);

This has been tested to work.

Thanks.
-- Sandeep

ColumnType as Integer doesn't accept Integer data

Hai,
Creating column type as Integer doesn't allow to enter Integer data.
During column creation the validation class is assigned to "IntegerType".
After inserting values to these column accept only character data?Is it possible to enter the Integer data to the integer column type?

using getcount() showing "predicate column_names and slice_range may not both be null"

Hi,

      While using a getcount(key,columnparent,slicepredicate);

Here key as:

        "my_key" and 

Columnparent and columnpath as:

          org::apache::cassandra::ColumnPath cp;
          cp.__isset.column = true;
          cp.column_family.assign("DynamicCF");
          cp.column.assign("ColumnEg");

          org::apache::cassandra::ColumnParent columnparent;
          columnparent.column_family.assign("DynamicCF");

SlicePredicate as:

             org::apache::cassandra::SlicePredicate slicepredicate;
             org::apache::cassandra::SliceRange slicerange;
             slicerange.start="";
             slicerange.finish="";
             slicepredicate.slice_range=slicerange;

             org::apache::cassandra::KeyRange keyrange;
             keyrange.start_key="my_key";
             keyrange.end_key="my_key";

The function client->getCount("my_key",columnparent,slicepredicate); showing "predicate column_names and slice_range may not both be null".Already I assigned the column name to columnparent and passed the columnparent to getcount().How to add columnnames and slice range to predicate?

TException : No more data to read.

Environment: Cassandra 0.7.4 Thrift 0.5 Ubuntu

I could create the keyspace and column family thru command lines. And not problem to insert and get columns.

Then I installed thrift and try to use c++ to access cassandra.
Finally the test code compiled and linked.
But as soon as I try to call cassandra function, I got exceptions. I try to search in the web, but looks like there are not many documents available.

Any thing I did wrong? Thanks.

The source is simple, I posted below :

// remove #include , those lines make the post ugly

using namespace std;
using namespace apache::thrift;
using namespace apache::thrift::protocol;
using namespace apache::thrift::transport;
using namespace org::apache::cassandra;
using namespace boost;

static string host("localhost");
static int port= 9160;

int main()
{
shared_ptr socket(new TSocket(host, port));
shared_ptr transport(new TBufferedTransport(socket));
shared_ptr protocol(new TBinaryProtocol(transport));
CassandraClient client(protocol);

try
{

//Open transport
transport->open();

string keyspace = "cpptest";

********* client.set_keyspace(keyspace);
// Get exception on above line

string columnFamily = "Users";
ColumnParent parent;
parent.column_family.assign(columnFamily);
parent.super_column.assign("");


Column col;
col.name.assign("name");
col.value.assign("Bill Gates");
col.timestamp = 111111;

client.insert("bGates", // key
        parent, // &ColumnParent
        col,    // &Column
        ConsistencyLevel::ONE); // consistency level

ColumnOrSuperColumn ret_val;
ColumnPath  path;
path.column_family.assign(columnFamily);
path.super_column.assign("");
path.column.assign("name");

client.get(ret_val,     // &ColumnOrSuperColumn return value
     "bGates",  // key
     path,      // column path
     ConsistencyLevel::ONE);    // consistency level

printf("Column name retrieved is: %s\n", ret_val.column.name.c_str());
printf("Value in column retrieved is: %s\n", ret_val.column.value.c_str());

transport->close();
}

catch (InvalidRequestException &re)
{
    printf("InvalidRequestException : ");
    printf("ERROR: %s\n", re.why.c_str());
}
catch (TException &tx)
{
    printf("TException : ");
    printf("ERROR: %s\n", tx.what());
}

}

////////////////////////////////////////////////////
Here is the keyspace describtion:

[default@cpptest] describe keyspace cpptest;
Keyspace: cpptest:
Replication Strategy: org.apache.cassandra.locator.SimpleStrategy
Replication Factor: 1
Column Families:
ColumnFamily: Users
Columns sorted by: org.apache.cassandra.db.marshal.UTF8Type
Row cache size / save period: 0.0/0
Key cache size / save period: 200000.0/14400
Memtable thresholds: 0.140625/30/1440
GC grace seconds: 864000
Compaction min/max thresholds: 4/32
Read repair chance: 1.0
Built indexes: []

Bug in removing super column

col_path.column.assign(super_column_name);

should be:

col_path.super_column.assign(super_column_name);

void Keyspace::remove(const string &key,
const string &column_family,
const string &super_column_name,
const string &column_name)
{
ColumnPath col_path;
col_path.column_family.assign(column_family);
if (! super_column_name.empty())
{
col_path.column.assign(super_column_name);
col_path.__isset.super_column= true;
}
if (! column_name.empty())
{
col_path.column.assign(column_name);
col_path.__isset.column= true;
}
remove(key, col_path);
}

make warnings => errors regarding variadic macros...

Tried installing libcassandra and ran into the following (they were errors till I mucked with the Makefile to drop the -Werror flag):

In file included from /usr/local/include/thrift/Thrift.h:40,
from /usr/local/include/thrift/transport/TTransport.h:23,
from /usr/local/include/thrift/protocol/TProtocol.h:23,
from /usr/local/include/thrift/protocol/TBinaryProtocol.h:23,
from libcassandra/keyspace_factory.cc:13:
/usr/local/include/thrift/TLogging.h:69:33: warning: anonymous variadic macros were introduced in C99
/usr/local/include/thrift/TLogging.h:91:35: warning: anonymous variadic macros were introduced in C99
/usr/local/include/thrift/TLogging.h:102:40: warning: anonymous variadic macros were introduced in C99
/usr/local/include/thrift/TLogging.h:113:31: warning: anonymous variadic macros were introduced in C99
/usr/local/include/thrift/TLogging.h:130:37: warning: anonymous variadic macros were introduced in C99
/usr/local/include/thrift/TLogging.h:148:36: warning: anonymous variadic macros were introduced in C99


really not sure what's going on, but the compiler command looks like it's instructing g++ (4.2) to use -std=gnu++98...is that "pre" C99?...:

g++ -DHAVE_CONFIG_H -I. -I. -ggdb3 -I/usr/local/include -D_THREAD_SAFE -pipe -std=gnu++98 -O3 -pedantic -Wall -Wundef -Wshadow -fdiagnostics-show-option -Wformat -fno-strict-aliasing -Wno-strict-aliasing -Wextra -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long -Wno-redundant-decls -I/usr/local/include/thrift -MT libcassandra/libcassandra_libcassandra_la-keyspace_factory.lo -MD -MP -MF libcassandra/.deps/libcassandra_libcassandra_la-keyspace_factory.Tpo -c libcassandra/keyspace_factory.cc -fno-common -DPIC -o libcassandra/.libs/libcassandra_libcassandra_la-keyspace_factory.o

even if it "works", i really don't like actively suppressing warnings like this, so would love any input/troubleshooting you could offer.

again, i know nothing, so feel free to ask obvious questions.

Mac OS X 10.6, (believe default with OS) g++-4.2, thrift 0.2.0 from tarball, boost 1.42, ...

thanks,
bp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.