Database Reference
In-Depth Information
TFramedTransport tf = new TFramedTransport(tr);
TProtocol proto = new TBinaryProtocol(tf);
Cassandra.Client client = new Cassandra.Client(proto);
tr.open();
//Add the new keyspace
client.system_add_keyspace(k);
System.out.println("Added keyspace: "+ keyspaceName);
}
}
So all you need to do to create a new keyspace is give it a name, a replica placement strategy
(see Replica Placement Strategies ) , and a replication factor, then define any column families you
want that keyspace to hold, and you're set. Now you are ready to start inserting values into your
new MyCF column family.
NOTE
Cassandra will provide the default replication strategy if you don't name one; I'm just trying to be explicit
in this example to show the syntax.
Creating a Column Family
To create a column family, you also use the CLI or the API. Here are the options available when
creating a column family:
column_type
column_type
Either Super or Standard.
clock_type
clock_type
The only valid value is Timestamp .
comparator
comparator
Valid options include AsciiType , BytesType , LexicalUUIDType , LongType ,
TimeUUIDType , and UTF8Type .
subcomparator
subcomparator
Name of comparator used for subcolumns when the column_type is Super . Valid options
are the same as comparator.
Search WWH ::




Custom Search