-
Notifications
You must be signed in to change notification settings - Fork 353
Create keyspaces and column families
ash2k edited this page Nov 15, 2012
·
2 revisions
Astyanax provides a mechanism to programmatically create keyspaces and column families based on the Keyspace and ColumnFamily objects. The API will pick up the names and validators from the object but will allow for overrides in an operation Map<String, Object>. The API supports all properties supported by the CLI.
Assuming you already created your keyspace object you can then create the actual keyspace by calling
keyspace.createKeyspace(ImmutableMap.<String, Object>builder()
.put("strategy_options", ImmutableMap.<String, Object>builder()
.put("us-east", "3");
.put("eu-west", "3");
.build())
.put("strategy_class", "NetworkTopologyStrategy")
.build()
);
keyspace.dropKeyspace()
ColumnFamily<String, String> CF_STANDARD1 = ColumnFamily
.newColumnFamily("Standard1", StringSerializer.get(), StringSerializer.get());
keyspace.createColumnFamily(CF_STANDARD1,null);
keyspace.createColumnFamily(CF_STANDARD1, ImmutableMap.<String, Object>builder()
.put("column_metadata", ImmutableMap.<String, Object>builder()
.put("Index1", ImmutableMap.<String, Object>builder()
.put("validation_class", "UTF8Type")
.put("index_name", "Index1")
.put("index_type", "KEYS")
.build())
.put("Index2", ImmutableMap.<String, Object>builder()
.put("validation_class", "UTF8Type")
.put("index_name", "Index2")
.put("index_type", "KEYS")
.build())
.build())
.build());
keyspace.dropColumnFamily(CF_STANDARD1);
A Netflix Original Production
Tech Blog | Twitter @NetflixOSS | Jobs
- Getting-Started
- Configuration
- Features
- Monitoring
- Thread Safety
- Timeouts
- Recipes
- Examples
- Javadoc
- Utilities
- Cassandra-Compatibility
- FAQ
- End-to-End Examples
- Astyanax Integration with Java Driver