Skip to content

Commit 730e934

Browse files
committed
Remove FST constructor
1 parent f2287e7 commit 730e934

File tree

20 files changed

+56
-56
lines changed

20 files changed

+56
-56
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ private TokenInfoDictionary(
103103
FST<Long> fst;
104104
try (InputStream is = new BufferedInputStream(fstResource.get())) {
105105
DataInput in = new InputStreamDataInput(is);
106-
fst = new FST<>(in, in, PositiveIntOutputs.getSingleton());
106+
FST.FSTMetadata<Long> metadata = FST.readMetadata(in, PositiveIntOutputs.getSingleton());
107+
fst = new FST<>(metadata, in, PositiveIntOutputs.getSingleton());
107108
}
108109
// TODO: some way to configure?
109110
this.fst = new TokenInfoFST(fst, true);

lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/TokenInfoDictionary.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ private TokenInfoDictionary(
102102
FST<Long> fst;
103103
try (InputStream is = new BufferedInputStream(fstResource.get())) {
104104
DataInput in = new InputStreamDataInput(is);
105-
fst = new FST<>(in, in, PositiveIntOutputs.getSingleton());
105+
FST.FSTMetadata<Long> metadata = FST.readMetadata(in, PositiveIntOutputs.getSingleton());
106+
fst = new FST<>(metadata, in, PositiveIntOutputs.getSingleton());
106107
}
107108
this.fst = new TokenInfoFST(fst);
108109
}

lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene40/blocktree/FieldReader.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,13 @@ public final class FieldReader extends Terms {
8989
final IndexInput clone = indexIn.clone();
9090
clone.seek(indexStartFP);
9191
if (metaIn == indexIn) { // Only true before Lucene 8.6
92-
index = new FST<>(clone, clone, ByteSequenceOutputs.getSingleton(), new OffHeapFSTStore());
92+
FST.FSTMetadata<BytesRef> metadata =
93+
FST.readMetadata(clone, ByteSequenceOutputs.getSingleton());
94+
index = new FST<>(metadata, clone, ByteSequenceOutputs.getSingleton(), new OffHeapFSTStore());
9395
} else {
94-
index = new FST<>(metaIn, clone, ByteSequenceOutputs.getSingleton(), new OffHeapFSTStore());
96+
FST.FSTMetadata<BytesRef> metadata =
97+
FST.readMetadata(metaIn, ByteSequenceOutputs.getSingleton());
98+
index = new FST<>(metadata, clone, ByteSequenceOutputs.getSingleton(), new OffHeapFSTStore());
9599
}
96100
/*
97101
if (false) {

lucene/codecs/src/java/org/apache/lucene/codecs/blockterms/VariableGapTermsIndexReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private final class FieldIndexData implements Accountable {
154154
public FieldIndexData(IndexInput in, FieldInfo fieldInfo, long indexStart) throws IOException {
155155
IndexInput clone = in.clone();
156156
clone.seek(indexStart);
157-
fst = new FST<>(clone, clone, fstOutputs);
157+
fst = new FST<>(FST.readMetadata(clone, fstOutputs), clone, fstOutputs);
158158
clone.close();
159159

160160
/*

lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsFieldReader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ final class OrdsFieldReader extends Terms {
8585
final IndexInput clone = indexIn.clone();
8686
// System.out.println("start=" + indexStartFP + " field=" + fieldInfo.name);
8787
clone.seek(indexStartFP);
88-
index = new FST<>(clone, clone, OrdsBlockTreeTermsWriter.FST_OUTPUTS);
88+
FST.FSTMetadata<Output> metadata =
89+
FST.readMetadata(clone, OrdsBlockTreeTermsWriter.FST_OUTPUTS);
90+
index = new FST<>(metadata, clone, OrdsBlockTreeTermsWriter.FST_OUTPUTS);
8991

9092
/*
9193
if (true) {

lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ final class TermsReader extends Terms {
194194
this.sumDocFreq = sumDocFreq;
195195
this.docCount = docCount;
196196
OffHeapFSTStore offHeapFSTStore = new OffHeapFSTStore();
197-
this.dict = new FST<>(in, in, new FSTTermOutputs(fieldInfo), offHeapFSTStore);
197+
FSTTermOutputs outputs = new FSTTermOutputs(fieldInfo);
198+
this.dict = new FST<>(FST.readMetadata(in, outputs), in, outputs, offHeapFSTStore);
198199
in.skipBytes(offHeapFSTStore.size());
199200
}
200201

lucene/codecs/src/java/org/apache/lucene/codecs/uniformsplit/FSTDictionary.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ protected static FSTDictionary read(
8989
isFSTOnHeap = true;
9090
}
9191
PositiveIntOutputs fstOutputs = PositiveIntOutputs.getSingleton();
92+
FST.FSTMetadata<Long> metadata = FST.readMetadata(fstDataInput, fstOutputs);
9293
FST<Long> fst =
9394
isFSTOnHeap
94-
? new FST<>(fstDataInput, fstDataInput, fstOutputs)
95-
: new FST<>(fstDataInput, fstDataInput, fstOutputs, new OffHeapFSTStore());
95+
? new FST<>(metadata, fstDataInput, fstOutputs)
96+
: new FST<>(metadata, fstDataInput, fstOutputs, new OffHeapFSTStore());
9697
return new FSTDictionary(fst);
9798
}
9899

lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/FieldReader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ public final class FieldReader extends Terms {
9191
// Initialize FST always off-heap.
9292
final IndexInput clone = indexIn.clone();
9393
clone.seek(indexStartFP);
94-
index = new FST<>(metaIn, clone, ByteSequenceOutputs.getSingleton(), new OffHeapFSTStore());
94+
FST.FSTMetadata<BytesRef> metadata =
95+
FST.readMetadata(metaIn, ByteSequenceOutputs.getSingleton());
96+
index = new FST<>(metadata, clone, ByteSequenceOutputs.getSingleton(), new OffHeapFSTStore());
9597
/*
9698
if (false) {
9799
final String dotFileName = segment + "_" + fieldInfo.name + ".dot";

lucene/core/src/java/org/apache/lucene/util/fst/FST.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -404,18 +404,8 @@ private static boolean flag(int flags, int bit) {
404404
* Load a previously saved FST with a DataInput for metdata using an {@link OnHeapFSTStore} with
405405
* maxBlockBits set to {@link #DEFAULT_MAX_BLOCK_BITS}
406406
*/
407-
public FST(DataInput metaIn, DataInput in, Outputs<T> outputs) throws IOException {
408-
this(metaIn, in, outputs, new OnHeapFSTStore(DEFAULT_MAX_BLOCK_BITS));
409-
}
410-
411-
/**
412-
* Load a previously saved FST with a DataInput for metdata and a FSTStore. If using {@link
413-
* OnHeapFSTStore}, setting maxBlockBits allows you to control the size of the byte[] pages used
414-
* to hold the FST bytes.
415-
*/
416-
public FST(DataInput metaIn, DataInput in, Outputs<T> outputs, FSTStore fstStore)
417-
throws IOException {
418-
this(readMetadata(metaIn, outputs), in, outputs, fstStore);
407+
public FST(FSTMetadata<T> metadata, DataInput in, Outputs<T> outputs) throws IOException {
408+
this(metadata, in, outputs, new OnHeapFSTStore(DEFAULT_MAX_BLOCK_BITS));
419409
}
420410

421411
/**
@@ -574,7 +564,7 @@ public void save(final Path path) throws IOException {
574564
public static <T> FST<T> read(Path path, Outputs<T> outputs) throws IOException {
575565
try (InputStream is = Files.newInputStream(path)) {
576566
DataInput in = new InputStreamDataInput(new BufferedInputStream(is));
577-
return new FST<>(in, in, outputs);
567+
return new FST<>(readMetadata(in, outputs), in, outputs);
578568
}
579569
}
580570

lucene/core/src/test/org/apache/lucene/util/fst/Test2BFST.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void test() throws Exception {
140140
fst.save(out, out);
141141
out.close();
142142
IndexInput in = dir.openInput("fst", IOContext.DEFAULT);
143-
fst = new FST<>(in, in, outputs);
143+
fst = new FST<>(FST.readMetadata(in, outputs), in, outputs);
144144
in.close();
145145
} else {
146146
dir.deleteFile("fst");
@@ -226,7 +226,7 @@ public void test() throws Exception {
226226
fst.save(out, out);
227227
out.close();
228228
IndexInput in = dir.openInput("fst", IOContext.DEFAULT);
229-
fst = new FST<>(in, in, outputs);
229+
fst = new FST<>(FST.readMetadata(in, outputs), in, outputs);
230230
in.close();
231231
} else {
232232
dir.deleteFile("fst");
@@ -317,7 +317,7 @@ public void test() throws Exception {
317317
fst.save(out, out);
318318
out.close();
319319
IndexInput in = dir.openInput("fst", IOContext.DEFAULT);
320-
fst = new FST<>(in, in, outputs);
320+
fst = new FST<>(FST.readMetadata(in, outputs), in, outputs);
321321
in.close();
322322
} else {
323323
dir.deleteFile("fst");

0 commit comments

Comments
 (0)