本文整理汇总了Java中org.apache.cassandra.io.sstable.SSTableScanner类的典型用法代码示例。如果您正苦于以下问题:Java SSTableScanner类的具体用法?Java SSTableScanner怎么用?Java SSTableScanner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SSTableScanner类属于org.apache.cassandra.io.sstable包,在下文中一共展示了SSTableScanner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: DataReader
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
/**
* Construct a reader for Index.db sstable file.
*
* @param tableStats SSTable statistics.
*/
public DataReader(SSTableStatistics tableStats, SSTableScanner scanner, int gcGrace) {
this.tableStats = tableStats;
this.scanner = scanner;
this.gcGrace = gcGrace;
this.position = 0;
}
开发者ID:instaclustr,项目名称:cassandra-sstable-tools,代码行数:12,代码来源:DataReader.java
示例2: testSuperColumnTombstones
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
@Test
public void testSuperColumnTombstones() throws ExecutionException, InterruptedException
{
Keyspace keyspace = Keyspace.open(KEYSPACE1);
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore("Super1");
cfs.disableAutoCompaction();
DecoratedKey key = Util.dk("tskey");
ByteBuffer scName = ByteBufferUtil.bytes("TestSuperColumn");
// a subcolumn
Mutation rm = new Mutation(KEYSPACE1, key.getKey());
rm.add("Super1", Util.cellname(scName, ByteBufferUtil.bytes(0)),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
FBUtilities.timestampMicros());
rm.applyUnsafe();
cfs.forceBlockingFlush();
// shadow the subcolumn with a supercolumn tombstone
rm = new Mutation(KEYSPACE1, key.getKey());
rm.deleteRange("Super1", SuperColumns.startOf(scName), SuperColumns.endOf(scName), FBUtilities.timestampMicros());
rm.applyUnsafe();
cfs.forceBlockingFlush();
CompactionManager.instance.performMaximal(cfs);
assertEquals(1, cfs.getSSTables().size());
// check that the shadowed column is gone
SSTableReader sstable = cfs.getSSTables().iterator().next();
Range keyRange = new Range<RowPosition>(key, sstable.partitioner.getMinimumToken().maxKeyBound());
SSTableScanner scanner = sstable.getScanner(DataRange.forKeyRange(keyRange));
OnDiskAtomIterator iter = scanner.next();
assertEquals(key, iter.getKey());
assertTrue(iter.next() instanceof RangeTombstone);
assertFalse(iter.hasNext());
}
开发者ID:daidong,项目名称:GraphTrek,代码行数:37,代码来源:CompactionsTest.java
示例3: CompactionIterator
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected CompactionIterator(CompactionType type, Iterator iter, CompactionController controller)
{
super(iter);
this.type = type;
this.controller = controller;
row = 0;
totalBytes = bytesRead = 0;
for (SSTableScanner scanner : getScanners())
{
totalBytes += scanner.getFileLength();
}
}
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:14,代码来源:CompactionIterator.java
示例4: getIterator
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
/**
* Get a row iterator over the provided memtables and sstables, between the provided keys
* and filtered by the queryfilter.
* @param memtables Memtables pending flush.
* @param sstables SStables to scan through.
* @param range The data range to fetch
* @param cfs
* @return A row iterator following all the given restrictions
*/
public static CloseableIterator<Row> getIterator(final Iterable<Memtable> memtables,
final Collection<SSTableReader> sstables,
final DataRange range,
final ColumnFamilyStore cfs,
final long now)
{
// fetch data from current memtable, historical memtables, and SSTables in the correct order.
final List<CloseableIterator<OnDiskAtomIterator>> iterators = new ArrayList<CloseableIterator<OnDiskAtomIterator>>();
// memtables
for (Memtable memtable : memtables)
{
iterators.add(new ConvertToColumnIterator<AtomicSortedColumns>(range, memtable.getEntryIterator(range.startKey(), range.stopKey())));
}
for (SSTableReader sstable : sstables)
{
final SSTableScanner scanner = sstable.getScanner(range);
iterators.add(scanner);
}
// reduce rows from all sources into a single row
return MergeIterator.get(iterators, COMPARE_BY_KEY, new MergeIterator.Reducer<OnDiskAtomIterator, Row>()
{
private final int gcBefore = cfs.gcBefore(now);
private final List<OnDiskAtomIterator> colIters = new ArrayList<OnDiskAtomIterator>();
private DecoratedKey key;
private ColumnFamily returnCF;
@Override
protected void onKeyChange()
{
this.returnCF = TreeMapBackedSortedColumns.factory.create(cfs.metadata);
}
public void reduce(OnDiskAtomIterator current)
{
this.colIters.add(current);
this.key = current.getKey();
this.returnCF.delete(current.getColumnFamily());
}
protected Row getReduced()
{
// First check if this row is in the rowCache. If it is we can skip the rest
ColumnFamily cached = cfs.getRawCachedRow(key);
if (cached == null)
{
// not cached: collate
QueryFilter.collateOnDiskAtom(returnCF, colIters, range.columnFilter(key.key), gcBefore, now);
}
else
{
QueryFilter keyFilter = new QueryFilter(key, cfs.name, range.columnFilter(key.key), now);
returnCF = cfs.filterColumnFamily(cached, keyFilter);
}
Row rv = new Row(key, returnCF);
colIters.clear();
key = null;
return rv;
}
});
}
开发者ID:pgaref,项目名称:ACaZoo,代码行数:74,代码来源:RowIteratorFactory.java
示例5: testNoExpire
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
@Test
public void testNoExpire() throws InterruptedException
{
ColumnFamilyStore cfs = Keyspace.open(KEYSPACE1).getColumnFamilyStore("Standard1");
cfs.disableAutoCompaction();
cfs.metadata.gcGraceSeconds(0);
long timestamp = System.currentTimeMillis();
Mutation rm = new Mutation(KEYSPACE1, Util.dk("ttl").getKey());
rm.add("Standard1", Util.cellname("col"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
1);
rm.add("Standard1", Util.cellname("col7"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
1);
rm.applyUnsafe();
cfs.forceBlockingFlush();
rm = new Mutation(KEYSPACE1, Util.dk("ttl").getKey());
rm.add("Standard1", Util.cellname("col2"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
1);
rm.applyUnsafe();
cfs.forceBlockingFlush();
rm = new Mutation(KEYSPACE1, Util.dk("ttl").getKey());
rm.add("Standard1", Util.cellname("col3"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
1);
rm.applyUnsafe();
cfs.forceBlockingFlush();
DecoratedKey noTTLKey = Util.dk("nottl");
rm = new Mutation(KEYSPACE1, noTTLKey.getKey());
rm.add("Standard1", Util.cellname("col311"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp);
rm.applyUnsafe();
cfs.forceBlockingFlush();
Thread.sleep(2000); // wait for ttl to expire
assertEquals(4, cfs.getSSTables().size());
cfs.enableAutoCompaction(true);
assertEquals(1, cfs.getSSTables().size());
SSTableReader sstable = cfs.getSSTables().iterator().next();
SSTableScanner scanner = sstable.getScanner(DataRange.allData(sstable.partitioner));
assertTrue(scanner.hasNext());
while(scanner.hasNext())
{
OnDiskAtomIterator iter = scanner.next();
assertEquals(noTTLKey, iter.getKey());
}
}
开发者ID:daidong,项目名称:GraphTrek,代码行数:55,代码来源:TTLExpiryTest.java
示例6: antiCompactOne
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
@Test
public void antiCompactOne() throws InterruptedException, ExecutionException, IOException
{
Keyspace keyspace = Keyspace.open(KEYSPACE1);
ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF);
store.disableAutoCompaction();
long timestamp = System.currentTimeMillis();
for (int i = 0; i < 10; i++)
{
DecoratedKey key = Util.dk(Integer.toString(i));
Mutation rm = new Mutation(KEYSPACE1, key.getKey());
for (int j = 0; j < 10; j++)
rm.add(CF, Util.cellname(Integer.toString(j)),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
0);
rm.applyUnsafe();
}
store.forceBlockingFlush();
Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
assertEquals(store.getSSTables().size(), sstables.size());
Range<Token> range = new Range<Token>(new BytesToken("0".getBytes()), new BytesToken("4".getBytes()));
List<Range<Token>> ranges = Arrays.asList(range);
SSTableReader.acquireReferences(sstables);
long repairedAt = 1000;
CompactionManager.instance.performAnticompaction(store, ranges, sstables, repairedAt);
assertEquals(2, store.getSSTables().size());
int repairedKeys = 0;
int nonRepairedKeys = 0;
for (SSTableReader sstable : store.getSSTables())
{
SSTableScanner scanner = sstable.getScanner();
while (scanner.hasNext())
{
SSTableIdentityIterator row = (SSTableIdentityIterator) scanner.next();
if (sstable.isRepaired())
{
assertTrue(range.contains(row.getKey().getToken()));
repairedKeys++;
}
else
{
assertFalse(range.contains(row.getKey().getToken()));
nonRepairedKeys++;
}
}
}
assertEquals(repairedKeys, 4);
assertEquals(nonRepairedKeys, 6);
}
开发者ID:daidong,项目名称:GraphTrek,代码行数:53,代码来源:AntiCompactionTest.java
示例7: antiCompactTen
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
public void antiCompactTen(String compactionStrategy) throws InterruptedException, ExecutionException, IOException
{
Keyspace keyspace = Keyspace.open(KEYSPACE1);
ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF);
store.setCompactionStrategyClass(compactionStrategy);
store.disableAutoCompaction();
for (int table = 0; table < 10; table++)
{
generateSStable(store,Integer.toString(table));
}
Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
assertEquals(store.getSSTables().size(), sstables.size());
Range<Token> range = new Range<Token>(new BytesToken("0".getBytes()), new BytesToken("4".getBytes()));
List<Range<Token>> ranges = Arrays.asList(range);
SSTableReader.acquireReferences(sstables);
long repairedAt = 1000;
CompactionManager.instance.performAnticompaction(store, ranges, sstables, repairedAt);
/*
Anticompaction will be anti-compacting 10 SSTables but will be doing this two at a time
so there will be no net change in the number of sstables
*/
assertEquals(10, store.getSSTables().size());
int repairedKeys = 0;
int nonRepairedKeys = 0;
for (SSTableReader sstable : store.getSSTables())
{
SSTableScanner scanner = sstable.getScanner();
while (scanner.hasNext())
{
SSTableIdentityIterator row = (SSTableIdentityIterator) scanner.next();
if (sstable.isRepaired())
{
assertTrue(range.contains(row.getKey().getToken()));
assertEquals(repairedAt, sstable.getSSTableMetadata().repairedAt);
repairedKeys++;
}
else
{
assertFalse(range.contains(row.getKey().getToken()));
assertEquals(ActiveRepairService.UNREPAIRED_SSTABLE, sstable.getSSTableMetadata().repairedAt);
nonRepairedKeys++;
}
}
}
assertEquals(repairedKeys, 40);
assertEquals(nonRepairedKeys, 60);
}
开发者ID:daidong,项目名称:GraphTrek,代码行数:51,代码来源:AntiCompactionTest.java
示例8: getIterator
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
/**
* Get a row iterator over the provided memtables and sstables, between the provided keys
* and filtered by the queryfilter.
* @param memtables Memtables pending flush.
* @param sstables SStables to scan through.
* @param startWith Start at this key
* @param stopAt Stop and this key
* @param filter Used to decide which columns to pull out
* @param cfs
* @return A row iterator following all the given restrictions
*/
public static CloseableIterator<Row> getIterator(final Iterable<Memtable> memtables,
final Collection<SSTableReader> sstables,
final RowPosition startWith,
final RowPosition stopAt,
final QueryFilter filter,
final ColumnFamilyStore cfs)
{
// fetch data from current memtable, historical memtables, and SSTables in the correct order.
final List<CloseableIterator<OnDiskAtomIterator>> iterators = new ArrayList<CloseableIterator<OnDiskAtomIterator>>();
// memtables
for (Memtable memtable : memtables)
{
iterators.add(new ConvertToColumnIterator(filter, memtable.getEntryIterator(startWith, stopAt)));
}
for (SSTableReader sstable : sstables)
{
final SSTableScanner scanner = sstable.getScanner(filter);
scanner.seekTo(startWith);
iterators.add(scanner);
}
// reduce rows from all sources into a single row
return MergeIterator.get(iterators, COMPARE_BY_KEY, new MergeIterator.Reducer<OnDiskAtomIterator, Row>()
{
private final int gcBefore = (int) (System.currentTimeMillis() / 1000) - cfs.metadata.getGcGraceSeconds();
private final List<OnDiskAtomIterator> colIters = new ArrayList<OnDiskAtomIterator>();
private DecoratedKey key;
private ColumnFamily returnCF;
@Override
protected void onKeyChange()
{
this.returnCF = ColumnFamily.create(cfs.metadata);
}
public void reduce(OnDiskAtomIterator current)
{
this.colIters.add(current);
this.key = current.getKey();
this.returnCF.delete(current.getColumnFamily());
}
protected Row getReduced()
{
// First check if this row is in the rowCache. If it is we can skip the rest
ColumnFamily cached = cfs.getRawCachedRow(key);
if (cached == null)
{
// not cached: collate
filter.collateOnDiskAtom(returnCF, colIters, gcBefore);
}
else
{
QueryFilter keyFilter = new QueryFilter(key, filter.path, filter.filter);
returnCF = cfs.filterColumnFamily(cached, keyFilter, gcBefore);
}
Row rv = new Row(key, returnCF);
colIters.clear();
key = null;
return rv;
}
});
}
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:79,代码来源:RowIteratorFactory.java
示例9: getIterator
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
/**
* Get a row iterator over the provided memtables and sstables, between the provided keys
* and filtered by the queryfilter.
* @param memtables Memtables pending flush.
* @param sstables SStables to scan through.
* @param range The data range to fetch
* @param cfs
* @return A row iterator following all the given restrictions
*/
public static CloseableIterator<Row> getIterator(final Iterable<Memtable> memtables,
final Collection<SSTableReader> sstables,
final DataRange range,
final ColumnFamilyStore cfs,
final long now)
{
// fetch data from current memtable, historical memtables, and SSTables in the correct order.
final List<CloseableIterator<OnDiskAtomIterator>> iterators = new ArrayList<CloseableIterator<OnDiskAtomIterator>>();
// memtables
for (Memtable memtable : memtables)
{
iterators.add(new ConvertToColumnIterator<>(range, memtable.getEntryIterator(range.startKey(), range.stopKey())));
}
for (SSTableReader sstable : sstables)
{
final SSTableScanner scanner = sstable.getScanner(range);
iterators.add(scanner);
}
// reduce rows from all sources into a single row
return MergeIterator.get(iterators, COMPARE_BY_KEY, new MergeIterator.Reducer<OnDiskAtomIterator, Row>()
{
private final int gcBefore = cfs.gcBefore(now);
private final List<OnDiskAtomIterator> colIters = new ArrayList<OnDiskAtomIterator>();
private DecoratedKey key;
private ColumnFamily returnCF;
@Override
protected void onKeyChange()
{
this.returnCF = TreeMapBackedSortedColumns.factory.create(cfs.metadata);
}
public void reduce(OnDiskAtomIterator current)
{
this.colIters.add(current);
this.key = current.getKey();
this.returnCF.delete(current.getColumnFamily());
}
protected Row getReduced()
{
// First check if this row is in the rowCache. If it is we can skip the rest
ColumnFamily cached = cfs.getRawCachedRow(key);
if (cached == null)
{
// not cached: collate
QueryFilter.collateOnDiskAtom(returnCF, colIters, range.columnFilter(key.key), gcBefore, now);
}
else
{
QueryFilter keyFilter = new QueryFilter(key, cfs.name, range.columnFilter(key.key), now);
returnCF = cfs.filterColumnFamily(cached, keyFilter);
}
Row rv = new Row(key, returnCF);
colIters.clear();
key = null;
return rv;
}
});
}
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:74,代码来源:RowIteratorFactory.java
示例10: testNoExpire
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
@Test
public void testNoExpire() throws ExecutionException, InterruptedException
{
ColumnFamilyStore cfs = Keyspace.open("Keyspace1").getColumnFamilyStore("Standard1");
cfs.disableAutoCompaction();
cfs.metadata.gcGraceSeconds(0);
long timestamp = System.currentTimeMillis();
Mutation rm = new Mutation("Keyspace1", Util.dk("ttl").key);
rm.add("Standard1", Util.cellname("col"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
1);
rm.add("Standard1", Util.cellname("col7"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
1);
rm.apply();
cfs.forceBlockingFlush();
rm = new Mutation("Keyspace1", Util.dk("ttl").key);
rm.add("Standard1", Util.cellname("col2"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
1);
rm.apply();
cfs.forceBlockingFlush();
rm = new Mutation("Keyspace1", Util.dk("ttl").key);
rm.add("Standard1", Util.cellname("col3"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
1);
rm.apply();
cfs.forceBlockingFlush();
DecoratedKey noTTLKey = Util.dk("nottl");
rm = new Mutation("Keyspace1", noTTLKey.key);
rm.add("Standard1", Util.cellname("col311"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp);
rm.apply();
cfs.forceBlockingFlush();
Thread.sleep(2000); // wait for ttl to expire
assertEquals(4, cfs.getSSTables().size());
cfs.enableAutoCompaction(true);
assertEquals(1, cfs.getSSTables().size());
SSTableReader sstable = cfs.getSSTables().iterator().next();
SSTableScanner scanner = sstable.getScanner(DataRange.allData(sstable.partitioner));
assertTrue(scanner.hasNext());
while(scanner.hasNext())
{
OnDiskAtomIterator iter = scanner.next();
assertEquals(noTTLKey, iter.getKey());
}
}
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:55,代码来源:TTLExpiryTest.java
示例11: getIterator
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
/**
* Get a row iterator over the provided memtables and sstables, between the provided keys
* and filtered by the queryfilter.
* @param memtables Memtables pending flush.
* @param sstables SStables to scan through.
* @param range The data range to fetch
* @param cfs
* @return A row iterator following all the given restrictions
*/
public static CloseableIterator<Row> getIterator(final Iterable<Memtable> memtables,
final Collection<SSTableReader> sstables,
final DataRange range,
final ColumnFamilyStore cfs,
final long now)
{
// fetch data from current memtable, historical memtables, and SSTables in the correct order.
final List<CloseableIterator<OnDiskAtomIterator>> iterators = new ArrayList<CloseableIterator<OnDiskAtomIterator>>();
// memtables
for (Memtable memtable : memtables)
{
iterators.add(new ConvertToColumnIterator(range, memtable.getEntryIterator(range.startKey(), range.stopKey())));
}
for (SSTableReader sstable : sstables)
{
final SSTableScanner scanner = sstable.getScanner(range);
iterators.add(scanner);
}
// reduce rows from all sources into a single row
return MergeIterator.get(iterators, COMPARE_BY_KEY, new MergeIterator.Reducer<OnDiskAtomIterator, Row>()
{
private final int gcBefore = cfs.gcBefore(now);
private final List<OnDiskAtomIterator> colIters = new ArrayList<OnDiskAtomIterator>();
private DecoratedKey key;
private ColumnFamily returnCF;
@Override
protected void onKeyChange()
{
this.returnCF = ArrayBackedSortedColumns.factory.create(cfs.metadata);
}
public void reduce(OnDiskAtomIterator current)
{
this.colIters.add(current);
this.key = current.getKey();
this.returnCF.delete(current.getColumnFamily());
}
protected Row getReduced()
{
// First check if this row is in the rowCache. If it is and it covers our filter, we can skip the rest
ColumnFamily cached = cfs.getRawCachedRow(key);
IDiskAtomFilter filter = range.columnFilter(key.key);
if (cached == null || !cfs.isFilterFullyCoveredBy(filter, cached, now))
{
// not cached: collate
QueryFilter.collateOnDiskAtom(returnCF, colIters, filter, gcBefore, now);
}
else
{
QueryFilter keyFilter = new QueryFilter(key, cfs.name, filter, now);
returnCF = cfs.filterColumnFamily(cached, keyFilter);
}
Row rv = new Row(key, returnCF);
colIters.clear();
key = null;
return rv;
}
});
}
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:76,代码来源:RowIteratorFactory.java
示例12: testNoExpire
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
@Test
public void testNoExpire() throws InterruptedException
{
ColumnFamilyStore cfs = Keyspace.open("Keyspace1").getColumnFamilyStore("Standard1");
cfs.disableAutoCompaction();
cfs.metadata.gcGraceSeconds(0);
long timestamp = System.currentTimeMillis();
Mutation rm = new Mutation("Keyspace1", Util.dk("ttl").key);
rm.add("Standard1", Util.cellname("col"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
1);
rm.add("Standard1", Util.cellname("col7"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
1);
rm.apply();
cfs.forceBlockingFlush();
rm = new Mutation("Keyspace1", Util.dk("ttl").key);
rm.add("Standard1", Util.cellname("col2"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
1);
rm.apply();
cfs.forceBlockingFlush();
rm = new Mutation("Keyspace1", Util.dk("ttl").key);
rm.add("Standard1", Util.cellname("col3"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
1);
rm.apply();
cfs.forceBlockingFlush();
DecoratedKey noTTLKey = Util.dk("nottl");
rm = new Mutation("Keyspace1", noTTLKey.key);
rm.add("Standard1", Util.cellname("col311"),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp);
rm.apply();
cfs.forceBlockingFlush();
Thread.sleep(2000); // wait for ttl to expire
assertEquals(4, cfs.getSSTables().size());
cfs.enableAutoCompaction(true);
assertEquals(1, cfs.getSSTables().size());
SSTableReader sstable = cfs.getSSTables().iterator().next();
SSTableScanner scanner = sstable.getScanner(DataRange.allData(sstable.partitioner));
assertTrue(scanner.hasNext());
while(scanner.hasNext())
{
OnDiskAtomIterator iter = scanner.next();
assertEquals(noTTLKey, iter.getKey());
}
}
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:55,代码来源:TTLExpiryTest.java
示例13: antiCompactOne
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
@Test
public void antiCompactOne() throws InterruptedException, ExecutionException, IOException
{
Keyspace keyspace = Keyspace.open(KEYSPACE1);
ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF);
store.disableAutoCompaction();
long timestamp = System.currentTimeMillis();
for (int i = 0; i < 10; i++)
{
DecoratedKey key = Util.dk(Integer.toString(i));
Mutation rm = new Mutation(KEYSPACE1, key.key);
for (int j = 0; j < 10; j++)
rm.add("Standard1", Util.cellname(Integer.toString(j)),
ByteBufferUtil.EMPTY_BYTE_BUFFER,
timestamp,
0);
rm.apply();
}
store.forceBlockingFlush();
Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
assertEquals(store.getSSTables().size(), sstables.size());
Range<Token> range = new Range<Token>(new BytesToken("0".getBytes()), new BytesToken("4".getBytes()));
List<Range<Token>> ranges = Arrays.asList(range);
SSTableReader.acquireReferences(sstables);
long repairedAt = 1000;
CompactionManager.instance.performAnticompaction(store, ranges, sstables, repairedAt);
assertEquals(2, store.getSSTables().size());
int repairedKeys = 0;
int nonRepairedKeys = 0;
for (SSTableReader sstable : store.getSSTables())
{
SSTableScanner scanner = sstable.getScanner();
while (scanner.hasNext())
{
SSTableIdentityIterator row = (SSTableIdentityIterator) scanner.next();
if (sstable.isRepaired())
{
assertTrue(range.contains(row.getKey().token));
repairedKeys++;
}
else
{
assertFalse(range.contains(row.getKey().token));
nonRepairedKeys++;
}
}
}
assertEquals(repairedKeys, 4);
assertEquals(nonRepairedKeys, 6);
}
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:53,代码来源:AntiCompactionTest.java
示例14: run
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
private static void run(Descriptor desc, CommandLine cmd, PrintStream out) throws IOException {
// Since we don't have a schema, make one up!
CFMetaData cfm = new CFMetaData(desc.ksname, desc.cfname, ColumnFamilyType.Standard,
UTF8Type.instance, UTF8Type.instance);
SSTableReader reader = SSTableReader.open(desc, cfm);
SSTableScanner scanner = reader.getScanner();
long totalTombstones = 0, totalColumns = 0;
if (cmd.hasOption("l")) {
out.printf(desc.baseFilename() + "\n");
out.printf("rowkey #tombstones (#columns)\n");
}
while (scanner.hasNext()) {
SSTableIdentityIterator row = (SSTableIdentityIterator) scanner.next();
int tombstonesCount = 0, columnsCount = 0;
while (row.hasNext())
{
OnDiskAtom column = row.next();
long now = System.currentTimeMillis();
if (column instanceof Column && ((Column) column).isMarkedForDelete(now)) {
tombstonesCount++;
}
columnsCount++;
}
totalTombstones += tombstonesCount;
totalColumns += columnsCount;
if (tombstonesCount > 0) {
String key;
try {
key = UTF8Type.instance.getString(row.getKey().key);
} catch (RuntimeException e) {
key = BytesType.instance.getString(row.getKey().key);
}
out.printf("%s %d (%d)%n", key, tombstonesCount, columnsCount);
}
}
if (cmd.hasOption("l")) {
out.printf("#total_tombstones (#total_columns)\n");
}
out.printf("%d (%d)%n", totalTombstones, totalColumns);
scanner.close();
}
开发者ID:spotify,项目名称:cassandra-opstools,代码行数:49,代码来源:CountTombstones.java
示例15: getScanners
import org.apache.cassandra.io.sstable.SSTableScanner; //导入依赖的package包/类
protected Iterable<SSTableScanner> getScanners()
{
return ((CollatingIterator)source).getIterators();
}
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:5,代码来源:CompactionIterator.java
注:本文中的org.apache.cassandra.io.sstable.SSTableScanner类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论