This is an automated email from the ASF dual-hosted git repository. mck pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 87ce597ad01a8a6eb8540aa49ac08c5ea49be258 Merge: d464c206e1 0e42b77c97 Author: Mick Semb Wever <m...@apache.org> AuthorDate: Sat Nov 25 10:03:48 2023 +0100 Merge branch 'cassandra-5.0' into trunk * cassandra-5.0: Improve code model around IndexContext CHANGES.txt | 1 + .../apache/cassandra/index/sai/IndexContext.java | 588 -------------- .../apache/cassandra/index/sai/SSTableContext.java | 4 +- .../cassandra/index/sai/StorageAttachedIndex.java | 709 +++++++++++------ .../index/sai/StorageAttachedIndexBuilder.java | 4 +- .../sai/StorageAttachedIndexBuildingSupport.java | 72 ++ .../index/sai/StorageAttachedIndexGroup.java | 22 +- .../index/sai/analyzer/AbstractAnalyzer.java | 13 +- .../cassandra/index/sai/analyzer/NoOpAnalyzer.java | 66 -- .../index/sai/analyzer/NonTokenizingAnalyzer.java | 24 +- .../index/sai/disk/IndexSearchResultIterator.java | 8 +- .../cassandra/index/sai/disk/SSTableIndex.java | 41 +- .../index/sai/disk/format/IndexDescriptor.java | 108 ++- .../index/sai/disk/format/OnDiskFormat.java | 30 +- .../cassandra/index/sai/disk/format/Version.java | 20 +- .../sai/disk/v1/ColumnCompletionMarkerUtil.java | 14 +- .../index/sai/disk/v1/IndexWriterConfig.java | 8 +- .../index/sai/disk/v1/MemtableIndexWriter.java | 62 +- .../index/sai/disk/v1/MetadataSource.java | 6 +- .../index/sai/disk/v1/PerColumnIndexFiles.java | 15 +- .../index/sai/disk/v1/SSTableIndexWriter.java | 98 ++- .../index/sai/disk/v1/V1OnDiskFormat.java | 44 +- .../index/sai/disk/v1/V1SSTableIndex.java | 25 +- .../disk/v1/bbtree/BlockBalancedTreeIterator.java | 7 +- .../v1/bbtree/BlockBalancedTreePostingsWriter.java | 9 +- .../disk/v1/bbtree/BlockBalancedTreeQueries.java | 23 +- .../disk/v1/bbtree/BlockBalancedTreeReader.java | 14 +- .../sai/disk/v1/bbtree/NumericIndexWriter.java | 30 +- .../disk/v1/postings/PostingListRangeIterator.java | 16 +- .../index/sai/disk/v1/postings/PostingsWriter.java | 10 +- .../sai/disk/v1/segment/IndexSegmentSearcher.java | 22 +- .../v1/segment/LiteralIndexSegmentSearcher.java | 25 +- .../v1/segment/LiteralIndexSegmentTermsReader.java | 10 +- .../v1/segment/NumericIndexSegmentSearcher.java | 22 +- .../index/sai/disk/v1/segment/Segment.java | 8 +- .../index/sai/disk/v1/segment/SegmentBuilder.java | 63 +- .../v1/segment/VectorIndexSegmentSearcher.java | 25 +- .../index/sai/disk/v1/trie/LiteralIndexWriter.java | 16 +- .../disk/v1/trie/TrieTermsDictionaryWriter.java | 8 +- .../sai/disk/v1/vector/CheckpointingIterator.java | 101 --- .../index/sai/disk/v1/vector/DiskAnn.java | 6 +- .../index/sai/disk/v1/vector/OnHeapGraph.java | 10 +- .../cassandra/index/sai/memory/MemoryIndex.java | 11 +- .../cassandra/index/sai/memory/MemtableIndex.java | 31 +- .../index/sai/memory/MemtableIndexManager.java | 24 +- .../index/sai/memory/TrieMemoryIndex.java | 133 ++-- .../index/sai/memory/VectorMemoryIndex.java | 40 +- .../index/sai/metrics/AbstractMetrics.java | 6 + .../index/sai/metrics/ColumnQueryMetrics.java | 14 +- .../cassandra/index/sai/metrics/IndexMetrics.java | 13 +- .../cassandra/index/sai/plan/Expression.java | 272 +++++-- .../cassandra/index/sai/plan/FilterTree.java | 12 +- .../apache/cassandra/index/sai/plan/Operation.java | 160 +++- .../cassandra/index/sai/plan/QueryController.java | 43 +- .../cassandra/index/sai/plan/QueryViewBuilder.java | 8 +- .../sai/plan/StorageAttachedIndexQueryPlan.java | 31 +- .../sai/plan/StorageAttachedIndexSearcher.java | 13 +- .../index/sai/plan/VectorTopKProcessor.java | 26 +- .../cassandra/index/sai/utils/IndexIdentifier.java | 81 ++ .../cassandra/index/sai/utils/IndexTermType.java | 868 +++++++++++++++++++++ .../apache/cassandra/index/sai/utils/TypeUtil.java | 522 ------------- .../cassandra/index/sai/view/IndexViewManager.java | 81 +- .../cassandra/index/sai/view/RangeTermTree.java | 51 +- .../org/apache/cassandra/index/sai/view/View.java | 13 +- .../index/sai/virtual/ColumnIndexesSystemView.java | 17 +- .../sai/virtual/SSTableIndexesSystemView.java | 15 +- .../index/sai/virtual/SegmentsSystemView.java | 15 +- .../test/sai/IndexStreamingFailureTest.java | 17 +- .../test/microbench/sai/KeyLookupBench.java | 3 +- .../org/apache/cassandra/index/sai/SAITester.java | 156 ++-- .../sai/analyzer/NonTokenizingAnalyzerTest.java | 3 +- .../index/sai/cql/StorageAttachedIndexDDLTest.java | 245 +++--- .../index/sai/cql/UnindexedExpressionsTest.java | 106 +++ .../cassandra/index/sai/cql/types/DataSet.java | 8 +- .../sai/cql/types/NumericTypeSortingTest.java | 18 +- .../cassandra/index/sai/disk/NodeStartupTest.java | 28 +- .../index/sai/disk/format/IndexDescriptorTest.java | 9 +- .../index/sai/disk/format/VersionTest.java | 2 +- .../sai/disk/v1/BalancedTreeIndexSearcherTest.java | 40 +- .../sai/disk/v1/InvertedIndexSearcherTest.java | 42 +- .../cassandra/index/sai/disk/v1/MetadataTest.java | 23 +- .../index/sai/disk/v1/SegmentFlushTest.java | 32 +- .../cassandra/index/sai/disk/v1/SegmentTest.java | 2 +- .../index/sai/disk/v1/TermsReaderTest.java | 30 +- .../v1/bbtree/BlockBalancedTreeIndexBuilder.java | 48 +- .../BlockBalancedTreePostingsWriterTest.java | 27 +- .../v1/bbtree/BlockBalancedTreeQueriesTest.java | 5 +- .../v1/bbtree/BlockBalancedTreeRamBufferTest.java | 6 +- .../v1/bbtree/BlockBalancedTreeReaderTest.java | 16 +- .../sai/disk/v1/bbtree/NumericIndexWriterTest.java | 30 +- .../index/sai/disk/v1/postings/PostingsTest.java | 45 +- .../sai/disk/v1/trie/TrieTermsDictionaryTest.java | 21 +- .../index/sai/functional/CompactionTest.java | 34 +- .../index/sai/functional/FailureTest.java | 27 +- .../index/sai/functional/FlushingTest.java | 18 +- .../index/sai/functional/GroupComponentsTest.java | 11 +- .../index/sai/functional/NodeRestartTest.java | 22 +- .../index/sai/functional/SnapshotTest.java | 25 +- .../index/sai/memory/TrieMemoryIndexTest.java | 29 +- .../index/sai/memory/VectorMemoryIndexTest.java | 22 +- .../index/sai/metrics/IndexGroupMetricsTest.java | 7 +- .../cassandra/index/sai/plan/ExpressionTest.java | 12 +- .../cassandra/index/sai/plan/OperationTest.java | 111 +-- .../index/sai/utils/AbstractPrimaryKeyTester.java | 2 +- .../{TypeUtilTest.java => IndexTermTypeTest.java} | 144 ++-- .../index/sai/virtual/IndexesSystemViewTest.java | 4 +- .../index/sai/virtual/SSTablesSystemViewTest.java | 2 +- .../index/sai/virtual/SegmentsSystemViewTest.java | 22 +- 108 files changed, 3366 insertions(+), 2995 deletions(-) diff --cc CHANGES.txt index 0271f1f87f,dc0bfeb9d5..b3e6ab1d1a --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,9 -1,5 +1,10 @@@ -5.0-beta1 +5.1 + * Transactional Cluster Metadata [CEP-21] (CASSANDRA-18330) + * Add ELAPSED command to cqlsh (CASSANDRA-18861) + * Add the ability to disable bulk loading of SSTables (CASSANDRA-18781) + * Clean up obsolete functions and simplify cql_version handling in cqlsh (CASSANDRA-18787) +Merged from 5.0: + * Improve SAI IndexContext handling of indexed and non-indexed columns in queries (CASSANDRA-18166) * Fixed bug where UnifiedCompactionTask constructor was calling the wrong base constructor of CompactionTask (CASSANDRA-18757) * Fix SAI unindexed contexts not considering CONTAINS KEY (CASSANDRA-19040) * Ensure that empty SAI column indexes do not fail on validation after full-SSTable streaming (CASSANDRA-19017) diff --cc src/java/org/apache/cassandra/index/sai/virtual/ColumnIndexesSystemView.java index d0d6ac2f68,2d2e5e2634..b59c6720fd --- a/src/java/org/apache/cassandra/index/sai/virtual/ColumnIndexesSystemView.java +++ b/src/java/org/apache/cassandra/index/sai/virtual/ColumnIndexesSystemView.java @@@ -27,12 -27,9 +27,10 @@@ import org.apache.cassandra.db.virtual. import org.apache.cassandra.db.virtual.VirtualTable; import org.apache.cassandra.dht.LocalPartitioner; import org.apache.cassandra.exceptions.InvalidRequestException; - import org.apache.cassandra.index.Index; import org.apache.cassandra.index.SecondaryIndexManager; - import org.apache.cassandra.index.sai.IndexContext; import org.apache.cassandra.index.sai.StorageAttachedIndex; import org.apache.cassandra.index.sai.StorageAttachedIndexGroup; +import org.apache.cassandra.schema.KeyspaceMetadata; import org.apache.cassandra.schema.Schema; import org.apache.cassandra.schema.TableMetadata; @@@ -93,19 -90,18 +91,18 @@@ public class ColumnIndexesSystemView ex if (group != null) { - for (Index index : group.getIndexes()) - { - IndexContext context = ((StorageAttachedIndex) index).getIndexContext(); - String indexName = context.getIndexName(); + group.getIndexes().forEach(i -> { + StorageAttachedIndex index = (StorageAttachedIndex) i; + String indexName = index.identifier().indexName; - dataset.row(ks, indexName) + dataset.row(ks.name, indexName) .column(TABLE_NAME, cfs.name) - .column(COLUMN_NAME, context.getColumnName()) + .column(COLUMN_NAME, index.termType().columnName()) .column(IS_QUERYABLE, manager.isIndexQueryable(index)) .column(IS_BUILDING, manager.isIndexBuilding(indexName)) - .column(IS_STRING, context.isLiteral()) - .column(ANALYZER, context.getAnalyzerFactory().toString()); - } + .column(IS_STRING, index.termType().isLiteral()) + .column(ANALYZER, index.hasAnalyzer() ? index.analyzer().toString() : "NoOpAnalyzer"); + }); } } } diff --cc src/java/org/apache/cassandra/index/sai/virtual/SSTableIndexesSystemView.java index 4692fba878,7bc5426195..fd6f0cd4cc --- a/src/java/org/apache/cassandra/index/sai/virtual/SSTableIndexesSystemView.java +++ b/src/java/org/apache/cassandra/index/sai/virtual/SSTableIndexesSystemView.java @@@ -110,9 -106,9 +107,9 @@@ public class SSTableIndexesSystemView e Descriptor descriptor = sstable.descriptor; AbstractBounds<Token> bounds = sstable.getBounds(); - dataset.row(ks.name, indexContext.getIndexName(), sstable.getFilename()) - dataset.row(ks, index.identifier().indexName, sstable.getFilename()) ++ dataset.row(ks.name, index.identifier().indexName, sstable.getFilename()) .column(TABLE_NAME, descriptor.cfname) - .column(COLUMN_NAME, indexContext.getColumnName()) + .column(COLUMN_NAME, index.termType().columnName()) .column(FORMAT_VERSION, sstableIndex.getVersion().toString()) .column(CELL_COUNT, sstableIndex.getRowCount()) .column(MIN_ROW_ID, sstableIndex.minSSTableRowId()) diff --cc src/java/org/apache/cassandra/index/sai/virtual/SegmentsSystemView.java index b4ee2a8972,d3206f1766..721b28af35 --- a/src/java/org/apache/cassandra/index/sai/virtual/SegmentsSystemView.java +++ b/src/java/org/apache/cassandra/index/sai/virtual/SegmentsSystemView.java @@@ -100,11 -97,11 +98,11 @@@ public class SegmentsSystemView extend return dataset; } - private void forEachIndex(Consumer<IndexContext> process) + private void forEachIndex(Consumer<StorageAttachedIndex> process) { - for (String ks : Schema.instance.getUserKeyspaces()) + for (KeyspaceMetadata ks : Schema.instance.getUserKeyspaces()) { - Keyspace keyspace = Schema.instance.getKeyspaceInstance(ks); + Keyspace keyspace = Schema.instance.getKeyspaceInstance(ks.name); if (keyspace == null) throw new IllegalStateException("Unknown keyspace " + ks + ". This can occur if the keyspace is being dropped."); diff --cc test/unit/org/apache/cassandra/index/sai/memory/VectorMemoryIndexTest.java index c6d26c976f,5ed06b0a69..b29f72017c --- a/test/unit/org/apache/cassandra/index/sai/memory/VectorMemoryIndexTest.java +++ b/test/unit/org/apache/cassandra/index/sai/memory/VectorMemoryIndexTest.java @@@ -58,21 -56,18 +57,18 @@@ import org.apache.cassandra.dht.Excludi import org.apache.cassandra.dht.IPartitioner; import org.apache.cassandra.dht.IncludingExcludingBounds; import org.apache.cassandra.dht.Range; - import org.apache.cassandra.index.sai.IndexContext; import org.apache.cassandra.index.sai.QueryContext; import org.apache.cassandra.index.sai.SAITester; + import org.apache.cassandra.index.sai.StorageAttachedIndex; +import org.apache.cassandra.index.sai.disk.format.Version; import org.apache.cassandra.index.sai.iterators.KeyRangeIterator; import org.apache.cassandra.index.sai.plan.Expression; import org.apache.cassandra.index.sai.utils.PrimaryKey; import org.apache.cassandra.index.sai.utils.RangeUtil; import org.apache.cassandra.inject.Injections; import org.apache.cassandra.inject.InvokePointBuilder; - //import org.apache.cassandra.locator.TokenMetadata; - import org.apache.cassandra.schema.MockSchema; -import org.apache.cassandra.locator.TokenMetadata; import org.apache.cassandra.schema.TableMetadata; - //import org.apache.cassandra.service.StorageService; -import org.apache.cassandra.service.StorageService; +import org.apache.cassandra.tcm.ClusterMetadata; import org.apache.cassandra.utils.FBUtilities; import static org.apache.cassandra.config.CassandraRelevantProperties.MEMTABLE_SHARD_COUNT; @@@ -114,14 -100,13 +110,10 @@@ public class VectorMemoryIndexTest exte @Before public void setup() throws Throwable { - TableMetadata tableMetadata = TableMetadata.builder("ks", "tb") - .addPartitionKeyColumn("pk", Int32Type.instance) - .addRegularColumn("val", Int32Type.instance) - .build(); - cfs = MockSchema.newCFS(tableMetadata); - partitioner = cfs.getPartitioner(); - TokenMetadata metadata = StorageService.instance.getTokenMetadata(); - metadata.updateNormalTokens(BootStrapper.getRandomTokens(metadata, 10), FBUtilities.getBroadcastAddressAndPort()); - dimensionCount = getRandom().nextIntBetween(2, 2048); - indexContext = SAITester.createIndexContext("index", VectorType.getInstance(FloatType.instance, dimensionCount)); + index = SAITester.createMockIndex("index", VectorType.getInstance(FloatType.instance, dimensionCount)); + cfs = index.baseCfs(); + partitioner = cfs.getPartitioner(); indexSearchCounter.reset(); keyMap = new TreeMap<>(); rowMap = new HashMap<>(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org