You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2024/02/29 10:51:00 UTC
(lucene) 02/02: Deprecate ByteBufferIndexInput and detect MemorySegmentIndexInput correctly in NRTSuggester (#13145)
This is an automated email from the ASF dual-hosted git repository.
uschindler pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
commit fe7382b25378d9e4bb97f5b30423de834b499c7c
Author: Uwe Schindler <us...@apache.org>
AuthorDate: Thu Feb 29 11:49:04 2024 +0100
Deprecate ByteBufferIndexInput and detect MemorySegmentIndexInput correctly in NRTSuggester (#13145)
---
lucene/CHANGES.txt | 5 ++++-
.../src/java/org/apache/lucene/store/ByteBufferIndexInput.java | 6 ++++++
.../src/java/org/apache/lucene/store/ByteBuffersDirectory.java | 7 +++++++
.../org/apache/lucene/search/suggest/document/NRTSuggester.java | 5 ++++-
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 16a3714898e..be9033a6745 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -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
---------------------
diff --git a/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java b/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java
index 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
*/
+@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);
diff --git a/lucene/core/src/java/org/apache/lucene/store/ByteBuffersDirectory.java b/lucene/core/src/java/org/apache/lucene/store/ByteBuffersDirectory.java
index 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.
+ */
+ @Deprecated
public 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.java
index 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);
}