Clean up dead code and unused imports

- SSTableCursorWriter.currentOffsetInPartition had zero callers: its logic moved into
  BigCursorIndexWriter when the index-writer seam was extracted, but the dead private
  method was left behind.
- Five imports in SSTableCursorWriter (Ints, FSWriteError, RowIndexEntry, BloomFilter,
  ByteArrayUtil) are unused: BloomFilter/RowIndexEntry usage moved into
  BigCursorIndexWriter along with the rest of the index machinery.
- DifferentialCompactionTester recompiled the "expired" field's normalization regex on
  every dump line instead of once; now a static final Pattern.
- CursorCompactor.Purger took a nowInSec constructor parameter and stored it in a field
  that was never read; shouldPurge() only ever uses controller.gcBefore. Removed the
  dead field and parameter.

No behavior change.
This commit is contained in:
Jon Haddad 2026-07-27 12:25:16 -07:00
parent 65da5b35ad
commit 627b83cba8
3 changed files with 12 additions and 20 deletions

View File

@ -315,7 +315,7 @@ public class CursorCompactor extends CompactionInfo.Holder
this.sstableCursorsEqualsNext = new boolean[sstables.size()];
this.enforceStrictLiveness = controller.cfs.metadata.get().enforceStrictLiveness();
purger = new Purger(type, controller, nowInSec);
purger = new Purger(type, controller);
detachedLastWrittenKey = metadata.partitioner.createReusableKey(128);
}
@ -1423,8 +1423,6 @@ public class CursorCompactor extends CompactionInfo.Holder
*/
static class Purger implements DeletionPurger
{
private final long nowInSec;
private final long oldestUnrepairedTombstone;
private final boolean onlyPurgeRepairedTombstones;
private final boolean shouldIgnoreGcGraceForAnyKey;
@ -1438,12 +1436,11 @@ public class CursorCompactor extends CompactionInfo.Holder
private long compactedUnfiltered;
Purger(OperationType type, AbstractCompactionController controller, long nowInSec)
Purger(OperationType type, AbstractCompactionController controller)
{
oldestUnrepairedTombstone = controller.compactingRepaired() ? Long.MAX_VALUE : Integer.MIN_VALUE;
onlyPurgeRepairedTombstones = controller.cfs.getCompactionStrategyManager().onlyPurgeRepairedTombstones();
shouldIgnoreGcGraceForAnyKey = controller.cfs.shouldIgnoreGcGraceForAnyKey();
this.nowInSec = nowInSec;
this.controller = controller;
this.type = type;
}

View File

@ -22,7 +22,6 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.primitives.Ints;
import org.agrona.collections.IntArrayList;
@ -44,19 +43,15 @@ import org.apache.cassandra.db.rows.SerializationHelper;
import org.apache.cassandra.db.rows.Unfiltered;
import org.apache.cassandra.db.rows.UnfilteredSerializer;
import org.apache.cassandra.dht.IPartitioner;
import org.apache.cassandra.io.FSWriteError;
import org.apache.cassandra.io.sstable.format.SSTableReader;
import org.apache.cassandra.io.sstable.format.SortedTableWriter;
import org.apache.cassandra.io.sstable.format.big.BigFormatPartitionWriter;
import org.apache.cassandra.io.sstable.format.big.BigTableWriter;
import org.apache.cassandra.io.sstable.format.big.RowIndexEntry;
import org.apache.cassandra.io.sstable.metadata.MetadataCollector;
import org.apache.cassandra.io.util.DataOutputBuffer;
import org.apache.cassandra.io.util.DataOutputPlus;
import org.apache.cassandra.io.util.SequentialWriter;
import org.apache.cassandra.schema.ColumnMetadata;
import org.apache.cassandra.utils.BloomFilter;
import org.apache.cassandra.utils.ByteArrayUtil;
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.cassandra.utils.concurrent.Ref;
@ -513,12 +508,6 @@ public class SSTableCursorWriter implements AutoCloseable
metadataCollector.updateClusteringValues(unfilteredDescriptor);
}
private long currentOffsetInPartition(long position)
{
return position - partitionStart;
}
/**
* Garbage-free equivalent of {@link org.apache.cassandra.db.Columns.Serializer}'s
* serializeSubset for a PARTIAL subset (not all-present, not all-missing callers

View File

@ -92,6 +92,12 @@ public abstract class DifferentialCompactionTester extends CQLTester
/** Fixed "now" used for JSON dumps so rendering cannot depend on wall clock. */
private static final long DUMP_NOW_SEC = 0;
// sstabledump's "expired" fields come from WALL CLOCK, not the fixed nowInSec above
// (JsonTransformer), so the two paths' captures can render them differently; the flag is
// derived from expires_at, which is still compared.
private static final java.util.regex.Pattern EXPIRED_FLAG =
java.util.regex.Pattern.compile("\"expired\"\\s*:\\s*(true|false)");
/**
* Scale mode for very large scenarios (millions of rows): the logical dump is streamed
* into a SHA-256 digest instead of being retained as a String, so capture memory stays
@ -422,7 +428,7 @@ public abstract class DifferentialCompactionTester extends CQLTester
sstable.metadata(), DUMP_NOW_SEC, baos);
}
json = baos.toString(StandardCharsets.UTF_8)
.replaceAll("\"expired\"\\s*:\\s*(true|false)", "\"expired\":\"normalized\"");
.transform(s -> EXPIRED_FLAG.matcher(s).replaceAll("\"expired\":\"normalized\""));
}
// 3. stats spot-check summary
@ -633,9 +639,9 @@ public abstract class DifferentialCompactionTester extends CQLTester
private void update(byte[] bytes, int length)
{
byte[] normalized = new String(bytes, 0, length, StandardCharsets.UTF_8)
.replaceAll("\"expired\"\\s*:\\s*(true|false)", "\"expired\":\"normalized\"")
.getBytes(StandardCharsets.UTF_8);
byte[] normalized = EXPIRED_FLAG.matcher(new String(bytes, 0, length, StandardCharsets.UTF_8))
.replaceAll("\"expired\":\"normalized\"")
.getBytes(StandardCharsets.UTF_8);
digest.update(normalized);
bytesSeen += normalized.length;
}