use of org.apache.cassandra.db.columniterator.IColumnIterator in project eiger by wlloyd.
the class ColumnFamilyStore method filterColumnFamily.
/**
* Filter a cached row, which will not be modified by the filter, but may be modified by throwing out
* tombstones that are no longer relevant.
* The returned column family won't be thread safe.
*/
ColumnFamily filterColumnFamily(ColumnFamily cached, QueryFilter filter, int gcBefore) {
ColumnFamily cf = cached.cloneMeShallow(ArrayBackedSortedColumns.factory(), filter.filter.isReversed());
IColumnIterator ci = filter.getMemtableColumnIterator(cached, null);
filter.collateColumns(cf, Collections.singletonList(ci), gcBefore);
// their subcolumns for relevance, so we need to do a second prune post facto here.
return cf.isSuper() ? removeDeleted(cf, gcBefore) : removeDeletedCF(cf, gcBefore);
}
use of org.apache.cassandra.db.columniterator.IColumnIterator in project eiger by wlloyd.
the class CollationController method collectAllData.
/**
* Collects data the brute-force way: gets an iterator for the filter in question
* from every memtable and sstable, then merges them together.
*/
private ColumnFamily collectAllData() {
logger.debug("collectAllData");
ISortedColumns.Factory factory = mutableColumns ? AtomicSortedColumns.factory() : ArrayBackedSortedColumns.factory();
List<IColumnIterator> iterators = new ArrayList<IColumnIterator>();
ColumnFamily returnCF = ColumnFamily.create(cfs.metadata, factory, filter.filter.isReversed());
ColumnFamilyStore.ViewFragment view = cfs.markReferenced(filter.key);
try {
for (Memtable memtable : view.memtables) {
IColumnIterator iter = filter.getMemtableColumnIterator(memtable);
if (iter != null) {
returnCF.delete(iter.getColumnFamily());
iterators.add(iter);
}
}
for (SSTableReader sstable : view.sstables) {
IColumnIterator iter = filter.getSSTableColumnIterator(sstable);
iterators.add(iter);
if (iter.getColumnFamily() != null) {
returnCF.delete(iter.getColumnFamily());
sstablesIterated++;
}
}
// and "there used to be data, but it's gone now" (we should cache the empty CF so we don't need to rebuild that slower)
if (iterators.isEmpty())
return null;
filter.collateColumns(returnCF, iterators, gcBefore);
// Caller is responsible for final removeDeletedCF. This is important for cacheRow to work correctly:
return returnCF;
} finally {
for (IColumnIterator iter : iterators) FileUtils.closeQuietly(iter);
SSTableReader.releaseReferences(view.sstables);
}
}
use of org.apache.cassandra.db.columniterator.IColumnIterator in project eiger by wlloyd.
the class SSTableImportTest method testImportSimpleCf.
@Test
public void testImportSimpleCf() throws IOException, URISyntaxException {
// Import JSON to temp SSTable file
String jsonUrl = resourcePath("SimpleCF.json");
File tempSS = tempSSTableFile("Keyspace1", "Standard1");
SSTableImport.importJson(jsonUrl, "Keyspace1", "Standard1", tempSS.getPath());
// Verify results
SSTableReader reader = SSTableReader.open(Descriptor.fromFilename(tempSS.getPath()));
QueryFilter qf = QueryFilter.getIdentityFilter(Util.dk("rowA"), new QueryPath("Standard1"));
IColumnIterator iter = qf.getSSTableColumnIterator(reader);
ColumnFamily cf = iter.getColumnFamily();
while (iter.hasNext()) cf.addColumn(iter.next());
assert cf.getColumn(ByteBufferUtil.bytes("colAA")).value().equals(hexToBytes("76616c4141"));
assert !(cf.getColumn(ByteBufferUtil.bytes("colAA")) instanceof DeletedColumn);
IColumn expCol = cf.getColumn(ByteBufferUtil.bytes("colAC"));
assert expCol.value().equals(hexToBytes("76616c4143"));
assert expCol instanceof ExpiringColumn;
assert ((ExpiringColumn) expCol).getTimeToLive() == 42 && expCol.getLocalDeletionTime() == 2000000000;
}
use of org.apache.cassandra.db.columniterator.IColumnIterator in project eiger by wlloyd.
the class SSTableUtils method assertContentEquals.
public static void assertContentEquals(SSTableReader lhs, SSTableReader rhs) throws IOException {
SSTableScanner slhs = lhs.getDirectScanner();
SSTableScanner srhs = rhs.getDirectScanner();
while (slhs.hasNext()) {
IColumnIterator ilhs = slhs.next();
assert srhs.hasNext() : "LHS contained more rows than RHS";
IColumnIterator irhs = srhs.next();
assertContentEquals(ilhs, irhs);
}
assert !srhs.hasNext() : "RHS contained more rows than LHS";
}
use of org.apache.cassandra.db.columniterator.IColumnIterator in project eiger by wlloyd.
the class Memtable method getNamesIterator.
public static IColumnIterator getNamesIterator(final DecoratedKey key, final ColumnFamily cf, final NamesQueryFilter filter) {
assert cf != null;
final boolean isStandard = !cf.isSuper();
return new SimpleAbstractColumnIterator() {
private Iterator<ByteBuffer> iter = filter.columns.iterator();
public ColumnFamily getColumnFamily() {
return cf;
}
public DecoratedKey getKey() {
return key;
}
protected IColumn computeNext() {
while (iter.hasNext()) {
ByteBuffer current = iter.next();
IColumn column = cf.getColumn(current);
if (column != null)
// clone supercolumns so caller can freely removeDeleted or otherwise mutate it
return isStandard ? column : ((SuperColumn) column).cloneMe();
}
return endOfData();
}
};
}
Aggregations