This is an automated email from the ASF dual-hosted git repository. adelapena pushed a commit to branch cassandra-5.0 in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-5.0 by this push: new c4d11c4372 Fix VectorUpdateDeleteTest for JDK 17 Removed use of reflection and directly set relevant property to avoid jdk 17 errors c4d11c4372 is described below commit c4d11c4372906ae1dea9e6c31c1136f122e8a1b2 Author: Mike Adamson <madam...@datastax.com> AuthorDate: Mon Oct 30 09:46:52 2023 +0000 Fix VectorUpdateDeleteTest for JDK 17 Removed use of reflection and directly set relevant property to avoid jdk 17 errors patch by Mike Adamson; reviewed by Stefan Miklosovic, Michael Semb Wever and Andrés de la Peña for CASSANDRA-18715 --- .../cassandra/index/sai/plan/QueryController.java | 6 +++--- .../index/sai/cql/VectorUpdateDeleteTest.java | 21 ++++----------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/java/org/apache/cassandra/index/sai/plan/QueryController.java b/src/java/org/apache/cassandra/index/sai/plan/QueryController.java index 018785647a..61101cabf6 100644 --- a/src/java/org/apache/cassandra/index/sai/plan/QueryController.java +++ b/src/java/org/apache/cassandra/index/sai/plan/QueryController.java @@ -67,8 +67,6 @@ import static org.apache.cassandra.config.CassandraRelevantProperties.SAI_VECTOR public class QueryController { - public static final int ORDER_CHUNK_SIZE = SAI_VECTOR_SEARCH_ORDER_CHUNK_SIZE.getInt(); - private final ColumnFamilyStore cfs; private final ReadCommand command; private final QueryContext queryContext; @@ -79,6 +77,7 @@ public class QueryController private final PrimaryKey.Factory keyFactory; private final PrimaryKey firstPrimaryKey; private final PrimaryKey lastPrimaryKey; + private final int orderChunkSize; public QueryController(ColumnFamilyStore cfs, ReadCommand command, @@ -98,6 +97,7 @@ public class QueryController this.keyFactory = new PrimaryKey.Factory(cfs.getPartitioner(), cfs.getComparator()); this.firstPrimaryKey = keyFactory.create(mergeRange.left.getToken()); this.lastPrimaryKey = keyFactory.create(mergeRange.right.getToken()); + this.orderChunkSize = SAI_VECTOR_SEARCH_ORDER_CHUNK_SIZE.getInt(); } public PrimaryKey.Factory primaryKeyFactory() @@ -275,7 +275,7 @@ public class QueryController // This is a hybrid query. We apply all other predicates before ordering and limiting. public KeyRangeIterator getTopKRows(KeyRangeIterator source, RowFilter.Expression expression) { - return new KeyRangeOrderingIterator(source, ORDER_CHUNK_SIZE, list -> this.getTopKRows(list, expression)); + return new KeyRangeOrderingIterator(source, orderChunkSize, list -> this.getTopKRows(list, expression)); } private KeyRangeIterator getTopKRows(List<PrimaryKey> rawSourceKeys, RowFilter.Expression expression) diff --git a/test/unit/org/apache/cassandra/index/sai/cql/VectorUpdateDeleteTest.java b/test/unit/org/apache/cassandra/index/sai/cql/VectorUpdateDeleteTest.java index f2fa362b4e..20842e6184 100644 --- a/test/unit/org/apache/cassandra/index/sai/cql/VectorUpdateDeleteTest.java +++ b/test/unit/org/apache/cassandra/index/sai/cql/VectorUpdateDeleteTest.java @@ -18,14 +18,11 @@ package org.apache.cassandra.index.sai.cql; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - import org.apache.cassandra.cql3.UntypedResultSet; -import org.apache.cassandra.index.sai.plan.QueryController; import org.junit.Test; +import static org.apache.cassandra.config.CassandraRelevantProperties.SAI_VECTOR_SEARCH_ORDER_CHUNK_SIZE; import static org.apache.cassandra.index.sai.cql.VectorTypeTest.assertContainsInt; import static org.assertj.core.api.Assertions.assertThat; @@ -528,7 +525,7 @@ public class VectorUpdateDeleteTest extends VectorTester // We also query for different LIMITs for (int i = 1; i <= 100; i++) { - setChunkSize(i); + SAI_VECTOR_SEARCH_ORDER_CHUNK_SIZE.setInt(i); var results = execute("SELECT pk FROM %s WHERE str_val = 'A' ORDER BY vec ANN OF [1,1] LIMIT 1"); assertRows(results, row(1)); results = execute("SELECT pk FROM %s WHERE str_val = 'A' ORDER BY vec ANN OF [1,1] LIMIT 3"); @@ -543,19 +540,9 @@ public class VectorUpdateDeleteTest extends VectorTester finally { // Revert to prevent interference with other tests. Note that a decreased chunk size can impact - // wether we compute the topk with brute force because it determines how many vectors get sent to the + // whether we compute the topk with brute force because it determines how many vectors get sent to the // vector index. - setChunkSize(100000); + SAI_VECTOR_SEARCH_ORDER_CHUNK_SIZE.setInt(100000); } } - - private static void setChunkSize(final int selectivityLimit) throws Exception - { - Field selectivity = QueryController.class.getDeclaredField("ORDER_CHUNK_SIZE"); - selectivity.setAccessible(true); - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(selectivity, selectivity.getModifiers() & ~Modifier.FINAL); - selectivity.set(null, selectivityLimit); - } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org