Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bf5f311
Extract Cursor class and update javadoc style
blambov Mar 13, 2025
e7f4f00
Change transformations to implement Cursor
blambov Mar 14, 2025
09a8b56
Adds the ability to verify cursors' behaviour for debugging
blambov Mar 14, 2025
635feaa
Put direction argument first in forEach/process
blambov Mar 18, 2025
7e57c12
Extract BaseTrie
blambov Mar 18, 2025
31ea5db
Add concrete type to BaseTrie
blambov Mar 18, 2025
a70a2d2
Add CursorWalkable interface to BaseTrie and move implementations there
blambov Mar 18, 2025
125b325
Run trie tests with verification by default
blambov Apr 4, 2025
3275662
Fix prefixed and singleton tailCursor
blambov Jun 2, 2025
0579577
Implement TrieSet and change slices to use intersection
blambov Mar 19, 2025
4735cde
Extract InMemoryBaseTrie unchanged in preparation for other trie types
blambov Apr 29, 2025
871f926
Add deletion support for InMemoryTrie
blambov Apr 29, 2025
e9b8ce1
Add RangeTrie
blambov Mar 24, 2025
ce9d384
Implement RangeTrie.applyTo, InMemoryTrie.delete and InMemoryTrie.app…
blambov May 5, 2025
ecd1f10
Add DeletionAwareTrie
blambov May 16, 2025
8069242
Add "Stage2" versions of trie memtable and partition classes
blambov Jul 15, 2025
83394bb
TrieMemtable Stage 3
blambov Jul 18, 2025
45bc6b1
Implement, test and benchmark stopIssuingTombstones
blambov Sep 4, 2025
855f587
Add trie slicing support for SAI uses
blambov Sep 25, 2025
b0519d6
Switch row deletions to point tombstones
blambov Sep 26, 2025
33b461e
Generalize forEachValue/Entry
blambov Oct 2, 2025
d59d5ec
Switch MemtableAverageRowSize to use trie directly and expand test
blambov Oct 2, 2025
21b0d30
Remove TrieSetIntersectionCursor and implement union and intersection…
blambov Nov 5, 2025
3177f9c
Move TrieSetNegatedCursor into TrieSetCursor
blambov Nov 5, 2025
9b0c620
Review changes
blambov Nov 6, 2025
993194d
Add graph for in-memory trie deletions
blambov Nov 6, 2025
d6902ca
Review changes
blambov Nov 6, 2025
64b5291
Test points in range tries
blambov Nov 6, 2025
94803f4
Review changes
blambov Nov 6, 2025
bbf34bd
Include head in applyToSelected calls
blambov Nov 6, 2025
b072af1
Add deletion-aware tails test and fix problems
blambov Nov 10, 2025
058afcb
Change deletion-aware collection merge to make independently tracking…
blambov Nov 10, 2025
239cb36
Review changes
blambov Nov 11, 2025
e825fde
Sonarcloud and idea warnings
blambov Nov 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,35 @@ public static TrieBackedPartition create(DecoratedKey partitionKey,
: new WithEnsureOnHeap(partitionKey, columnMetadata, encodingStats, rowCountIncludingStatic, tombstoneCount, trie, metadata, ensureOnHeap);
}

class RowIterator extends TrieEntriesIterator<Object, Row>
class RowIterator extends TrieEntriesIterator.WithNullFiltering<Object, Row>
{
public RowIterator(DeletionAwareTrie<Object, TrieTombstoneMarker> trie, Direction direction)
{
super(trie.contentOnlyTrie(), direction, RowData.class::isInstance);
super(trie.mergedTrie(TrieBackedPartition::combineDataAndDeletion), direction);
}

@Override
protected Row mapContent(Object content, byte[] bytes, int byteLength)
{
var rd = (RowData) content;
return toRow(rd,
metadata.comparator.clusteringFromByteComparable(
ByteBufferAccessor.instance,
ByteComparable.preencoded(BYTE_COMPARABLE_VERSION, bytes, 0, byteLength)));
if (content instanceof RowData)
return toRow((RowData) content,
getClustering(bytes, byteLength));
if (content instanceof Row)
{
BTreeRow row = (BTreeRow) content;
return BTreeRow.create(getClustering(bytes, byteLength),
row.primaryKeyLivenessInfo(),
row.deletion(),
row.getBTree(),
row.getMinLocalDeletionTime());
}

TrieTombstoneMarker marker = (TrieTombstoneMarker) content;
if (marker.hasPointData())
return BTreeRow.emptyDeletedRow(getClustering(bytes, byteLength),
Row.Deletion.regular(marker.deletionTime()));
else
return null;
}
}

