| for (int j = 2; j < 10; j++)
insertRowWithKey(i * 100 + j);
store.forceBlockingFlush();
assertEquals(1, store.getSSTables().size());
SSTableReader sstable = store.getSSTables().iterator().next();
// full range scan
ICompactionScanner fullScanner = sstable.getScanner();
assertScanContainsRanges(fullScanner,
2, 9,
102, 109,
202, 209);
// scan all three ranges separately
ICompactionScanner scanner = sstable.getScanner(makeRanges(1, 9,
101, 109,
201, 209),
null);
assertScanContainsRanges(scanner,
2, 9,
102, 109,
202, 209);
// skip the first range
scanner = sstable.getScanner(makeRanges(101, 109,
201, 209),
null);
assertScanContainsRanges(scanner,
102, 109,
202, 209);
// skip the second range
scanner = sstable.getScanner(makeRanges(1, 9,
201, 209),
null);
assertScanContainsRanges(scanner,
2, 9,
202, 209);
// skip the last range
scanner = sstable.getScanner(makeRanges(1, 9,
101, 109),
null);
assertScanContainsRanges(scanner,
2, 9,
102, 109);
// the first scanned range stops short of the actual data in the first range
scanner = sstable.getScanner(makeRanges(1, 5,
101, 109,
201, 209),
null);
assertScanContainsRanges(scanner,
2, 5,
102, 109,
202, 209);
// the first scanned range requests data beyond actual data in the first range
scanner = sstable.getScanner(makeRanges(1, 20,
101, 109,
201, 209),
null);
assertScanContainsRanges(scanner,
2, 9,
102, 109,
202, 209);
// the middle scan range splits the outside two data ranges
scanner = sstable.getScanner(makeRanges(1, 5,
6, 205,
206, 209),
null);
assertScanContainsRanges(scanner,
2, 5,
7, 9,
102, 109,
202, 205,
207, 209);
// empty ranges
scanner = sstable.getScanner(makeRanges(0, 1,
2, 20,
101, 109,
150, 159,
201, 209,
1000, 1001),
null);
assertScanContainsRanges(scanner,
3, 9,
102, 109,
202, 209);
// out of order ranges
scanner = sstable.getScanner(makeRanges(201, 209,
1, 20,
201, 209,
101, 109,
1000, 1001,
150, 159),
null);
assertScanContainsRanges(scanner,
2, 9,
102, 109,
202, 209);
// only empty ranges
scanner = sstable.getScanner(makeRanges(0, 1,
150, 159,
250, 259),
null);
assertFalse(scanner.hasNext());
// no ranges is equivalent to a full scan
scanner = sstable.getScanner(new ArrayList<Range<Token>>(), null);
assertFalse(scanner.hasNext());
}
|