Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ venv/
# build-scripts will put cassandra-builds into the directory
cassandra-builds/
cassandra-dtest/

.ai/
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Future version (tbd)
* Reduce size of per-SSTable index components for SAI (CASSANDRA-18673)
* Require only MODIFY permission on base when updating table with MV (STAR-564)
Merged from 5.1:
* Expose current compaction throughput in nodetool (CASSANDRA-13890)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,16 @@ public enum CassandraRelevantProperties
*/
SAI_MONITORING_EXECUTION_INFO_ENABLED("cassandra.sai.monitoring_execution_info_enabled", "true"),

/**
* Used to determine the block size and block mask for the clustering sorted terms.
*/
SAI_SORTED_TERMS_CLUSTERING_BLOCK_SHIFT("cassandra.sai.sorted_terms_clustering_block_shift", "4"),

/**
* Used to determine the block size and block mask for the partition sorted terms.
*/
SAI_SORTED_TERMS_PARTITION_BLOCK_SHIFT("cassandra.sai.sorted_terms_partition_block_shift", "4"),

/** Whether vector type only allows float vectors. True by default. **/
VECTOR_FLOAT_ONLY("cassandra.float_only_vectors", "true"),
/** Enables use of vector type. True by default. **/
Expand Down
5 changes: 5 additions & 0 deletions src/java/org/apache/cassandra/db/marshal/AbstractType.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ public <V> T compose(V value, ValueAccessor<V> accessor)
return getSerializer().deserialize(value, accessor);
}

public ByteBuffer decomposeUntyped(Object value)
{
return decompose((T) value);
}