Expand Down Expand Up @@ -318,16 +332,17 @@ protected static void putInTrie(ClusteringComparator comparator, InMemoryDeletio
Clustering<?> clustering = row.clustering();
DeletionTime deletionTime = row.deletion().time();

ByteComparable comparableClustering = comparator.asByteComparable(clustering);
if (!deletionTime.isLive())
{
putDeletionInTrie(trie,
comparator.asByteComparable(clustering.asStartBound()),
comparator.asByteComparable(clustering.asEndBound()),
comparableClustering,
comparableClustering,
deletionTime);
}
if (!row.isEmptyAfterDeletion())
{
trie.apply(DeletionAwareTrie.<Object, TrieTombstoneMarker>singleton(comparator.asByteComparable(clustering),
trie.apply(DeletionAwareTrie.<Object, TrieTombstoneMarker>singleton(comparableClustering,
BYTE_COMPARABLE_VERSION,
rowToData(row)),
noConflictInData(),
Expand Down Expand Up @@ -499,6 +514,27 @@ public UnfilteredRowIterator unfilteredIterator()
return unfilteredIterator(ColumnFilter.selection(columns()), Slices.ALL, false);
}

public static Object combineDataAndDeletion(Object data, TrieTombstoneMarker deletion)
{
if (data == null || data instanceof PartitionMarker)
return deletion;

if (deletion == null || !deletion.hasPointData())
return data;

// This is a row combined with a point deletion.
RowData rowData = (RowData) data;
return rowData.toRow(Clustering.EMPTY, deletion.deletionTime());
}

private Clustering<?> getClustering(byte[] bytes, int byteLength)
{
return metadata.comparator.clusteringFromByteComparable(ByteBufferAccessor.instance,
ByteComparable.preencoded(BYTE_COMPARABLE_VERSION,
bytes, 0, byteLength),
BYTE_COMPARABLE_VERSION);
}

/// Implementation of [UnfilteredRowIterator] for this partition.
///
/// Currently, this implementation is pretty involved because it has to revert the transformations done to row and
Expand All @@ -522,7 +558,8 @@ protected UnfilteredIterator(ColumnFilter selection, DeletionAwareTrie<Object, T

private UnfilteredIterator(ColumnFilter selection, DeletionAwareTrie<Object, TrieTombstoneMarker> trie, boolean reversed, DeletionTime partitionLevelDeletion)
{
super(trie.mergedTrieSwitchable((x, y) -> x instanceof RowData ? x : y), Direction.fromBoolean(reversed));
super(trie.mergedTrieSwitchable(TrieBackedPartition::combineDataAndDeletion),
Direction.fromBoolean(reversed));
this.trie = trie;
this.selection = selection;
this.reversed = reversed;
Expand All @@ -536,11 +573,23 @@ protected Unfiltered mapContent(Object content, byte[] bytes, int byteLength)
{
if (content instanceof RowData)
return toRow((RowData) content,
metadata.comparator.clusteringFromByteComparable(ByteBufferAccessor.instance,
ByteComparable.preencoded(BYTE_COMPARABLE_VERSION,
bytes, 0, byteLength),
BYTE_COMPARABLE_VERSION)) // deletion is given as range tombstone
.filter(selection, metadata());
getClustering(bytes, byteLength)) // deletion is given as range tombstone
.filter(selection, metadata());
if (content instanceof Row)
{
BTreeRow row = (BTreeRow) content;
return BTreeRow.create(getClustering(bytes, byteLength),
row.primaryKeyLivenessInfo(),
row.deletion(),
row.getBTree(),
row.getMinLocalDeletionTime())
.filter(selection, metadata());
}

TrieTombstoneMarker marker = (TrieTombstoneMarker) content;
if (marker.hasPointData())
return BTreeRow.emptyDeletedRow(getClustering(bytes, byteLength),
Row.Deletion.regular(marker.deletionTime()));
else
return ((TrieTombstoneMarker) content).toRangeTombstoneMarker(
ByteComparable.preencoded(BYTE_COMPARABLE_VERSION, bytes, 0, byteLength),
Expand Down Expand Up @@ -576,7 +625,7 @@ public boolean isReverseOrder()
@Override
public RegularAndStaticColumns columns()
{
return columns;
return selection.fetchedColumns();
}

@Override
Expand Down Expand Up @@ -615,7 +664,7 @@ public UnfilteredRowIterator unfilteredIterator(ColumnFilter selection, ByteComp
return UnfilteredRowIterators.noRowsIterator(metadata, partitionKey, staticRow(), partitionLevelDeletion(), reversed);

DeletionAwareTrie<Object, TrieTombstoneMarker> slicedTrie = trie.intersect(TrieSet.ranges(BYTE_COMPARABLE_VERSION, bounds));
return new RecombiningUnfilteredRowIterator(new UnfilteredIterator(selection, slicedTrie, reversed));
return new UnfilteredIterator(selection, slicedTrie, reversed);
}

public UnfilteredRowIterator unfilteredIterator(ColumnFilter selection, Slices slices, boolean reversed)
Expand Down
Loading