use of org.apache.cassandra.db.RowIndexEntry in project cassandra by apache.
the class MajorLeveledCompactionWriter method realAppend.
@Override
@SuppressWarnings("resource")
public boolean realAppend(UnfilteredRowIterator partition) {
RowIndexEntry rie = sstableWriter.append(partition);
partitionsWritten++;
long totalWrittenInCurrentWriter = sstableWriter.currentWriter().getEstimatedOnDiskBytesWritten();
if (totalWrittenInCurrentWriter > maxSSTableSize) {
totalWrittenInLevel += totalWrittenInCurrentWriter;
if (totalWrittenInLevel > LeveledManifest.maxBytesForLevel(currentLevel, levelFanoutSize, maxSSTableSize)) {
totalWrittenInLevel = 0;
currentLevel++;
}
switchCompactionLocation(sstableDirectory);
}
return rie != null;
}
use of org.apache.cassandra.db.RowIndexEntry in project cassandra by apache.
the class SSTableRewriter method append.
public RowIndexEntry append(UnfilteredRowIterator partition) {
// we do this before appending to ensure we can resetAndTruncate() safely if the append fails
DecoratedKey key = partition.partitionKey();
maybeReopenEarly(key);
RowIndexEntry index = writer.append(partition);
if (!transaction.isOffline() && index != null) {
for (SSTableReader reader : transaction.originals()) {
if (reader.getCachedPosition(key, false) != null) {
cachedKeys.put(key, index);
break;
}
}
}
return index;
}
use of org.apache.cassandra.db.RowIndexEntry in project cassandra by apache.
the class QueryWithIndexedSSTableTest method queryIndexedSSTableTest.
@Test
public void queryIndexedSSTableTest() throws Throwable {
// That test reproduces the bug from CASSANDRA-10903 and the fact we have a static column is
// relevant to that reproduction in particular as it forces a slightly different code path that
// if there wasn't a static.
int ROWS = 1000;
int VALUE_LENGTH = 100;
createTable("CREATE TABLE %s (k int, t int, s text static, v text, PRIMARY KEY (k, t))");
// We create a partition that is big enough that the underlying sstable will be indexed
// For that, we use a large-ish number of row, and a value that isn't too small.
String text = TombstonesWithIndexedSSTableTest.makeRandomString(VALUE_LENGTH);
for (int i = 0; i < ROWS; i++) execute("INSERT INTO %s(k, t, v) VALUES (?, ?, ?)", 0, i, text + i);
flush();
compact();
// Sanity check that we're testing what we want to test, that is that we're reading from an indexed
// sstable. Note that we'll almost surely have a single indexed sstable in practice, but it's theorically
// possible for a compact strategy to yield more than that and as long as one is indexed we're pretty
// much testing what we want. If this check ever fails on some specific setting, we'll have to either
// tweak ROWS and VALUE_LENGTH, or skip the test on those settings.
DecoratedKey dk = Util.dk(ByteBufferUtil.bytes(0));
boolean hasIndexed = false;
for (SSTableReader sstable : getCurrentColumnFamilyStore().getLiveSSTables()) {
RowIndexEntry indexEntry = sstable.getPosition(dk, SSTableReader.Operator.EQ);
hasIndexed |= indexEntry != null && indexEntry.isIndexed();
}
assert hasIndexed;
assertRowCount(execute("SELECT s FROM %s WHERE k = ?", 0), ROWS);
assertRowCount(execute("SELECT s FROM %s WHERE k = ? ORDER BY t DESC", 0), ROWS);
assertRowCount(execute("SELECT DISTINCT s FROM %s WHERE k = ?", 0), 1);
assertRowCount(execute("SELECT DISTINCT s FROM %s WHERE k = ? ORDER BY t DESC", 0), 1);
}
Aggregations