Created
February 28, 2012 01:17
-
-
Save emaxerrno/1928338 to your computer and use it in GitHub Desktop.
Working Version -- Tracking TimeUUIDType bug
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
import me.prettyprint.cassandra.model.HColumnImpl; | |
import me.prettyprint.cassandra.serializers.BytesArraySerializer; | |
import me.prettyprint.cassandra.serializers.DynamicCompositeSerializer; | |
import me.prettyprint.cassandra.serializers.StringSerializer; | |
import me.prettyprint.hector.api.Cluster; | |
import me.prettyprint.hector.api.Keyspace; | |
import me.prettyprint.hector.api.beans.DynamicComposite; | |
import me.prettyprint.hector.api.factory.HFactory; | |
import me.prettyprint.hector.api.mutation.Mutator; | |
public class NateExample { | |
public static String keyspaceName = "KSP", columnFamilyName = "UserEvents"; | |
public static void main(String... args) { | |
// Step 1: Create a cluster | |
Cluster cluster = HFactory.getOrCreateCluster("Test Cluster", | |
"192.168.2.38:9160"); | |
Keyspace ksp = HFactory.createKeyspace(keyspaceName, cluster); | |
// The mutator is a mutator for ANY column family. | |
Mutator<byte[]> mutator = HFactory.createMutator(ksp, | |
BytesArraySerializer.get()); | |
// The columns inside the "composite row" are simply | |
// DynamicComposite:String for key:value pairs. | |
// You can exapnd this model and use Composite:String or whatever other | |
// time you want | |
HColumnImpl<DynamicComposite, String> column = new HColumnImpl<DynamicComposite, String>( | |
DynamicCompositeSerializer.get(), StringSerializer.get()); | |
column.setClock(ksp.createClock()); | |
// family above. | |
DynamicComposite colKey = new DynamicComposite(); | |
colKey.add(0, "BoldBetum".getBytes()); | |
colKey.add(1, "BoomBaz"); | |
column.setName(colKey); | |
column.setValue("bestValue"); | |
mutator.insert("realByteArray".getBytes(), columnFamilyName, column); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment