Apache Lucene open-source search software
Deprecate ByteBufferIndexInput and detect MemorySegmentIndexInput correctly in NRTSuggester (#13145)
Uwe Schindlerfe7382b25378
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 16a3714898e..be9033a6745 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -182,7 +182,8 @@ OtherAPI Changes----------------------(No changes)++* GITHUB#13145: Deprecate ByteBufferIndexInput as it will be removed in Lucene 10.0. (Uwe Schindler)New Features---------------------@@ -213,6 +214,8 @@ Bug Fixes* GITHUB#13105: Fix ByteKnnVectorFieldSource & FloatKnnVectorFieldSource to work correctly when a segment does not containany docs with vectors (hossman)+* GITHUB#13145: Detect MemorySegmentIndexInput correctly in NRTSuggester. (Uwe Schindler)+Other---------------------diff --git a/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java b/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.javaindex 6d6040bd437..04c78a10242 100644--- a/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java+++ b/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java@@ -33,7 +33,13 @@ import java.nio.LongBuffer;** <p>For efficiency, this class requires that the buffers are a power-of-two (<code>chunkSizePower* </code>).+ *+ * @deprecated This class was made public for internal reasons ({@code instanceof} checks). In+ * {@link MMapDirectory} it was replaced by {@code MemorySegment} based {@link IndexInput}+ * implementations and will be no longer required in Lucene 10.+ * @lucene.internal*/+@Deprecatedpublic abstract class ByteBufferIndexInput extends IndexInput implements RandomAccessInput {private static final FloatBuffer EMPTY_FLOATBUFFER = FloatBuffer.allocate(0);private static final LongBuffer EMPTY_LONGBUFFER = LongBuffer.allocate(0);diff --git a/lucene/core/src/java/org/apache/lucene/store/ByteBuffersDirectory.java b/lucene/core/src/java/org/apache/lucene/store/ByteBuffersDirectory.javaindex 1b65ffa43b7..dbefd6a03cc 100644--- a/lucene/core/src/java/org/apache/lucene/store/ByteBuffersDirectory.java+++ b/lucene/core/src/java/org/apache/lucene/store/ByteBuffersDirectory.java@@ -82,6 +82,13 @@ public final class ByteBuffersDirectory extends BaseDirectory {public static final BiFunction<String, ByteBuffersDataOutput, IndexInput> OUTPUT_AS_BYTE_ARRAY =OUTPUT_AS_ONE_BUFFER;+ /**+ * Use {@link ByteBufferIndexInput} for reading, otherwise identical to {@link+ * #OUTPUT_AS_MANY_BUFFERS}.+ *+ * @deprecated Use {@link #OUTPUT_AS_MANY_BUFFERS} instead.+ */+ @Deprecatedpublic static final BiFunction<String, ByteBuffersDataOutput, IndexInput>OUTPUT_AS_MANY_BUFFERS_LUCENE =(fileName, output) -> {diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/NRTSuggester.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/NRTSuggester.javaindex f47ac040601..4f6936ee205 100644--- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/NRTSuggester.java+++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/NRTSuggester.java@@ -325,7 +325,10 @@ public final class NRTSuggester implements Accountable {case OFF_HEAP:return true;case AUTO:- return input instanceof ByteBufferIndexInput;+ // TODO: Make this less hacky to maybe expose "off-heap" feature using a marker interface on+ // the IndexInput+ return input instanceof ByteBufferIndexInput+ || input.getClass().getName().contains(".MemorySegmentIndexInput");default:throw new IllegalStateException("unknown enum constant: " + fstLoadMode);}