Created
February 17, 2011 21:19
-
-
Save zznate/832728 to your computer and use it in GitHub Desktop.
Snippet from test case for new HColumnFamily
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
Where we have the following generic declaration of a type K for the key an N for the column name: HColumnFamily<K,N> | |
@Before | |
public void setupLocal() { | |
setupClient(); | |
Cluster cluster = new ThriftCluster("Test Cluster", cassandraHostConfigurator); | |
keyspace = HFactory.createKeyspace("Keyspace1", cluster); | |
Mutator<String> mutator = HFactory.createMutator(keyspace, StringSerializer.get()); | |
mutator.addInsertion("zznate", "Standard1", HFactory.createStringColumn("email", "[email protected]")); | |
mutator.addInsertion("zznate", "Standard1", HFactory.createColumn("int", 1, StringSerializer.get(), IntegerSerializer.get())); | |
mutator.addInsertion("zznate", "Standard1", HFactory.createColumn("long", 1L, StringSerializer.get(), LongSerializer.get())); | |
timeUUID = TimeUUIDUtils.getTimeUUID(System.currentTimeMillis()); | |
mutator.addInsertion("zznate", "Standard1", HFactory.createColumn("uuid", timeUUID, StringSerializer.get(), UUIDSerializer.get())); | |
mutator.execute(); | |
} | |
... | |
@Test | |
public void testColumnFamilySetup() { | |
HColumnFamily<String, String> columnFamily = new HColumnFamilyImpl<String,String>(keyspace, "Standard1",StringSerializer.get(), StringSerializer.get()); | |
columnFamily.addKey("zznate"); | |
// columnFamily.loadSlice(15); columnFamily.addKey().loadSlice() ~ def. 100 | |
assertEquals(1,columnFamily.getInt("int")); | |
assertEquals("[email protected]",columnFamily.getString("email")); | |
assertEquals(1L, columnFamily.getLong("long")); | |
assertEquals(timeUUID, columnFamily.getUUID("uuid")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment