Created
May 15, 2012 17:39
-
-
Save sheki/2703581 to your computer and use it in GitHub Desktop.
example of creating column family's from astyanax Cassandra client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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