public void createSchema()
{
try
{
KsDef ksDef = null;
CfDef cfDef = new CfDef();
cfDef.name = "StudentFloatPrimitive";
cfDef.keyspace = keyspace;
cfDef.setKey_validation_class("FloatType");
cfDef.setComparator_type("UTF8Type");
ColumnDef name = new ColumnDef(ByteBuffer.wrap("NAME".getBytes()), "UTF8Type");
name.index_type = IndexType.KEYS;
cfDef.addToColumn_metadata(name);
ColumnDef age = new ColumnDef(ByteBuffer.wrap("AGE".getBytes()), "Int32Type");
age.index_type = IndexType.KEYS;
cfDef.addToColumn_metadata(age);
List<CfDef> cfDefs = new ArrayList<CfDef>();
cfDefs.add(cfDef);
try
{
CassandraCli.initClient();
ksDef = CassandraCli.client.describe_keyspace(keyspace);
CassandraCli.client.set_keyspace(keyspace);
List<CfDef> cfDefn = ksDef.getCf_defs();
for (CfDef cfDef1 : cfDefn)
{
if (cfDef1.getName().equalsIgnoreCase("StudentFloatPrimitive"))
{
CassandraCli.client.system_drop_column_family("StudentFloatPrimitive");
}
}
CassandraCli.client.system_add_column_family(cfDef);
}
catch (NotFoundException e)
{
ksDef = new KsDef(keyspace, "org.apache.cassandra.locator.SimpleStrategy", cfDefs);
// Set replication factor
if (ksDef.strategy_options == null)
{
ksDef.strategy_options = new LinkedHashMap<String, String>();
}