Skip to content

Instantly share code, notes, and snippets.

@posulliv
Created February 28, 2011 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save posulliv/846774 to your computer and use it in GitHub Desktop.
Save posulliv/846774 to your computer and use it in GitHub Desktop.
cf= tr1::shared_ptr<CassandraFactory>(new CassandraFactory("localhost", 9160));
c= tr1::shared_ptr<Cassandra>(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(IndexType::KEYS);
ColumnDefinition third_col;
third_col.setName("state");
third_col.setValidationClass("UTF8Type");
third_col.setIndexType(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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment