Skip to content

Commit e1fd2b2

Browse files
committed
Make FSTCompiler.compile() to only return the FSTMetadata
1 parent 02722ee commit e1fd2b2

File tree

82 files changed

+501
-690
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+501
-690
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,15 @@ First of all, you need the Lucene source code.
2525

2626
Get the source code using: `git clone https://github.com/apache/lucene`
2727

28-
Please note that it is important to preserve the files' original line breaks - some of them have their checksums verified during build.
29-
If you are using Windows you might want to override the default Git configuration when cloning the repository:
30-
`git clone --config core.autocrlf=false https://github.com/apache/lucene`
31-
32-
### Pre-requisites
28+
### Notes for required Java version
3329

3430
Be sure that you are using an appropriate version of the JDK. Please check [README](./README.md) for the required JDK version for current main branch.
3531

36-
Some build tasks (in particular `./gradlew check`) require Perl and Python 3.
37-
3832
### Building with Gradle
3933

4034
Lucene uses [Gradle](https://gradle.org/) for build control. Gradle is itself Java-based and may be incompatible with newer Java versions; you can still build and test Lucene with these Java releases, see [jvms.txt](./help/jvms.txt) for more information.
4135

42-
NOTE: DO NOT use the `gradle` command that is perhaps installed on your machine. This may result in using a different gradle version than the project requires and this is known to lead to very cryptic errors. The "gradle wrapper" (`gradlew` script) does everything required to build the project from scratch: it downloads the correct version of gradle, sets up sane local configurations and is tested on multiple environments.
36+
NOTE: DO NOT use the `gradle` command that is perhaps installed on your machine. This may result in using a different gradle version than the project requires and this is known to lead to very cryptic errors. The "gradle wrapper" (gradlew script) does everything required to build the project from scratch: it downloads the correct version of gradle, sets up sane local configurations and is tested on multiple environments.
4337

4438
The first time you run gradlew, it will create a file "gradle.properties" that contains machine-specific settings. Normally you can use this file as-is, but it can be modified if necessary.
4539

help/formatting.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ IMPORTANT: There is *no* way to mark sections of the code as excluded
1616
from formatting. This is by design and cannot be altered. In vast
1717
majority of cases the formatter will do a great job of cleaning up the
1818
code. Occasionally you may want to rewrite the code (introduce a local
19-
variable or reshape code paths) so that it's easier to read after
19+
variable orreshape code paths) so that it's easier to read after
2020
automatic formatting.

lucene/CHANGES.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ API Changes
6969
* GITHUB#12243: Remove TermInSetQuery ctors taking varargs param. SortedSetDocValuesField#newSlowSetQuery,
7070
SortedDocValuesField#newSlowSetQuery, KeywordField#newSetQuery, KeywordField#newSetQuery now take a collection. (Jakub Slowinski)
7171

72+
* GITHUB#12624, GITHUB#12831: Allow FSTCompiler to stream to any DataOutput while building, and
73+
make compile() only return the FSTMetadata. For on-heap (default) use case, please use
74+
FST.fromFSTReader(fstMetadata, fstCompiler.getFSTReader()) to create the FST. (Anh Dung Bui)
75+
7276
* GITHUB#12881: Performance improvements to MatchHighlighter and MatchRegionRetriever. MatchRegionRetriever can be
7377
configured to not load matches (or content) of certain fields and to force-load other fields so that stored fields
7478
of a document are accessed once. A configurable limit of field matches placed in the priority queue was added
@@ -120,8 +124,6 @@ Optimizations
120124

121125
* GITHUB#12552: Make FSTPostingsFormat load FSTs off-heap. (Tony X)
122126

123-
* GITHUB#12841: Move group-varint encoding/decoding logic to DataOutput/DataInput. (Adrien Grand, Zhang Chao, Uwe Schindler)
124-
125127
Bug Fixes
126128
---------------------
127129

lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/NormalizeCharMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public NormalizeCharMap build() {
111111
for (Map.Entry<String, String> ent : pendingPairs.entrySet()) {
112112
fstCompiler.add(Util.toUTF16(ent.getKey(), scratch), new CharsRef(ent.getValue()));
113113
}
114-
map = fstCompiler.compile();
114+
map = FST.fromFSTReader(fstCompiler.compile(), fstCompiler.getFSTReader());
115115
pendingPairs.clear();
116116
} catch (IOException ioe) {
117117
// Bogus FST IOExceptions!! (will never happen)

lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/ConvTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ConvTable {
5151
fstCompiler.add(scratchInts.get(), new CharsRef(entry.getValue()));
5252
}
5353

54-
fst = fstCompiler.compile();
54+
fst = FST.fromFSTReader(fstCompiler.compile(), fstCompiler.getFSTReader());
5555
} catch (IOException bogus) {
5656
throw new RuntimeException(bogus);
5757
}

lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ private FST<IntsRef> affixFST(TreeMap<String, List<Integer>> affixes) throws IOE
657657
}
658658
fstCompiler.add(scratch.get(), output);
659659
}
660-
return fstCompiler.compile();
660+
return FST.fromFSTReader(fstCompiler.compile(), fstCompiler.getFSTReader());
661661
}
662662

663663
/**

lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/StemmerOverrideFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ public StemmerOverrideMap build() throws IOException {
222222
intsSpare.copyUTF8Bytes(bytesRef);
223223
fstCompiler.add(intsSpare.get(), new BytesRef(outputValues.get(id)));
224224
}
225-
return new StemmerOverrideMap(fstCompiler.compile(), ignoreCase);
225+
return new StemmerOverrideMap(
226+
FST.fromFSTReader(fstCompiler.compile(), fstCompiler.getFSTReader()), ignoreCase);
226227
}
227228
}
228229
}

lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public SynonymMap build() throws IOException {
291291
fstCompiler.add(Util.toUTF32(input, scratchIntsRef), scratch.toBytesRef());
292292
}
293293

294-
FST<BytesRef> fst = fstCompiler.compile();
294+
FST<BytesRef> fst = FST.fromFSTReader(fstCompiler.compile(), fstCompiler.getFSTReader());
295295
return new SynonymMap(fst, words, maxHorizontalContext);
296296
}
297297
}

lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/TokenInfoDictionaryBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private TokenInfoDictionaryWriter buildDictionary(List<Path> csvFiles) throws IO
130130
dictionary.addMapping((int) ord, offset);
131131
offset = next;
132132
}
133-
dictionary.setFST(fstCompiler.compile());
133+
dictionary.setFST(FST.fromFSTReader(fstCompiler.compile(), fstCompiler.getFSTReader()));
134134
return dictionary;
135135
}
136136

lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/UserDictionary.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ public int compare(String[] left, String[] right) {
147147
segmentations.add(wordIdAndLength);
148148
ord++;
149149
}
150-
this.fst = new TokenInfoFST(fstCompiler.compile(), false);
150+
this.fst =
151+
new TokenInfoFST(
152+
FST.fromFSTReader(fstCompiler.compile(), fstCompiler.getFSTReader()), false);
151153
this.morphAtts = new UserMorphData(data.toArray(new String[0]));
152154
this.segmentations = segmentations.toArray(new int[segmentations.size()][]);
153155
}

0 commit comments

Comments
 (0)