You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2025/12/09 08:56:20 UTC

(lucene) branch branch_10x updated: Revert "Add `@SuppressAssertingFormats` annotation for fine-grained control over `AssertingCodec` formats (#15468)"

This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_10x by this push:
     new ba8a0db42dc Revert "Add `@SuppressAssertingFormats` annotation for fine-grained control over `AssertingCodec` formats (#15468)"
ba8a0db42dc is described below

commit ba8a0db42dc89119674d4b90ce2b62967574d2eb
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Tue Dec 9 09:56:09 2025 +0100

    Revert "Add `@SuppressAssertingFormats` annotation for fine-grained control over `AssertingCodec` formats (#15468)"
    
    This reverts commit 2e1e50a351a29f021dadf006f74b49fe44162550.
---
 lucene/CHANGES.txt                                 |  2 --
 .../tests/codecs/asserting/AssertingCodec.java     | 37 ++++------------------
 .../apache/lucene/tests/util/LuceneTestCase.java   | 13 --------
 .../util/TestRuleSetupAndRestoreClassEnv.java      | 14 --------
 4 files changed, 6 insertions(+), 60 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 5c2a6e9ca31..1e97a661cbd 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -59,8 +59,6 @@ New Features
  * GITHUB#15415: Add fallback support to Lucene104ScalarQuantizedVectorsFormat getFloatVectorValues when there are
    no 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.java
index 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 {
 
   @Override
   public TermVectorsFormat termVectorsFormat() {
-    return isSuppressed(Format.TERM_VECTORS) ? delegate.termVectorsFormat() : vectors;
+    return vectors;
   }
 
   @Override
   public StoredFieldsFormat storedFieldsFormat() {
-    return isSuppressed(Format.STORED_FIELDS) ? delegate.storedFieldsFormat() : storedFields;
+    return storedFields;
   }
 
   @Override
@@ -130,22 +105,22 @@ public class AssertingCodec extends FilterCodec {
 
   @Override
   public NormsFormat normsFormat() {
-    return isSuppressed(Format.NORMS) ? delegate.normsFormat() : norms;
+    return norms;
   }
 
   @Override
   public LiveDocsFormat liveDocsFormat() {
-    return isSuppressed(Format.LIVE_DOCS) ? delegate.liveDocsFormat() : liveDocs;
+    return liveDocs;
   }
 
   @Override
   public PointsFormat pointsFormat() {
-    return isSuppressed(Format.POINTS) ? delegate.pointsFormat() : pointsFormat;
+    return pointsFormat;
   }
 
   @Override
   public KnnVectorsFormat knnVectorsFormat() {
-    return isSuppressed(Format.KNN_VECTORS) ? delegate.knnVectorsFormat() : knnVectorsFormat;
+    return knnVectorsFormat;
   }
 
   @Override
diff --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.java
index 535bc590ee3..95f16bc4f56 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
@@ -177,7 +177,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;
@@ -342,18 +341,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.java
index 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)) {