From c8018b220d17f1bead1fe595b33e870e9eabd4c9 Mon Sep 17 00:00:00 2001 From: Luca Cavanna Date: Mon, 2 Dec 2024 10:24:56 +0100 Subject: [PATCH] Make SegmentInfos#readCommit(Directory, String, int) public (#14027) The corresponding readLatestCommit method is public and can be used to read segment infos from indices that are older than N - 1. The same should be possible for readCommit, but that requires the method that takes the minimum supported version as an argument to be public. --- lucene/CHANGES.txt | 2 ++ .../java/org/apache/lucene/index/SegmentInfos.java | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 09827bef219e..8ccf456f16a1 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -106,6 +106,8 @@ Bug Fixes * GITHUB#13990: Added filter to the toString() method of Knn[Float|Byte]VectorQuery and DiversifyingChildren[Float|Byte]KnnVectorQuery. (Viswanath Kuchibhotla) +* GITHUB#14027: Make SegmentInfos#readCommit(Directory, String, int) public + Build --------------------- diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java index f047e795dd42..36c6b76896c9 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java +++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java @@ -284,7 +284,14 @@ public static final SegmentInfos readCommit(Directory directory, String segmentF return readCommit(directory, segmentFileName, Version.MIN_SUPPORTED_MAJOR); } - static final SegmentInfos readCommit( + /** + * Read a particular segmentFileName, as long as the commit's {@link + * SegmentInfos#getIndexCreatedVersionMajor()} is strictly greater than the provided minimum + * supported major version. If the commit's version is older, an {@link + * IndexFormatTooOldException} will be thrown. Note that this may throw an IOException if a commit + * is in process. + */ + public static final SegmentInfos readCommit( Directory directory, String segmentFileName, int minSupportedMajorVersion) throws IOException { @@ -307,7 +314,7 @@ public static final SegmentInfos readCommit( } /** Read the commit from the provided {@link ChecksumIndexInput}. */ - static final SegmentInfos readCommit( + public static final SegmentInfos readCommit( Directory directory, ChecksumIndexInput input, long generation, int minSupportedMajorVersion) throws IOException { Throwable priorE = null;