use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class SSTableReaderTest method testSpannedIndexPositions.
@Test
public void testSpannedIndexPositions() throws IOException, ExecutionException, InterruptedException {
// each index entry is ~11 bytes, so this will generate lots of segments
MmappedSegmentedFile.MAX_SEGMENT_SIZE = 40;
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
// insert a bunch of data and compact to a single sstable
CompactionManager.instance.disableAutoCompaction();
for (int j = 0; j < 100; j += 2) {
ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(j));
RowMutation rm = new RowMutation("Keyspace1", key);
rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("0")), ByteBufferUtil.EMPTY_BYTE_BUFFER, j);
rm.apply();
}
store.forceBlockingFlush();
CompactionManager.instance.performMaximal(store);
// check that all our keys are found correctly
SSTableReader sstable = store.getSSTables().iterator().next();
for (int j = 0; j < 100; j += 2) {
DecoratedKey dk = Util.dk(String.valueOf(j));
FileDataInput file = sstable.getFileDataInput(dk, DatabaseDescriptor.getIndexedReadBufferSizeInKB() * 1024);
DecoratedKey keyInDisk = SSTableReader.decodeKey(sstable.partitioner, sstable.descriptor, ByteBufferUtil.readWithShortLength(file));
assert keyInDisk.equals(dk) : String.format("%s != %s in %s", keyInDisk, dk, file.getPath());
}
// check no false positives
for (int j = 1; j < 110; j += 2) {
DecoratedKey dk = Util.dk(String.valueOf(j));
assert sstable.getPosition(dk, SSTableReader.Operator.EQ) == -1;
}
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class SSTableReaderTest method testGetPositionsForRangesWithKeyCache.
@Test
public void testGetPositionsForRangesWithKeyCache() throws IOException, ExecutionException, InterruptedException {
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Standard2");
CacheService.instance.keyCache.setCapacity(100);
// insert data and compact to a single sstable
CompactionManager.instance.disableAutoCompaction();
for (int j = 0; j < 10; j++) {
ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(j));
RowMutation rm = new RowMutation("Keyspace1", key);
rm.add(new QueryPath("Standard2", null, ByteBufferUtil.bytes("0")), ByteBufferUtil.EMPTY_BYTE_BUFFER, j);
rm.apply();
}
store.forceBlockingFlush();
CompactionManager.instance.performMaximal(store);
SSTableReader sstable = store.getSSTables().iterator().next();
long p2 = sstable.getPosition(k(2), SSTableReader.Operator.EQ);
long p3 = sstable.getPosition(k(3), SSTableReader.Operator.EQ);
long p6 = sstable.getPosition(k(6), SSTableReader.Operator.EQ);
long p7 = sstable.getPosition(k(7), SSTableReader.Operator.EQ);
Pair<Long, Long> p = sstable.getPositionsForRanges(makeRanges(t(2), t(6))).iterator().next();
// range are start exclusive so we should start at 3
assert p.left == p3;
// to capture 6 we have to stop at the start of 7
assert p.right == p7;
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class SSTableReaderTest method testPersistentStatistics.
@Test
public void testPersistentStatistics() throws IOException, ExecutionException, InterruptedException {
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
for (int j = 0; j < 100; j += 2) {
ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(j));
RowMutation rm = new RowMutation("Keyspace1", key);
rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("0")), ByteBufferUtil.EMPTY_BYTE_BUFFER, j);
rm.apply();
}
store.forceBlockingFlush();
store.clearUnsafe();
store.loadNewSSTables();
assert store.getMaxRowSize() != 0;
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class SSTableReaderTest method testGetPositionsForRanges.
@Test
public void testGetPositionsForRanges() throws IOException, ExecutionException, InterruptedException {
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Standard2");
// insert data and compact to a single sstable
CompactionManager.instance.disableAutoCompaction();
for (int j = 0; j < 10; j++) {
ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(j));
RowMutation rm = new RowMutation("Keyspace1", key);
rm.add(new QueryPath("Standard2", null, ByteBufferUtil.bytes("0")), ByteBufferUtil.EMPTY_BYTE_BUFFER, j);
rm.apply();
}
store.forceBlockingFlush();
CompactionManager.instance.performMaximal(store);
List<Range<Token>> ranges = new ArrayList<Range<Token>>();
// 1 key
ranges.add(new Range<Token>(t(0), t(1)));
// 2 keys
ranges.add(new Range<Token>(t(2), t(4)));
// wrapping range from key to end
ranges.add(new Range<Token>(t(6), StorageService.getPartitioner().getMinimumToken()));
// empty range (should be ignored)
ranges.add(new Range<Token>(t(9), t(91)));
// confirm that positions increase continuously
SSTableReader sstable = store.getSSTables().iterator().next();
long previous = -1;
for (Pair<Long, Long> section : sstable.getPositionsForRanges(ranges)) {
assert previous <= section.left : previous + " ! < " + section.left;
assert section.left < section.right : section.left + " ! < " + section.right;
previous = section.right;
}
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class TimeSortTest method validateTimeSort.
private void validateTimeSort(Table table) throws IOException {
for (int i = 900; i < 1000; ++i) {
DecoratedKey key = Util.dk(Integer.toString(i));
for (int j = 0; j < 8; j += 3) {
ColumnFamily cf = table.getColumnFamilyStore("StandardLong1").getColumnFamily(key, new QueryPath("StandardLong1"), getBytes(j * 2), ByteBufferUtil.EMPTY_BYTE_BUFFER, false, 1000);
Collection<IColumn> columns = cf.getSortedColumns();
assert columns.size() == 8 - j;
int k = j;
for (IColumn c : columns) {
assertEquals((k++) * 2, c.timestamp());
}
}
}
}
Aggregations