Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
34f2f34
Add codecs for lucene 8x
drempapis Jan 2, 2025
a867385
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 2, 2025
69b6b6e
Add Lucene80 Codec support
drempapis Jan 2, 2025
81c9fce
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 2, 2025
30e2cb4
Add wrapped lucene 84 codec
drempapis Jan 2, 2025
000a7aa
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 3, 2025
2c53ff6
apply spot
drempapis Jan 3, 2025
d3f18a5
Add comment
drempapis Jan 3, 2025
b3afec7
Update doc
drempapis Jan 3, 2025
5fef3eb
Add doc
drempapis Jan 3, 2025
1596495
update doc
drempapis Jan 3, 2025
1ec0501
update doc
drempapis Jan 3, 2025
394dae3
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 3, 2025
a279780
Update docs/changelog/119503.yaml
drempapis Jan 3, 2025
ecb162d
update doc
drempapis Jan 3, 2025
2448af7
Merge branch 'fix/117042_Support_7x_segments_as_archive_in_8x' of git…
drempapis Jan 3, 2025
9d9b6af
unmute tests
drempapis Jan 3, 2025
02ddf82
revert
drempapis Jan 3, 2025
bf79ef3
Merge remote-tracking branch 'upstream/main'
drempapis Jan 3, 2025
590091c
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 7, 2025
528f220
Update docs/changelog/119503.yaml
drempapis Jan 7, 2025
f1c91bd
Merge remote-tracking branch 'upstream/main'
drempapis Jan 7, 2025
ba67bff
Merge remote-tracking branch 'upstream/main'
drempapis Jan 7, 2025
6d1c65a
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 8, 2025
2c3654a
Merge remote-tracking branch 'upstream/main'
drempapis Jan 8, 2025
58d4762
Merge remote-tracking branch 'upstream/main'
drempapis Jan 8, 2025
bc38090
Merge remote-tracking branch 'upstream/main'
drempapis Jan 9, 2025
87f790f
Update after review
drempapis Jan 9, 2025
4334bc4
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 9, 2025
ef0447b
Merge remote-tracking branch 'upstream/main'
drempapis Jan 9, 2025
a7a8a84
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 9, 2025
d91844d
Add ITests for LuceceCodecs8.x
drempapis Jan 9, 2025
fe009d7
Merge remote-tracking branch 'upstream/main'
drempapis Jan 10, 2025
a747a40
Merge remote-tracking branch 'upstream/main'
drempapis Jan 10, 2025
f3e47ae
Merge remote-tracking branch 'upstream/main'
drempapis Jan 10, 2025
7fdc027
Update and extend testing
drempapis Jan 13, 2025
5b831ec
update tests
drempapis Jan 13, 2025
338dbb1
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 13, 2025
25b216e
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 13, 2025
50530a2
Update library
drempapis Jan 13, 2025
7033ed0
Merge branch 'fix/117042_Support_7x_segments_as_archive_in_8x' of git…
drempapis Jan 13, 2025
9be8cea
update forbidden API
drempapis Jan 13, 2025
420e646
Add smoke tests for codecs
drempapis Jan 13, 2025
48ab5b4
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 13, 2025
ad70e72
fix test
drempapis Jan 13, 2025
6b479e2
Merge branch 'fix/117042_Support_7x_segments_as_archive_in_8x' of git…
drempapis Jan 13, 2025
2bc0107
Merge remote-tracking branch 'upstream/main'
drempapis Jan 13, 2025
99e816f
Delete internal javadoc
drempapis Jan 13, 2025
3196523
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 13, 2025
f3b3d00
Merge remote-tracking branch 'upstream/main'
drempapis Jan 13, 2025
f52789e
Merge remote-tracking branch 'upstream/main'
drempapis Jan 14, 2025
ec243b7
Merge remote-tracking branch 'upstream/main'
drempapis Jan 14, 2025
900fcb8
Modify MetadataOnly PointsReader to adjust Lucene86 changes
drempapis Jan 15, 2025
46d408f
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 15, 2025
2abea64
[CI] Auto commit changes from spotless
Jan 15, 2025
f93eb9b
Merge remote-tracking branch 'upstream/main'
drempapis Jan 16, 2025
f7e0012
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 16, 2025
2777916
Merge remote-tracking branch 'upstream/main'
drempapis Jan 16, 2025
7d71f93
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 16, 2025
623bd7b
Merge remote-tracking branch 'upstream/main'
drempapis Jan 16, 2025
13806d1
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 16, 2025
3fee6af
Merge remote-tracking branch 'upstream/main'
drempapis Jan 16, 2025
008d767
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 17, 2025
af3fff9
Merge remote-tracking branch 'upstream/main'
drempapis Jan 17, 2025
a41bbad
Merge remote-tracking branch 'upstream/main'
drempapis Jan 17, 2025
6010cc9
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 18, 2025
023e8ea
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 20, 2025
8115a61
Merge remote-tracking branch 'upstream/main'
drempapis Jan 20, 2025
0609411
update after review
drempapis Jan 20, 2025
11ab217
Merge branch 'fix/117042_Support_7x_segments_as_archive_in_8x' of git…
drempapis Jan 20, 2025
d9dedc7
revert code after review
drempapis Jan 20, 2025
4f85349
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 20, 2025
6b2361e
Merge remote-tracking branch 'upstream/main'
drempapis Jan 20, 2025
41dcc1c
Merge remote-tracking branch 'upstream/main'
drempapis Jan 21, 2025
2343576
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 21, 2025
2df7f62
Merge remote-tracking branch 'upstream/main'
drempapis Jan 21, 2025
de31af3
update after review
drempapis Jan 22, 2025
4c3f29a
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 22, 2025
6b95b0c
Merge remote-tracking branch 'upstream/main'
drempapis Jan 22, 2025
74cb102
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 22, 2025
6f8ff50
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 22, 2025
3ebc9f4
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 22, 2025
eadf8cf
Merge remote-tracking branch 'upstream/main'
drempapis Jan 23, 2025
41dc557
Merge remote-tracking branch 'upstream/main'
drempapis Jan 24, 2025
2ca8a9f
Update after review
drempapis Jan 24, 2025
e0e1740
Merge remote-tracking branch 'upstream/main'
drempapis Jan 24, 2025
1ba2eaa
Merge remote-tracking branch 'upstream/main'
drempapis Jan 24, 2025
6820c35
Merge remote-tracking branch 'upstream/main'
drempapis Jan 24, 2025
8280559
Merge remote-tracking branch 'upstream/main'
drempapis Jan 24, 2025
806d442
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 24, 2025
3e0de6d
Update after review
drempapis Jan 27, 2025
a57c0d1
Merge branch 'fix/117042_Support_7x_segments_as_archive_in_8x' of git…
drempapis Jan 27, 2025
bb561e2
[CI] Auto commit changes from spotless
Jan 27, 2025
03bbc25
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 27, 2025
e82375e
Merge remote-tracking branch 'upstream/main'
drempapis Jan 27, 2025
e98aac7
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 27, 2025
b39ef53
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 27, 2025
ce4c1c9
Merge remote-tracking branch 'upstream/main'
drempapis Jan 27, 2025
69fc6f6
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 27, 2025
8a66843
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 28, 2025
ff92f92
Merge remote-tracking branch 'upstream/main'
drempapis Jan 28, 2025
c0f4d18
Merge remote-tracking branch 'upstream/main'
drempapis Jan 28, 2025
02ac377
Merge remote-tracking branch 'upstream/main'
drempapis Jan 29, 2025
7941cbc
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 29, 2025
bb93eac
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 30, 2025
42aa647
Merge remote-tracking branch 'upstream/main'
drempapis Jan 30, 2025
9c9dc66
Update after review
drempapis Jan 30, 2025
b93bf88
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 30, 2025
1cf1afc
Merge branch 'fix/117042_Support_7x_segments_as_archive_in_8x' of git…
drempapis Jan 30, 2025
6e31623
update after review
drempapis Jan 30, 2025
f155836
[CI] Auto commit changes from spotless
Jan 30, 2025
c668a3a
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 30, 2025
bd258ab
Merge remote-tracking branch 'upstream/main'
drempapis Jan 30, 2025
c96cd31
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 30, 2025
6b26b66
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Jan 30, 2025
b20d791
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 5, 2025
58be89d
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 10, 2025
1539844
update after review
drempapis Mar 10, 2025
80919b6
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 10, 2025
5a4ef59
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 11, 2025
d42aa51
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 11, 2025
668ccb3
update after review
drempapis Mar 11, 2025
952ec01
update after review
drempapis Mar 11, 2025
b636061
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 11, 2025
ca586f9
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 13, 2025
6783285
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 13, 2025
e911ed2
update after review
drempapis Mar 14, 2025
7770291
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 14, 2025
44cd893
minor naming update after review
drempapis Mar 14, 2025
b9eb516
[CI] Auto commit changes from spotless
Mar 14, 2025
bb4458d
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 17, 2025
6fec899
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 18, 2025
ca0f256
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 18, 2025
b3bbc6a
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 19, 2025
36f62ca
update after review
drempapis Mar 20, 2025
36edf83
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 20, 2025
2952e62
[CI] Auto commit changes from spotless
Mar 20, 2025
43465fc
Merge branch 'main' into fix/117042_Support_7x_segments_as_archive_in_8x
drempapis Mar 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/119503.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 119503
summary: Support indices created in ESv6 and updated in ESV7 using different LuceneCodecs as archive in current version.
area: Search
type: bug
issues:
- 117042
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.SegmentInfoFormat;
import org.apache.lucene.codecs.TermVectorsFormat;
import org.apache.lucene.codecs.perfield.PerFieldPostingsFormat;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.Fields;
Expand All @@ -26,6 +27,13 @@
import org.apache.lucene.index.Terms;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.util.Version;
import org.elasticsearch.core.UpdateForV10;
import org.elasticsearch.xpack.lucene.bwc.codecs.lucene70.BWCLucene70Codec;
import org.elasticsearch.xpack.lucene.bwc.codecs.lucene80.BWCLucene80Codec;
import org.elasticsearch.xpack.lucene.bwc.codecs.lucene84.BWCLucene84Codec;
import org.elasticsearch.xpack.lucene.bwc.codecs.lucene86.BWCLucene86Codec;
import org.elasticsearch.xpack.lucene.bwc.codecs.lucene87.BWCLucene87Codec;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -37,55 +45,122 @@
*/
public abstract class BWCCodec extends Codec {

private final FieldInfosFormat fieldInfosFormat;
private final SegmentInfoFormat segmentInfosFormat;
private final PostingsFormat postingsFormat;

protected BWCCodec(String name) {
super(name);
}

@Override
public NormsFormat normsFormat() {
throw new UnsupportedOperationException();
}
this.fieldInfosFormat = new FieldInfosFormat() {
final FieldInfosFormat wrappedFormat = originalFieldInfosFormat();

@Override
public TermVectorsFormat termVectorsFormat() {
throw new UnsupportedOperationException();
}
@Override
public FieldInfos read(Directory directory, SegmentInfo segmentInfo, String segmentSuffix, IOContext iocontext)
throws IOException {
return filterFields(wrappedFormat.read(directory, segmentInfo, segmentSuffix, iocontext));
}

@Override
public KnnVectorsFormat knnVectorsFormat() {
throw new UnsupportedOperationException();
}
@Override
public void write(Directory directory, SegmentInfo segmentInfo, String segmentSuffix, FieldInfos infos, IOContext context)
throws IOException {
wrappedFormat.write(directory, segmentInfo, segmentSuffix, infos, context);
}
};

this.segmentInfosFormat = new SegmentInfoFormat() {
final SegmentInfoFormat wrappedFormat = originalSegmentInfoFormat();

protected static SegmentInfoFormat wrap(SegmentInfoFormat wrapped) {
return new SegmentInfoFormat() {
@Override
public SegmentInfo read(Directory directory, String segmentName, byte[] segmentID, IOContext context) throws IOException {
return wrap(wrapped.read(directory, segmentName, segmentID, context));
return wrap(wrappedFormat.read(directory, segmentName, segmentID, context));
}

@Override
public void write(Directory dir, SegmentInfo info, IOContext ioContext) throws IOException {
wrapped.write(dir, info, ioContext);
wrappedFormat.write(dir, info, ioContext);
}
};
}

protected static FieldInfosFormat wrap(FieldInfosFormat wrapped) {
return new FieldInfosFormat() {
this.postingsFormat = new PerFieldPostingsFormat() {
@Override
public FieldInfos read(Directory directory, SegmentInfo segmentInfo, String segmentSuffix, IOContext iocontext)
throws IOException {
return filterFields(wrapped.read(directory, segmentInfo, segmentSuffix, iocontext));
}

@Override
public void write(Directory directory, SegmentInfo segmentInfo, String segmentSuffix, FieldInfos infos, IOContext context)
throws IOException {
wrapped.write(directory, segmentInfo, segmentSuffix, infos, context);
public PostingsFormat getPostingsFormatForField(String field) {
throw new UnsupportedOperationException("Old codecs can't be used for writing");
}
};
}

@Override
public final FieldInfosFormat fieldInfosFormat() {
return fieldInfosFormat;
}

@Override
public final SegmentInfoFormat segmentInfoFormat() {
return segmentInfosFormat;
}

@Override
public PostingsFormat postingsFormat() {
return postingsFormat;
}

/**
* This method is not supported for archive indices and older codecs and will always throw an {@link UnsupportedOperationException}.
* This method is never called in practice, as we rewrite field infos to override the info about which features are present in
* the index. Even if norms are present, field info lies about it.
*
* @return nothing, as this method always throws an exception
* @throws UnsupportedOperationException always thrown to indicate that this method is not supported
*/
@Override
public final NormsFormat normsFormat() {
throw new UnsupportedOperationException();
}

/**
* This method is not supported for archive indices and older codecs and will always throw an {@link UnsupportedOperationException}.
* This method is never called in practice, as we rewrite field infos to override the info about which features are present in
* the index. Even if term vectors are present, field info lies about it.
*
* @return nothing, as this method always throws an exception
* @throws UnsupportedOperationException always thrown to indicate that this method is not supported
*/
@Override
public final TermVectorsFormat termVectorsFormat() {
throw new UnsupportedOperationException();
}

/**
* This method is not supported for archive indices and older codecs and will always throw an {@link UnsupportedOperationException}.
* The knn vectors can't be present because it is not supported yet in any of the lucene versions that we support for archive indices.
*
* @return nothing, as this method always throws an exception
* @throws UnsupportedOperationException always thrown to indicate that this method is not supported
*/
@Override
public final KnnVectorsFormat knnVectorsFormat() {
throw new UnsupportedOperationException();
}

/**
* Returns the original {@link SegmentInfoFormat} used by this codec.
* This method should be implemented by subclasses to provide the specific
* {@link SegmentInfoFormat} that this codec is intended to use.
*
* @return the original {@link SegmentInfoFormat} used by this codec
*/
protected abstract SegmentInfoFormat originalSegmentInfoFormat();

/**
* Returns the original {@link FieldInfosFormat} used by this codec.
* This method should be implemented by subclasses to provide the specific
* {@link FieldInfosFormat} that this codec is intended to use.
*
* @return the original {@link FieldInfosFormat} used by this codec
*/
protected abstract FieldInfosFormat originalFieldInfosFormat();

// mark all fields as no term vectors, no norms, no payloads, and no vectors.
private static FieldInfos filterFields(FieldInfos fieldInfos) {
List<FieldInfo> fieldInfoCopy = new ArrayList<>(fieldInfos.size());
Expand Down Expand Up @@ -118,13 +193,14 @@ private static FieldInfos filterFields(FieldInfos fieldInfos) {
}

public static SegmentInfo wrap(SegmentInfo segmentInfo) {
final Codec codec = segmentInfo.getCodec();
Codec codec = getBackwardCompatibleCodec(segmentInfo.getCodec());

final SegmentInfo segmentInfo1 = new SegmentInfo(
segmentInfo.dir,
// Use Version.LATEST instead of original version, otherwise SegmentCommitInfo will bark when processing (N-1 limitation)
// TODO: perhaps store the original version information in attributes so that we can retrieve it later when needed?
org.apache.lucene.util.Version.LATEST,
org.apache.lucene.util.Version.LATEST,
Version.LATEST,
Version.LATEST,
segmentInfo.name,
segmentInfo.maxDoc(),
segmentInfo.getUseCompoundFile(),
Expand All @@ -139,6 +215,29 @@ public static SegmentInfo wrap(SegmentInfo segmentInfo) {
return segmentInfo1;
}

/**
* Returns a backward-compatible codec for the given codec. If the codec is one of the known Lucene 8.x codecs,
* it returns a corresponding read-only backward-compatible codec. Otherwise, it returns the original codec.
* Lucene 8.x codecs are still shipped with the current version of Lucene.
* Earlier codecs we are providing directly they will also be read-only backward-compatible, but they don't require the renaming.
*
* This switch is only for indices created in ES 6.x, later written into in ES 7.x (Lucene 8.x). Indices created
* in ES 7.x can be read directly by ES if marked read-only, without going through archive indices.
*/
@UpdateForV10(owner = UpdateForV10.Owner.SEARCH_FOUNDATIONS)
private static Codec getBackwardCompatibleCodec(Codec codec) {
if (codec == null) return null;

return switch (codec.getClass().getSimpleName()) {
case "Lucene70Codec" -> new BWCLucene70Codec();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @drempapis I missed this during review, not a huge deal, but wrapping Lucene70Codec is not required here. Lucene70Codec is no longer shipped with Lucene 10.0, we rather ship it, and it's already extending BWCCodec. I would instead check that the codec we get extends from BWCCodec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true; I passed it from the debugger to verify it. I'll create a pr to adjust this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ thanks, ping me for review, it'll be quicker this time :)

case "Lucene80Codec" -> new BWCLucene80Codec();
case "Lucene84Codec" -> new BWCLucene84Codec();
case "Lucene86Codec" -> new BWCLucene86Codec();
case "Lucene87Codec" -> new BWCLucene87Codec();
default -> codec;
};
}

/**
* In-memory postings format that shows no postings available.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
*/
@Deprecated
public class Lucene60Codec extends BWCCodec {
private final FieldInfosFormat fieldInfosFormat = wrap(new Lucene60FieldInfosFormat());
private final SegmentInfoFormat segmentInfosFormat = wrap(new Lucene50SegmentInfoFormat());

private final LiveDocsFormat liveDocsFormat = new Lucene50LiveDocsFormat();
private final CompoundFormat compoundFormat = new Lucene50CompoundFormat();
private final StoredFieldsFormat storedFieldsFormat;
Expand All @@ -68,18 +67,18 @@ public Lucene60Codec() {
}

@Override
public final StoredFieldsFormat storedFieldsFormat() {
return storedFieldsFormat;
protected FieldInfosFormat originalFieldInfosFormat() {
return new Lucene60FieldInfosFormat();
}

@Override
public final FieldInfosFormat fieldInfosFormat() {
return fieldInfosFormat;
protected SegmentInfoFormat originalSegmentInfoFormat() {
return new Lucene50SegmentInfoFormat();
}

@Override
public SegmentInfoFormat segmentInfoFormat() {
return segmentInfosFormat;
public final StoredFieldsFormat storedFieldsFormat() {
return storedFieldsFormat;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.io.IOException;

/**
* This is a fork of {@link org.apache.lucene.backward_codecs.lucene60.Lucene60PointsFormat}
* Allows reading metadata only from Lucene 6.0 point format
**/
public class Lucene60MetadataOnlyPointsFormat extends PointsFormat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
import java.util.HashMap;
import java.util.Map;

/** Reads the metadata of point values previously written with Lucene60PointsWriter */
/**
* This is a fork of {@link org.apache.lucene.backward_codecs.lucene60.Lucene60PointsReader}
* Reads the metadata of point values previously written with Lucene60PointsWriter
*/
public final class Lucene60MetadataOnlyPointsReader extends PointsReader {
final IndexInput dataIn;
final SegmentReadState readState;
Expand Down Expand Up @@ -105,7 +108,7 @@ public Lucene60MetadataOnlyPointsReader(SegmentReadState readState) throws IOExc
int fieldNumber = ent.getKey();
long fp = ent.getValue();
dataIn.seek(fp);
PointValues reader = new MetadataOnlyBKDReader(dataIn);
PointValues reader = new MetadataOnlyBKDReader(dataIn, false);
readers.put(fieldNumber, reader);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class MetadataOnlyBKDReader extends PointValues {
final int docCount;
final int version;

public MetadataOnlyBKDReader(IndexInput metaIn) throws IOException {
public MetadataOnlyBKDReader(IndexInput metaIn, boolean isVersionPost86) throws IOException {
version = CodecUtil.checkHeader(metaIn, "BKD", VERSION_START, VERSION_CURRENT);
final int numDims = metaIn.readVInt();
final int numIndexDims;
Expand Down Expand Up @@ -85,6 +85,15 @@ public MetadataOnlyBKDReader(IndexInput metaIn) throws IOException {

pointCount = metaIn.readVLong();
docCount = metaIn.readVInt();

// This code has been introduced to process IndexInput created with Lucene86Codec+. This is not necessary
// in the read-only version for older formats.
if (isVersionPost86) {
metaIn.readVInt();
metaIn.readLong();
// The following fields are not used in this class, but we need to read them to advance the pointer
metaIn.readLong();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
*/
@Deprecated
public class Lucene62Codec extends BWCCodec {
private final FieldInfosFormat fieldInfosFormat = wrap(new Lucene60FieldInfosFormat());
private final SegmentInfoFormat segmentInfosFormat = wrap(new Lucene62SegmentInfoFormat());

private final LiveDocsFormat liveDocsFormat = new Lucene50LiveDocsFormat();
private final CompoundFormat compoundFormat = new Lucene50CompoundFormat();
private final StoredFieldsFormat storedFieldsFormat;
Expand All @@ -68,18 +67,18 @@ public Lucene62Codec() {
}

@Override
public final StoredFieldsFormat storedFieldsFormat() {
return storedFieldsFormat;
protected FieldInfosFormat originalFieldInfosFormat() {
return new Lucene60FieldInfosFormat();
}

@Override
public final FieldInfosFormat fieldInfosFormat() {
return fieldInfosFormat;
protected SegmentInfoFormat originalSegmentInfoFormat() {
return new Lucene62SegmentInfoFormat();
}

@Override
public SegmentInfoFormat segmentInfoFormat() {
return segmentInfosFormat;
public final StoredFieldsFormat storedFieldsFormat() {
return storedFieldsFormat;
}

@Override
Expand Down
Loading
Loading