Skip to content

Instantly share code, notes, and snippets.

@sheki
Created May 15, 2012 17:39
Show Gist options
  • Save sheki/2703581 to your computer and use it in GitHub Desktop.
Save sheki/2703581 to your computer and use it in GitHub Desktop.
example of creating column family's from astyanax Cassandra client
def createColumn(name: String, columnFamily : ColumnDefinition) = columnFamily.setName(name).setValidationClass("UTF8Type").setKeysIndex(name)
def createKeySpace(name : String) {
val ks = context.getEntity.makeKeyspaceDefinition().setName(name).setStrategyClass("SimpleStrategy").setStrategyOptions(Map("replication_factor"->"1") )
context.getEntity.addKeyspace(ks)
}
def createNewColumnFamily() = {
val columnFamily = newContext.getEntity.makeColumnFamilyDefinition().setKeyspace("harami")
val temp = createColumn("name",columnFamily.makeColumnDefinition())
val finalColumn = columnFamily.addColumnDefinition(temp).addColumnDefinition(createColumn("booya",columnFamily.makeColumnDefinition()))
context.getEntity.addColumnFamily(finalColumn)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment