Created
July 16, 2012 07:35
-
-
Save bartprokop/3121376 to your computer and use it in GitHub Desktop.
Storing simple values in Casandra datastore
This file contains hidden or 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
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