Created
February 28, 2012 01:23
-
-
Save emaxerrno/1928349 to your computer and use it in GitHub Desktop.
Could not find comparator for component 0
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.cassandra.utils.TimeUUIDUtils; | |
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()); | |
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, TimeUUIDUtils.getUniqueTimeUUIDinMillis()); | |
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