dungba88 commented on code in PR #12624:
URL: https://github.com/apache/lucene/pull/12624#discussion_r1391285510


##########
lucene/core/src/java/org/apache/lucene/util/fst/FSTCompiler.java:
##########
@@ -120,31 +122,54 @@ public class FSTCompiler<T> {
   final float directAddressingMaxOversizingFactor;
   long directAddressingExpansionCredit;
 
-  final BytesStore bytes;
+  // writer for frozen nodes
+  final FSTDataOutputWriter fstWriter;
+  // reader for the frozen nodes
+  final FSTReader fstReader;
+
+  // buffer to store the scratch bytes before writing to the fstWriter
+  final BytesStore bytes = new BytesStore(DEFAULT_SCRATCH_PAGE_BITS);
 
   /**
    * Instantiates an FST/FSA builder with default settings and pruning options 
turned off. For more
    * tuning and tweaking, see {@link Builder}.
    */
   // TODO: remove this?  Builder API should be the only entry point?
   public FSTCompiler(FST.INPUT_TYPE inputType, Outputs<T> outputs) {
-    this(inputType, 32.0, outputs, true, 15, 1f);
+    this(
+        inputType,
+        32.0,
+        outputs,
+        true,
+        new FSTDataOutputWriter(getLegacyDataOutput(DEFAULT_BLOCK_BITS)),
+        1f);
+  }
+
+  static DataOutput getLegacyDataOutput(int blockBits) {
+    return new BytesStore(blockBits);
   }
 
   private FSTCompiler(
       FST.INPUT_TYPE inputType,
       double suffixRAMLimitMB,
       Outputs<T> outputs,
       boolean allowFixedLengthArcs,
-      int bytesPageBits,
+      FSTDataOutputWriter fstWriter,
       float directAddressingMaxOversizingFactor) {
     this.allowFixedLengthArcs = allowFixedLengthArcs;
     this.directAddressingMaxOversizingFactor = 
directAddressingMaxOversizingFactor;
-    bytes = new BytesStore(bytesPageBits);
     // pad: ensure no node gets address 0 which is reserved to mean
     // the stop state w/ no arcs
-    bytes.writeByte((byte) 0);
-    fst = new FST<>(new FST.FSTMetadata<>(inputType, null, -1, 
VERSION_CURRENT, 0), outputs, bytes);
+    try {
+      fstWriter.writeByte((byte) 0);
+    } catch (IOException e) {

Review Comment:
   Ah, if the public ctor is be removed in 
https://github.com/apache/lucene/pull/12715 then we can throw it here. I'll 
wait for that PR to be merged.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to