You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[8.x] Docs and simplifications to support for Lucene ancient versions (#124053) (#124509)
* Docs and simplifications to support for Lucene ancient versions (#124053)
The old lucene versions plugin allows users to read indices created by ancient
Elasticsearch version, starting from 5.0. Especially for 5.x which relied on Lucene
6.x, some special logic is required around postings format support. That revolves
around reading of FSTs, but has a consequence of requiring quite a few fork of
other Lucene classes due to their visibility.
This commit attempts to add javadocs to clarify the intent of some of these classes.
It also includes some simplifications, in that Lucene50PostingsReader can be reused as-is
and some other classes are only needed in tests hence are moved to the test folder.
* iter
* iter
Copy file name to clipboardExpand all lines: x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/LegacyAdaptingPerFieldPostingsFormat.java
Copy file name to clipboardExpand all lines: x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene40/blocktree/CompressionAlgorithm.java
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,10 @@
25
25
26
26
importjava.io.IOException;
27
27
28
-
/** Compression algorithm used for suffixes of a block of terms. */
28
+
/**
29
+
* This is a copy of the class with same name shipped with Lucene, which is though package protected hence not accessible.
30
+
* We need to copy it because we have our own fork of {@link FieldReader}.
Copy file name to clipboardExpand all lines: x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene40/blocktree/FieldReader.java
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,9 @@
35
35
36
36
/**
37
37
* BlockTree's implementation of {@link Terms}.
38
+
*
39
+
* This is a fork of {@link org.apache.lucene.backward_codecs.lucene40.blocktree.FieldReader} that allows to read from ancient
40
+
* Lucene versions. The key difference is the FST loading which relies on {@link FST}.
Copy file name to clipboardExpand all lines: x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene40/blocktree/IntersectTermsEnum.java
+2-6Lines changed: 2 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,6 @@
23
23
importorg.apache.lucene.index.ImpactsEnum;
24
24
importorg.apache.lucene.index.PostingsEnum;
25
25
importorg.apache.lucene.index.TermState;
26
-
importorg.apache.lucene.index.Terms;
27
26
importorg.apache.lucene.store.IndexInput;
28
27
importorg.apache.lucene.util.ArrayUtil;
29
28
importorg.apache.lucene.util.BytesRef;
@@ -39,11 +38,8 @@
39
38
importjava.io.IOException;
40
39
41
40
/**
42
-
* This is used to implement efficient {@link Terms#intersect} for block-tree. Note that it cannot
43
-
* seek, except for the initial term on init. It just "nexts" through the intersection of the
44
-
* automaton and the terms. It does not use the terms index at all: on init, it loads the root
45
-
* block, and scans its way to the initial term. Likewise, in next it scans until it finds a term
46
-
* that matches the current automaton transition.
41
+
* This is a copy of the class with same name shipped with Lucene, which is though package protected hence not accessible.
42
+
* We need to copy it because we have our own fork of {@link FieldReader}.
Copy file name to clipboardExpand all lines: x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene40/blocktree/IntersectTermsEnumFrame.java
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,10 @@
31
31
importjava.io.IOException;
32
32
importjava.util.Arrays;
33
33
34
-
// TODO: can we share this with the frame in STE?
34
+
/**
35
+
* This is a copy of the class with same name shipped with Lucene, which is though package protected hence not accessible.
36
+
* We need to copy it because we have our own fork of {@link FieldReader}.
Copy file name to clipboardExpand all lines: x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene40/blocktree/Lucene40BlockTreeTermsReader.java
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -252,6 +252,10 @@ public Lucene40BlockTreeTermsReader(PostingsReaderBase postingsReader, SegmentRe
252
252
finallongindexStartFP = indexMetaIn.readVLong();
253
253
FieldReaderprevious = fieldMap.put(
254
254
fieldInfo.name,
255
+
/*
256
+
The FieldReader used differs from the original Lucene variant, in that it is more flexible
Copy file name to clipboardExpand all lines: x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene40/blocktree/SegmentTermsEnum.java
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,10 @@
36
36
importjava.io.IOException;
37
37
importjava.io.PrintStream;
38
38
39
-
/** Iterates through terms in this field. */
39
+
/**
40
+
* This is a copy of the class with same name shipped with Lucene, which is though package protected hence not accessible.
41
+
* We need to copy it because we have our own fork of {@link FieldReader}.
Copy file name to clipboardExpand all lines: x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene40/blocktree/SegmentTermsEnumFrame.java
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,10 @@
31
31
importjava.io.IOException;
32
32
importjava.util.Arrays;
33
33
34
+
/**
35
+
* This is a copy of the class with same name shipped with Lucene, which is though package protected hence not accessible.
36
+
* We need to copy it because we have our own fork of {@link FieldReader}.
Copy file name to clipboardExpand all lines: x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene40/blocktree/Stats.java
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,8 @@
30
30
importjava.util.Locale;
31
31
32
32
/**
33
-
* BlockTree statistics for a single field returned by {@link FieldReader#getStats()}.
33
+
* This is a copy of {@link Stats} shipped with Lucene, which has though package protected constructor and methods.
34
+
* We need to copy it because we have our own fork of {@link FieldReader}.
0 commit comments