Deprecate ByteBufferIndexInput and detect MemorySegmentIndexInput correctly in NRTSuggester (#13145)

This commit is contained in:
Uwe Schindler 2024-02-29 11:49:04 +01:00
parent a356fc1e23
commit fe7382b253
4 changed files with 21 additions and 2 deletions

View File

@ -182,7 +182,8 @@ Other
API 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 contain
any docs with vectors (hossman)
* GITHUB#13145: Detect MemorySegmentIndexInput correctly in NRTSuggester. (Uwe Schindler)
Other
---------------------

View File

@ -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
*/
@Deprecated
public 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);

View File

@ -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.
*/
@Deprecated
public static final BiFunction<String, ByteBuffersDataOutput, IndexInput>
OUTPUT_AS_MANY_BUFFERS_LUCENE =
(fileName, output) -> {

View File

@ -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);
}