Skip to content

Instantly share code, notes, and snippets.

@bartprokop
Created July 16, 2012 07:35
Show Gist options
  • Save bartprokop/3121376 to your computer and use it in GitHub Desktop.
Save bartprokop/3121376 to your computer and use it in GitHub Desktop.
Storing simple values in Casandra datastore
public static void main(String... args) throws Exception {
Cluster cluster = HFactory.getOrCreateCluster("test-cluster", "localhost:9160");
Keyspace keyspace = HFactory.createKeyspace("MyKeyspace", cluster);
ColumnFamilyTemplate<String, String> template =
new ThriftColumnFamilyTemplate<String, String>(keyspace, "ColumnFamilyName",
StringSerializer.get(), StringSerializer.get());
ColumnFamilyUpdater<String, String> updater = template.createUpdater("ABCDEFGHIJKLMNOPQ");
updater.setString("firstName", "John");
updater.setString("lastName", "Doe");
template.update(updater);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment