Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ public enum CassandraRelevantProperties
/** what class to use for mbean registeration */
MBEAN_REGISTRATION_CLASS("org.apache.cassandra.mbean_registration_class"),

/** Size limit for in-memory tries. This determines when the trie will report that it is full to trigger a flush. */
MEMTABLE_TRIE_SIZE_LIMIT("cassandra.trie_size_limit_mb"),
/** To be used for tests: whether trie cursors should be verified for correctness. */
TRIE_DEBUG("cassandra.debug_tries"),

/** This property indicates if the code is running under the in-jvm dtest framework */
DTEST_IS_IN_JVM_DTEST("org.apache.cassandra.dtest.is_in_jvm_dtest"),
Expand Down
25 changes: 25 additions & 0 deletions src/java/org/apache/cassandra/db/IDataSize.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.cassandra.db;

/// Shared interface for providing data size information
public interface IDataSize
{
int dataSize();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@

package org.apache.cassandra.db.memtable;

import java.util.function.Consumer;

import org.apache.cassandra.db.DataRange;
import org.apache.cassandra.db.IDataSize;
import org.apache.cassandra.db.filter.ColumnFilter;
import org.apache.cassandra.db.rows.Row;
import org.apache.cassandra.db.rows.Unfiltered;
import org.apache.cassandra.db.rows.UnfilteredRowIterator;
import org.apache.cassandra.db.tries.Trie;

class MemtableAverageRowSize
{
Expand All @@ -31,6 +35,35 @@ class MemtableAverageRowSize
public final long rowSize;
public final long operations;

public MemtableAverageRowSize(Memtable memtable, Trie<?> trie)
{
// If this is a trie-based memtable, get the row sizes from the trie elements. This achieves two things:
// - makes sure the size used is the size reflected in the memtable's dataSize
// (which e.g. excludes clustering keys)
// - avoids the conversion to Row, which has non-trivial cost

class SizeCalculator implements Trie.ValueConsumer<Object>
{
long totalSize = 0;
long count = 0;

@Override
public void accept(Object o)
{
if (o instanceof IDataSize)
{
totalSize += ((IDataSize) o).dataSize();
++count;
}
}
}

SizeCalculator sizeCalculator = new SizeCalculator();
trie.forEachValue(sizeCalculator);

this.rowSize = sizeCalculator.count > 0 ? sizeCalculator.totalSize / sizeCalculator.count : 0;
this.operations = memtable.getOperations();
}

public MemtableAverageRowSize(Memtable memtable)
{
Expand Down
Loading