Skip to content

Commit e1c587f

Browse files
ekaterinadimitrova2driftx
authored andcommitted
CNDB-13192: Bump the default cassandra.sai.latest.version from DC to EC so we support BM25 by default. (#1737)
We do not need to update JVECTOR_VERSION post CNDB-14301
1 parent 8474453 commit e1c587f

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

src/java/org/apache/cassandra/config/CassandraRelevantProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ public enum CassandraRelevantProperties
684684
SAI_ANN_USE_SYNTHETIC_SCORE("cassandra.sai.ann_use_synthetic_score", "false"),
685685

686686
/** The current version of the SAI on-disk index format. */
687-
SAI_CURRENT_VERSION("cassandra.sai.latest.version", "dc"),
687+
SAI_CURRENT_VERSION("cassandra.sai.latest.version", "ec"),
688688

689689
SAI_CUSTOM_COMPONENTS_DISCOVERY_CLASS("cassandra.sai.custom_components_discovery_class"),
690690
SAI_ENABLE_EDGES_CACHE("cassandra.sai.enable_edges_cache", "false"),

test/unit/org/apache/cassandra/index/sai/disk/v1/InvertedIndexSearcherTest.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import java.util.stream.Collectors;
2525

2626
import org.agrona.collections.Int2IntHashMap;
27+
import org.apache.cassandra.index.sai.*;
28+
import org.junit.Before;
2729
import org.junit.BeforeClass;
2830
import org.junit.Test;
2931

@@ -32,10 +34,6 @@
3234
import org.apache.cassandra.cql3.Operator;
3335
import org.apache.cassandra.db.marshal.UTF8Type;
3436
import org.apache.cassandra.dht.Murmur3Partitioner;
35-
import org.apache.cassandra.index.sai.IndexContext;
36-
import org.apache.cassandra.index.sai.QueryContext;
37-
import org.apache.cassandra.index.sai.SAITester;
38-
import org.apache.cassandra.index.sai.SSTableContext;
3937
import org.apache.cassandra.index.sai.disk.MemtableTermsIterator;
4038
import org.apache.cassandra.index.sai.disk.format.IndexComponents;
4139
import org.apache.cassandra.index.sai.disk.format.IndexDescriptor;
@@ -61,6 +59,8 @@ public class InvertedIndexSearcherTest extends SaiRandomizedTest
6159
// Use a shared index context to prevent creating too many metrics unnecessarily
6260
private final IndexContext indexContext = SAITester.createIndexContext("meh", UTF8Type.instance);
6361

62+
private final Version version;
63+
6464
@ParametersFactory()
6565
public static Collection<Object[]> data()
6666
{
@@ -70,7 +70,11 @@ public static Collection<Object[]> data()
7070
return Version.ALL.stream().map(v -> new Object[]{v}).collect(Collectors.toList());
7171
}
7272

73-
private final Version version;
73+
@Before
74+
public void setCurrentSAIVersion()
75+
{
76+
SAIUtil.setCurrentVersion(version);
77+
}
7478

7579
public InvertedIndexSearcherTest(Version version)
7680
{
@@ -214,7 +218,7 @@ private IndexSearcher buildIndexAndOpenSearcher(int terms, List<InvertedIndexBui
214218

215219
private List<InvertedIndexBuilder.TermsEnum> buildTermsEnum(Version version, int terms, int postings)
216220
{
217-
return InvertedIndexBuilder.buildStringTermsEnum(version, terms, postings, () -> randomSimpleString(3, 5), () -> nextInt(0, Integer.MAX_VALUE));
221+
return InvertedIndexBuilder.buildStringTermsEnum(version, terms, postings, () -> randomSimpleString(3, 5), () -> nextInt(0, terms * postings * 2));
218222
}
219223

220224
private Int2IntHashMap createMockDocLengths(List<InvertedIndexBuilder.TermsEnum> termsEnum)

test/unit/org/apache/cassandra/index/sai/disk/v1/TermsReaderTest.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.List;
2323
import java.util.stream.Collectors;
2424

25+
import org.junit.Before;
2526
import org.junit.Test;
2627

2728
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
@@ -31,6 +32,7 @@
3132
import org.apache.cassandra.index.sai.IndexContext;
3233
import org.apache.cassandra.index.sai.QueryContext;
3334
import org.apache.cassandra.index.sai.SAITester;
35+
import org.apache.cassandra.index.sai.SAIUtil;
3436
import org.apache.cassandra.index.sai.disk.MemtableTermsIterator;
3537
import org.apache.cassandra.index.sai.disk.PostingList;
3638
import org.apache.cassandra.index.sai.disk.TermsIterator;
@@ -56,6 +58,8 @@ public class TermsReaderTest extends SaiRandomizedTest
5658
{
5759
public static final ByteComparable.Version VERSION = TypeUtil.BYTE_COMPARABLE_VERSION;
5860

61+
private final Version version;
62+
5963
@ParametersFactory()
6064
public static Collection<Object[]> data()
6165
{
@@ -65,7 +69,11 @@ public static Collection<Object[]> data()
6569
return Version.ALL.stream().map(v -> new Object[]{v}).collect(Collectors.toList());
6670
}
6771

68-
private final Version version;
72+
@Before
73+
public void setCurrentSAIVersion()
74+
{
75+
SAIUtil.setCurrentVersion(version);
76+
}
6977

7078
public TermsReaderTest(Version version)
7179
{
@@ -232,6 +240,8 @@ private Int2IntHashMap createMockDocLengths(List<InvertedIndexBuilder.TermsEnum>
232240

233241
private List<InvertedIndexBuilder.TermsEnum> buildTermsEnum(Version version, int terms, int postings)
234242
{
235-
return buildStringTermsEnum(version, terms, postings, () -> randomSimpleString(4, 10), () -> nextInt(0, Integer.MAX_VALUE));
243+
// We use terms * postings * 2 as the upper bound on row ids used in the postings list to allow for a somewhat
244+
// sparse mapping but not one that is too sparse.
245+
return buildStringTermsEnum(version, terms, postings, () -> randomSimpleString(4, 10), () -> nextInt(0, terms * postings * 2));
236246
}
237247
}

0 commit comments

Comments
 (0)