Database Reference
In-Depth Information
Range Ghosts
You may sometimes hear people refer to “range ghosts” in Cassandra. This means that even if
you have deleted all of the columns for a given row, you will still see a result returned for that
row in a range slice, but the column data will be empty. This is valid, and is just something to
keep in mind as you iterate result sets on the client.
Programmatically Defining Keyspaces and Column
Families
You can create keyspaces and column families through the API as well. Example 7-6 shows you
how.
Example7-6.DeineKeyspaceExample.java
package com.cassandraguide.rw;
//imports omitted
/**
* Shows how to define a keyspace and CF programmatically.
*/
public class DefineKeyspaceExample {
public static void main(String[] args) throws UnsupportedEncodingException,
InvalidRequestException, UnavailableException,
TimedOutException,
TException, NotFoundException, InterruptedException {
Connector conn = new Connector();
Cassandra.Client client = conn.connect();
System.out.println("Defining new keyspace.");
KsDef ksdef = new KsDef();
ksdef.name = "ProgKS";
ksdef.replication_factor = 1;
ksdef.strategy_class =
"org.apache.cassandra.locator.RackUnawareStrategy";
List<CfDef> cfdefs = new ArrayList<CfDef>();
CfDef cfdef1 = new CfDef();
cfdef1.name = "ProgCF1";
cfdef1.keyspace = ksdef.name;
Search WWH ::




Custom Search