indexkeys.put("foreignid","777");
indexkeys.put("type", "5");
indexkeys.put("instance", "222222");
// creating a iterator that has both start and end and both are inclusive
UnboundableCQLStatementIterator unBoundedIterator = (UnboundableCQLStatementIterator) CObjectCQLGenerator.makeCQLforList(KEYSPACE_NAME, shardIdLists, def, indexkeys, CObjectOrdering.DESCENDING, start, stop, 10l, true, false, false);
CQLStatement actual = unBoundedIterator.next();
CQLStatement expected = CQLStatement.make(
"SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id >= ? AND id <= ? ORDER BY id DESC LIMIT 10 ALLOW FILTERING;",
TABLE_NAME,
arrayFromValues(Long.valueOf(160),"777","222222","5", start, stop)
);
assertEquals(expected.getQuery(), actual.getQuery());
assertEquals(expected.getValues()[0], actual.getValues()[0]);
assertEquals(expected.getValues()[1], actual.getValues()[1]);
assertEquals(expected.getValues()[2], actual.getValues()[2]);
assertEquals(expected.getValues()[3], actual.getValues()[3]);
assertEquals(expected.getValues()[4], actual.getValues()[4]);
assertEquals(expected.getValues()[5], actual.getValues()[5]);
// testing if next start uuid is correctly applied
UUID nextUuid = UUID.fromString("ada375b1-a2d9-11e2-99a3-3f36d3955e43");
unBoundedIterator.setNextUuid(nextUuid);
// should not contain next shard
assertFalse(unBoundedIterator.hasNext());
actual = unBoundedIterator.next();
assertEquals(expected.getQuery(), actual.getQuery());
assertEquals(expected.getValues()[0], actual.getValues()[0]);
assertEquals(expected.getValues()[1], actual.getValues()[1]);
assertEquals(expected.getValues()[2], actual.getValues()[2]);
assertEquals(expected.getValues()[3], actual.getValues()[3]);
assertEquals(expected.getValues()[4], actual.getValues()[4]);
assertEquals(nextUuid, actual.getValues()[5]);
// testing iterator that has both start and end , non inclusive
unBoundedIterator = (UnboundableCQLStatementIterator) CObjectCQLGenerator.makeCQLforList(KEYSPACE_NAME, shardIdLists, def, indexkeys, CObjectOrdering.DESCENDING, start, stop, 10l, false, false, false);
actual = unBoundedIterator.next();
expected = CQLStatement.make(
"SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id > ? AND id < ? ORDER BY id DESC LIMIT 10 ALLOW FILTERING;",
TABLE_NAME,
arrayFromValues(Long.valueOf(160),"777","222222","5", start, stop)
);
assertEquals(expected.getQuery(), actual.getQuery());
assertEquals(expected.getValues()[0], actual.getValues()[0]);
assertEquals(expected.getValues()[1], actual.getValues()[1]);
assertEquals(expected.getValues()[2], actual.getValues()[2]);
assertEquals(expected.getValues()[3], actual.getValues()[3]);
assertEquals(expected.getValues()[4], actual.getValues()[4]);
assertEquals(expected.getValues()[5], actual.getValues()[5]);
// testing if next start uuid is correctly applied
nextUuid = UUID.fromString("ada375b1-a2d9-11e2-99a3-3f36d3955e43");
unBoundedIterator.setNextUuid(nextUuid);
// should not contain next shard
assertFalse(unBoundedIterator.hasNext());
actual = unBoundedIterator.next();
expected = CQLStatement.make(
"SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id >= ? AND id <= ? ORDER BY id DESC LIMIT 10 ALLOW FILTERING;",
TABLE_NAME,
arrayFromValues(Long.valueOf(160),"777","222222","5", start, nextUuid)
);
assertEquals(expected.getQuery(), actual.getQuery());
assertEquals(expected.getValues()[0], actual.getValues()[0]);
assertEquals(expected.getValues()[1], actual.getValues()[1]);
assertEquals(expected.getValues()[2], actual.getValues()[2]);
assertEquals(expected.getValues()[3], actual.getValues()[3]);
assertEquals(expected.getValues()[4], actual.getValues()[4]);
assertEquals(expected.getValues()[5], actual.getValues()[5]);
// Repeating the above tests for ascending
unBoundedIterator = (UnboundableCQLStatementIterator) CObjectCQLGenerator.makeCQLforList(KEYSPACE_NAME, shardIdLists, def, indexkeys, CObjectOrdering.ASCENDING, start, stop, 10l, true, false, false);
actual = unBoundedIterator.next();
expected = CQLStatement.make(
"SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id >= ? AND id <= ? ORDER BY id ASC LIMIT 10 ALLOW FILTERING;",
TABLE_NAME,
arrayFromValues(Long.valueOf(160),"777","222222","5", start, stop)
);
assertEquals(expected.getQuery(), actual.getQuery());
assertEquals(expected.getValues()[0], actual.getValues()[0]);
assertEquals(expected.getValues()[1], actual.getValues()[1]);
assertEquals(expected.getValues()[2], actual.getValues()[2]);
assertEquals(expected.getValues()[3], actual.getValues()[3]);
assertEquals(expected.getValues()[4], actual.getValues()[4]);
assertEquals(expected.getValues()[5], actual.getValues()[5]);
// testing if next start uuid is correctly applied
nextUuid = UUID.fromString("ada375b1-a2d9-11e2-99a3-3f36d3955e43");
unBoundedIterator.setNextUuid(nextUuid);
// should not contain next shard
assertFalse(unBoundedIterator.hasNext());
actual = unBoundedIterator.next();
assertEquals(expected.getQuery(), actual.getQuery());
assertEquals(expected.getValues()[0], actual.getValues()[0]);
assertEquals(expected.getValues()[1], actual.getValues()[1]);
assertEquals(expected.getValues()[2], actual.getValues()[2]);
assertEquals(expected.getValues()[3], actual.getValues()[3]);
assertEquals(nextUuid, actual.getValues()[4]);
assertEquals(expected.getValues()[5], actual.getValues()[5]);
// testing iterator that has both start and end , non inclusive
unBoundedIterator = (UnboundableCQLStatementIterator) CObjectCQLGenerator.makeCQLforList(KEYSPACE_NAME, shardIdLists, def, indexkeys, CObjectOrdering.ASCENDING, start, stop, 10l, false, false, false);
actual = unBoundedIterator.next();
expected = CQLStatement.make(
"SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id > ? AND id < ? ORDER BY id ASC LIMIT 10 ALLOW FILTERING;",
TABLE_NAME,
arrayFromValues(Long.valueOf(160),"777","222222","5", start, stop)
);
assertEquals(expected.getQuery(), actual.getQuery());
assertEquals(expected.getValues()[0], actual.getValues()[0]);
assertEquals(expected.getValues()[1], actual.getValues()[1]);
assertEquals(expected.getValues()[2], actual.getValues()[2]);
assertEquals(expected.getValues()[3], actual.getValues()[3]);
assertEquals(expected.getValues()[4], actual.getValues()[4]);
assertEquals(expected.getValues()[5], actual.getValues()[5]);
// testing if next start uuid is correctly applied
nextUuid = UUID.fromString("ada375b1-a2d9-11e2-99a3-3f36d3955e43");
unBoundedIterator.setNextUuid(nextUuid);
// should not contain next shard
assertFalse(unBoundedIterator.hasNext());
actual = unBoundedIterator.next();
expected = CQLStatement.make(
"SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id >= ? AND id <= ? ORDER BY id ASC LIMIT 10 ALLOW FILTERING;",
TABLE_NAME,
arrayFromValues(Long.valueOf(160),"777","222222","5", nextUuid, stop)