msfroh commented on PR #13054:
URL: https://github.com/apache/lucene/pull/13054#issuecomment-1961803620

   @dungba88  -- I'm trying to resolve conflicts with your changes, but I'm a 
little stuck. I don't understand how we're supposed to use the FST APIs to 
write the FST to disk now.
   
   After merging our changes, `SynonymMap` contains:
   
   ```
         FST<BytesRef> fst = FST.fromFSTReader(fstCompiler.compile(), 
fstCompiler.getFSTReader());
         if (directory != null) {
           fstOutput.close(); // TODO -- Should fstCompiler.compile take care 
of this?
           try (SynonymMapDirectory.WordsOutput wordsOutput = 
directory.wordsOutput()) {
             BytesRef scratchRef = new BytesRef();
             for (int i = 0; i < words.size(); i++) {
               words.get(i, scratchRef);
               wordsOutput.addWord(scratchRef);
             }
           }
           directory.writeMetadata(words.size(), maxHorizontalContext, fst);
           return directory.readMap();
         }
   ```
   
   That call to `FST.fromFSTReader(...)` fails with:
   
   ```
   The DataOutput must implement FSTReader, but got 
FSIndexOutput(path="/home/froh/ws/lucene/lucene/analysis/common/build/tmp/tests-tmp/lucene.analysis.synonym.TestSynonymGraphFilter_1171182AD5892267-001/tempDir-001/synonyms.fst")
   ```
   
   Is there something else that I'm supposed to be calling on the write path? 
Note that in the "off-heap" case above (when `directory != null`), we just need 
to **write** the FST. The `directory.readMap()` call loads it fresh from disk, 
discarding the FST that we constructed on heap.


-- 
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