public ByteBuffer decompose(T value)
{
return getSerializer().serialize(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public PrimaryKeyMap.Factory primaryKeyMapFactory()
*/
public int openFilesPerSSTable()
{
return perSSTableComponents.onDiskFormat().openFilesPerSSTable();
return perSSTableComponents.onDiskFormat().openFilesPerSSTable(sstable.hasClustering);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

Expand Down Expand Up @@ -265,7 +266,7 @@ public StorageAttachedIndexQueryPlan queryPlanFor(RowFilter rowFilter)
@Override
public SSTableFlushObserver getFlushObserver(Descriptor descriptor, LifecycleNewTracker tracker, TableMetadata tableMetadata, long keyCount)
{
IndexDescriptor indexDescriptor = IndexDescriptor.empty(descriptor);
IndexDescriptor indexDescriptor = IndexDescriptor.empty(descriptor, tableMetadata);
try
{
return new StorageAttachedIndexWriter(indexDescriptor, tableMetadata, indices, tracker, keyCount, baseCfs.metric);
Expand All @@ -290,7 +291,7 @@ public boolean handles(IndexTransaction.Type type)
@Override
public Set<Component> componentsForNewSSTable()
{
return IndexDescriptor.componentsForNewlyFlushedSSTable(indices, version);
return IndexDescriptor.componentsForNewlyFlushedSSTable(indices, version, baseCfs.metadata().comparator.size() > 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.google.common.base.Stopwatch;

import org.apache.cassandra.db.DecoratedKey;
import org.apache.cassandra.index.sai.utils.PrimaryKey;

/**
Expand All @@ -33,6 +34,9 @@ public interface PerSSTableWriter
default void startPartition(long position) throws IOException
{}

default void startPartition(DecoratedKey decoratedKey) throws IOException
{}

void nextRow(PrimaryKey primaryKey) throws IOException;

default void complete(Stopwatch stopwatch) throws IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ public void close() throws IOException

FileUtils.closeQuietly(postingList, primaryKeyMap);
}
else {
else
{
logger.warn("PostingListKeyRangeIterator is already closed",
new IllegalStateException("PostingListKeyRangeIterator is already closed"));
}

}

private boolean exhausted()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public interface PrimaryKeyMap extends Closeable
* A factory for creating {@link PrimaryKeyMap} instances. Implementations of this
* interface are expected to be threadsafe.
*/
public interface Factory extends Closeable
interface Factory extends Closeable
{
/**
* Creates a new {@link PrimaryKeyMap} instance
Expand Down Expand Up @@ -121,7 +121,7 @@ default PrimaryKey primaryKeyFromRowId(long sstableRowId, @Nonnull PrimaryKey lo
* @param key the {@link PrimaryKey} to lookup
* @return an sstable row id or a negative value if no row is found
*/
long ceiling(PrimaryKey key);
long ceiling(PrimaryKey key);

/**
* Returns the sstable row id associated with the greatest {@link PrimaryKey} less than or equal to the given
Expand All @@ -132,7 +132,7 @@ default PrimaryKey primaryKeyFromRowId(long sstableRowId, @Nonnull PrimaryKey lo
* @param key the {@link PrimaryKey} to lookup
* @return an sstable row id or a negative value if no row is found
*/
long floor(PrimaryKey key);
long floor(PrimaryKey key);

/**
* Returns the number of primary keys in the map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ public void startPartition(DecoratedKey key, long position)

try
{
// Implemented in v1
perSSTableWriter.startPartition(position);
// Implemented in v2
perSSTableWriter.startPartition(key);
}
catch (Throwable t)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.cassandra.io.sstable.Component;
import org.apache.cassandra.io.util.File;
import org.apache.cassandra.io.util.FileHandle;
import org.apache.cassandra.utils.Throwables;
import org.apache.lucene.store.ChecksumIndexInput;

public interface IndexComponent
Expand All @@ -50,10 +51,10 @@ interface ForRead extends IndexComponent
@Override
IndexComponents.ForRead parent();

FileHandle createFileHandle();
FileHandle createFileHandle(Throwables.DiscreteAction<?> cleanup);

/**
* Opens a file handle for the provided index component similarly to {@link #createFileHandle()},
* Opens a file handle for the provided index component similarly to {@link #createFileHandle(Throwables.DiscreteAction)},
* but this method shoud be called instead of the aforemented one if the access is done during index building, that is
* before the full index that this is a part of has been finalized.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,36 @@ public enum IndexComponentType
* V1
*/
OFFSETS_VALUES("OffsetsValues"),

/**
* An on-disk trie containing the primary keys used for looking up the rowId from a partition key
*
* V2
* An on-disk block-packed index containing the starting and ending rowIds for each partition.
*/
PRIMARY_KEY_TRIE("PrimaryKeyTrie"),
PARTITION_SIZES("PartitionSizes"),

/**
* Prefix-compressed blocks of primary keys used for rowId to partition key lookups
*
* Prefix-compressed blocks of partition keys used for rowId to partition key lookups
* <p>
* V2
*/
PRIMARY_KEY_BLOCKS("PrimaryKeyBlocks"),
PARTITION_KEY_BLOCKS("PartitionKeyBlocks"),

/**
* Encoded sequence of offsets to primary key blocks
*
* Encoded sequence of offsets to partition key blocks
* <p>
* V2
*/
PRIMARY_KEY_BLOCK_OFFSETS("PrimaryKeyBlockOffsets"),
PARTITION_KEY_BLOCK_OFFSETS("PartitionKeyBlockOffsets"),

/**
* Prefix-compressed blocks of clustering keys used for rowId to clustering key lookups
*/
CLUSTERING_KEY_BLOCKS("ClusteringKeyBlocks"),

/**
* Encoded sequence of offsets to clustering key blocks
*/
CLUSTERING_KEY_BLOCK_OFFSETS("ClusteringKeyBlockOffsets"),

/**
* Stores per-sstable metadata.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.slf4j.LoggerFactory;

import org.apache.cassandra.config.CassandraRelevantProperties;
import org.apache.cassandra.db.ClusteringComparator;
import org.apache.cassandra.db.lifecycle.Tracker;
import org.apache.cassandra.index.sai.IndexContext;
import org.apache.cassandra.io.sstable.Component;
Expand Down Expand Up @@ -183,9 +184,13 @@ default Set<IndexComponentType> expectedComponentsForVersion()
{
return isPerIndexGroup()
? onDiskFormat().perIndexComponentTypes(context())
: onDiskFormat().perSSTableComponentTypes();
: onDiskFormat().perSSTableComponentTypes(hasClustering());
}

boolean hasClustering();

ClusteringComparator comparator();

default ByteComparable.Version byteComparableVersionFor(IndexComponentType component)
{
return version().byteComparableVersionFor(component, descriptor().version);
Expand Down
Loading