Apache Lucene open-source search software
Revert "Add `@SuppressAssertingFormats` annotation for fine-grained control over `AssertingCodec` formats (#15468)"
Dawid Weissa931b8a5d18f
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex dce771a04d6..6dda8cfa2e3 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -191,8 +191,6 @@ New Features* GITHUB#15415: Add fallback support to Lucene104ScalarQuantizedVectorsFormat getFloatVectorValues when there areno full-precision vectors present (Pulkit Gupta)- * GITHUB#15468: Add support for `@SuppressAssertingFormats` annotation for fine-grained control over `AssertingCodec` formats (Prudhvi Godithi)-Improvements---------------------* GITHUB#15148: Add support uint8 distance and allow 8 bit scalar quantization (Trevor McCulloch)diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/codecs/asserting/AssertingCodec.java b/lucene/test-framework/src/java/org/apache/lucene/tests/codecs/asserting/AssertingCodec.javaindex 7ff8d9ab4a9..0aded31855e 100644--- a/lucene/test-framework/src/java/org/apache/lucene/tests/codecs/asserting/AssertingCodec.java+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/codecs/asserting/AssertingCodec.java@@ -16,9 +16,6 @@*/package org.apache.lucene.tests.codecs.asserting;-import java.util.Collections;-import java.util.EnumSet;-import java.util.Set;import org.apache.lucene.codecs.DocValuesFormat;import org.apache.lucene.codecs.FilterCodec;import org.apache.lucene.codecs.KnnVectorsFormat;@@ -36,28 +33,6 @@ import org.apache.lucene.tests.util.TestUtil;/** Acts like the default codec but with additional asserts. */public class AssertingCodec extends FilterCodec {- /** Enum representing asserting format types that can be suppressed. */- public enum Format {- STORED_FIELDS,- TERM_VECTORS,- NORMS,- LIVE_DOCS,- POINTS,- KNN_VECTORS- }-- private static volatile Set<Format> suppressedFormats = Collections.emptySet();-- /** Set the formats to suppress. */- public static void setSuppressedFormats(Set<Format> formats) {- suppressedFormats =- formats == null || formats.isEmpty() ? Collections.emptySet() : EnumSet.copyOf(formats);- }-- private static boolean isSuppressed(Format format) {- return suppressedFormats.contains(format);- }-static void assertThread(String object, Thread creationThread) {if (creationThread != Thread.currentThread()) {throw new AssertionError(@@ -115,12 +90,12 @@ public class AssertingCodec extends FilterCodec {@Overridepublic TermVectorsFormat termVectorsFormat() {- return isSuppressed(Format.TERM_VECTORS) ? delegate.termVectorsFormat() : vectors;+ return vectors;}@Overridepublic StoredFieldsFormat storedFieldsFormat() {- return isSuppressed(Format.STORED_FIELDS) ? delegate.storedFieldsFormat() : storedFields;+ return storedFields;}@Override@@ -130,22 +105,22 @@ public class AssertingCodec extends FilterCodec {@Overridepublic NormsFormat normsFormat() {- return isSuppressed(Format.NORMS) ? delegate.normsFormat() : norms;+ return norms;}@Overridepublic LiveDocsFormat liveDocsFormat() {- return isSuppressed(Format.LIVE_DOCS) ? delegate.liveDocsFormat() : liveDocs;+ return liveDocs;}@Overridepublic PointsFormat pointsFormat() {- return isSuppressed(Format.POINTS) ? delegate.pointsFormat() : pointsFormat;+ return pointsFormat;}@Overridepublic KnnVectorsFormat knnVectorsFormat() {- return isSuppressed(Format.KNN_VECTORS) ? delegate.knnVectorsFormat() : knnVectorsFormat;+ return knnVectorsFormat;}@Overridediff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.javaindex f754ec67621..6c3ab79687e 100644--- a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java@@ -171,7 +171,6 @@ import org.apache.lucene.store.MergeInfo;import org.apache.lucene.store.NRTCachingDirectory;import org.apache.lucene.store.ReadOnceHint;import org.apache.lucene.tests.analysis.MockAnalyzer;-import org.apache.lucene.tests.codecs.asserting.AssertingCodec;import org.apache.lucene.tests.index.AlcoholicMergePolicy;import org.apache.lucene.tests.index.AssertingDirectoryReader;import org.apache.lucene.tests.index.AssertingLeafReader;@@ -351,18 +350,6 @@ public abstract class LuceneTestCase extends Assert {String[] value();}- /**- * Annotation for test classes that should avoid specific asserting formats within the Asserting- * codec (e.g., AssertingStoredFieldsFormat) while keeping other asserting formats active.- */- @Documented- @Inherited- @Retention(RetentionPolicy.RUNTIME)- @Target(ElementType.TYPE)- public @interface SuppressAssertingFormats {- AssertingCodec.Format[] value();- }-/*** Annotation for test classes that should avoid mock filesystem types (because they test a bug* that only happens on linux, for example).diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/util/TestRuleSetupAndRestoreClassEnv.java b/lucene/test-framework/src/java/org/apache/lucene/tests/util/TestRuleSetupAndRestoreClassEnv.javaindex f7b4fdc4819..e4c0625e7c5 100644--- a/lucene/test-framework/src/java/org/apache/lucene/tests/util/TestRuleSetupAndRestoreClassEnv.java+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/util/TestRuleSetupAndRestoreClassEnv.java@@ -31,7 +31,6 @@ import com.carrotsearch.randomizedtesting.RandomizedContext;import com.carrotsearch.randomizedtesting.generators.RandomPicks;import java.io.PrintStream;import java.util.Arrays;-import java.util.EnumSet;import java.util.HashSet;import java.util.Locale;import java.util.Random;@@ -52,7 +51,6 @@ import org.apache.lucene.tests.index.RandomCodec;import org.apache.lucene.tests.search.similarities.AssertingSimilarity;import org.apache.lucene.tests.search.similarities.RandomSimilarity;import org.apache.lucene.tests.util.LuceneTestCase.LiveIWCFlushMode;-import org.apache.lucene.tests.util.LuceneTestCase.SuppressAssertingFormats;import org.apache.lucene.tests.util.LuceneTestCase.SuppressCodecs;import org.apache.lucene.util.InfoStream;import org.apache.lucene.util.PrintStreamInfoStream;@@ -78,11 +76,6 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule {*/HashSet<String> avoidCodecs;- /**- * @see SuppressAssertingFormats- */- EnumSet<AssertingCodec.Format> avoidAssertingFormats;-static class ThreadNameFixingPrintStreamInfoStream extends PrintStreamInfoStream {public ThreadNameFixingPrintStreamInfoStream(PrintStream out) {super(out);@@ -134,13 +127,6 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule {avoidCodecs.addAll(Arrays.asList(a.value()));}- avoidAssertingFormats = EnumSet.noneOf(AssertingCodec.Format.class);- if (targetClass.isAnnotationPresent(SuppressAssertingFormats.class)) {- SuppressAssertingFormats a = targetClass.getAnnotation(SuppressAssertingFormats.class);- avoidAssertingFormats.addAll(Arrays.asList(a.value()));- }- AssertingCodec.setSuppressedFormats(avoidAssertingFormats);-savedCodec = Codec.getDefault();int randomVal = random.nextInt(11);if ("default".equals(TEST_CODEC)) {