Skip to content

Commit

Permalink
added additional index clause arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
zznate committed Oct 5, 2010
1 parent 6a40be4 commit a68bd27
Showing 1 changed file with 34 additions and 12 deletions.
Expand Up @@ -24,11 +24,26 @@ public class IndexedSlicesQueryTest extends BaseEmbededServerSetupTest {
private static final LongSerializer le = new LongSerializer();
private Cluster cluster;
private Keyspace keyspace;
private String cf = "Indexed1";

@Before
public void setupCase() {
cluster = getOrCreateCluster("MyCluster", "127.0.0.1:9170");
keyspace = createKeyspace(KEYSPACE, cluster);
createMutator(keyspace, se)
.addInsertion("indexedSlicesTest_key1", cf, createColumn("birthyear", 1974L, se, le))
.addInsertion("indexedSlicesTest_key1", cf, createColumn("birthmonth", 4L, se, le))
.addInsertion("indexedSlicesTest_key2", cf, createColumn("birthyear", 1975L, se, le))
.addInsertion("indexedSlicesTest_key2", cf, createColumn("birthmonth", 4L, se, le))
.addInsertion("indexedSlicesTest_key3", cf, createColumn("birthyear", 1975L, se, le))
.addInsertion("indexedSlicesTest_key3", cf, createColumn("birthmonth", 5L, se, le))
.addInsertion("indexedSlicesTest_key4", cf, createColumn("birthyear", 1975L, se, le))
.addInsertion("indexedSlicesTest_key4", cf, createColumn("birthmonth", 6L, se, le))
.addInsertion("indexedSlicesTest_key5", cf, createColumn("birthyear", 1975L, se, le))
.addInsertion("indexedSlicesTest_key5", cf, createColumn("birthmonth", 7L, se, le))
.addInsertion("indexedSlicesTest_key6", cf, createColumn("birthyear", 1976L, se, le))
.addInsertion("indexedSlicesTest_key6", cf, createColumn("birthmonth", 6L, se, le))
.execute();
}

@After
Expand All @@ -38,24 +53,31 @@ public void teardownCase() {
}

@Test
public void testInsertGetRemove() {
String cf = "Indexed1";
public void testInsertGetRemove() {

createMutator(keyspace, se)
.addInsertion("indexedSlicesTest_key1", cf, createColumn("birthdate", 1L, se, le))
.addInsertion("indexedSlicesTest_key2", cf, createColumn("birthdate", 2L, se, le))
.addInsertion("indexedSlicesTest_key3", cf, createColumn("birthdate", 3L, se, le))
.addInsertion("indexedSlicesTest_key4", cf, createColumn("birthdate", 4L, se, le))
.addInsertion("indexedSlicesTest_key5", cf, createColumn("birthdate", 5L, se, le))
.execute();
IndexedSlicesQuery<String, String, Long> indexedSlicesQuery = new IndexedSlicesQuery<String, String, Long>(keyspace, se, se, le);
indexedSlicesQuery.addEqualsExpression("birthyear", 1975L);
indexedSlicesQuery.setColumnNames("birthyear");
indexedSlicesQuery.setColumnFamily(cf);
indexedSlicesQuery.setStartKey("");
QueryResult<OrderedRows<String, String, Long>> result = indexedSlicesQuery.execute();
assertEquals(4, result.get().getList().size());


}

@Test
public void testMultiClause() {

IndexedSlicesQuery<String, String, Long> indexedSlicesQuery = new IndexedSlicesQuery<String, String, Long>(keyspace, se, se, le);
indexedSlicesQuery.addEqualsExpression("birthdate", 4L);
indexedSlicesQuery.setColumnNames("birthdate");
indexedSlicesQuery.addEqualsExpression("birthyear", 1975L);
indexedSlicesQuery.addGteExpression("birthmonth", 4L);
indexedSlicesQuery.addLteExpression("birthmonth", 6L);
indexedSlicesQuery.setColumnNames("birthyear");
indexedSlicesQuery.setColumnFamily(cf);
indexedSlicesQuery.setStartKey("");
QueryResult<OrderedRows<String, String, Long>> result = indexedSlicesQuery.execute();
assertEquals(1, result.get().getList().size());
assertEquals(3, result.get().getList().size());


}
Expand Down

0 comments on commit a68bd27

Please sign in to comment.