Skip to content

Commit

Permalink
Fix compatibility with Solr 9.4 and Lucene 9.8
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaiter committed Jan 16, 2024
1 parent b04b000 commit 858de86
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
2 changes: 1 addition & 1 deletion integration-tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SOLR_HOST="${SOLR_HOST:-localhost}"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
SOLR7_VERSIONS="7.7 7.6 7.5"
SOLR8_VERSIONS="8.11 8.10 8.9 8.8 8.7 8.6 8.5 8.4 8.3 8.2 8.1 8.0"
SOLR9_VERSIONS="9.2 9.1 9.0"
SOLR9_VERSIONS="9.4 9.3 9.2 9.1 9.0"
SOLR78_PLUGIN_PATH=/tmp/solrocr-solr78

wait_for_solr() {
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
<version.junit>5.10.1</version.junit>
<version.mockito>5.8.0</version.mockito>
<version.slf4j>2.0.2</version.slf4j>
<version.solr>9.2.1</version.solr>
<version.lucene>9.4.2</version.lucene>
<version.solr>9.4.0</version.solr>
<version.lucene>9.8.0</version.lucene>
<!-- DO NOT UPDATE THIS, this is the latest version that works with Java 8 -->
<version.fmt-maven-plugin>2.9.1</version.fmt-maven-plugin>
<version.maven-gpg-plugin>3.1.0</version.maven-gpg-plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import org.apache.lucene.index.MultiReader;
import org.apache.lucene.index.ReaderUtil;
import org.apache.lucene.index.StoredFieldVisitor;
import org.apache.lucene.index.StoredFields;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermVectors;

/**
* Base class for implementing {@link CompositeReader}s based on an array of sub-readers. The
Expand All @@ -48,8 +50,8 @@
* synchronization, you should <b>not</b> synchronize on the <code>IndexReader</code> instance; use
* your own (non-Lucene) objects instead.
*
* <p><b>NOTE:</b> This is a backport from Lucene 8.8 since the API changed with v8.9, but we still
* want to support earlier versions.
* <p><b>NOTE:</b> This is a backport from Lucene 9.8 since the API changed with v8.9 and 9.8, but
* we still want to support earlier versions.
*
* @see MultiReader
* @lucene.internal
Expand All @@ -74,7 +76,7 @@ public abstract class LegacyBaseCompositeReader<R extends IndexReader> extends C
* methods. <b>Please note:</b> This array is <b>not</b> cloned and not protected for
* modification, the subclass is responsible to do this.
*/
protected LegacyBaseCompositeReader(R[] subReaders) throws IOException {
protected LegacyBaseCompositeReader(R[] subReaders) {
this.subReaders = subReaders;
this.subReadersList = Collections.unmodifiableList(Arrays.asList(subReaders));
starts = new int[subReaders.length + 1]; // build starts array
Expand All @@ -97,6 +99,40 @@ public final Fields getTermVectors(int docID) throws IOException {
return subReaders[i].getTermVectors(docID - starts[i]); // dispatch to subreader
}

@Override
public final TermVectors termVectors() throws IOException {
ensureOpen();
TermVectors[] subVectors = new TermVectors[subReaders.length];
return new TermVectors() {
@Override
public Fields get(int docID) throws IOException {
final int i = readerIndex(docID); // find subreader num
// dispatch to subreader, reusing if possible
if (subVectors[i] == null) {
subVectors[i] = subReaders[i].termVectors();
}
return subVectors[i].get(docID - starts[i]);
}
};
}

@Override
public final StoredFields storedFields() throws IOException {
ensureOpen();
StoredFields[] subFields = new StoredFields[subReaders.length];
return new StoredFields() {
@Override
public void document(int docID, StoredFieldVisitor visitor) throws IOException {
final int i = readerIndex(docID); // find subreader num
// dispatch to subreader, reusing if possible
if (subFields[i] == null) {
subFields[i] = subReaders[i].storedFields();
}
subFields[i].document(docID - starts[i], visitor);
}
};
}

@Override
public final int numDocs() {
// Don't call ensureOpen() here (it could affect performance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public boolean shouldExit() {
return timeoutAt - System.nanoTime() < 0L;
}

@Override
public boolean isTimeoutEnabled() {
return get() != null;
}
Expand Down

0 comments on commit 858de86

Please sign in to comment.