I am trying to run below code, but it gives this error. It compiles without
any errors. Kindly help me.
(source of the code :
http://posulliv.github.io/2011/02/27/libcassandra-sec-indexes/)
terminate called after throwing an instance of
'org::apache::cassandra::InvalidRequestException'
what(): Default TException.
Aborted
#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>
#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>
using namespace std;
using namespace libcassandra;
static string host("127.0.0.1");
static int port= 9160;
int main()
{
CassandraFactory cf(host, port);
tr1::shared_ptr<Cassandra> c(cf.create());
KeyspaceDefinition ks_def;
ks_def.setName("demo");
c->createKeyspace(ks_def);
ColumnFamilyDefinition cf_def;
cf_def.setName("users");
cf_def.setKeyspaceName(ks_def.getName());
ColumnDefinition name_col;
name_col.setName("full_name");
name_col.setValidationClass("UTF8Type");
ColumnDefinition sec_col;
sec_col.setName("birth_date");
sec_col.setValidationClass("LongType");
sec_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
ColumnDefinition third_col;
third_col.setName("state");
third_col.setValidationClass("UTF8Type");
third_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
cf_def.addColumnMetadata(name_col);
cf_def.addColumnMetadata(sec_col);
cf_def.addColumnMetadata(third_col);
c->setKeyspace(ks_def.getName());
c->createColumnFamily(cf_def);
return 0;
}