msfroh commented on code in PR #13054: URL: https://github.com/apache/lucene/pull/13054#discussion_r1701032411
########## lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMapDirectory.java: ########## @@ -0,0 +1,191 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.lucene.analysis.synonym; + +import java.io.Closeable; +import java.io.IOException; +import java.nio.file.Path; +import java.util.List; +import org.apache.lucene.store.Directory; +import org.apache.lucene.store.FSDirectory; +import org.apache.lucene.store.IOContext; +import org.apache.lucene.store.IndexInput; +import org.apache.lucene.store.IndexOutput; +import org.apache.lucene.util.BytesRef; +import org.apache.lucene.util.fst.ByteSequenceOutputs; +import org.apache.lucene.util.fst.FST; +import org.apache.lucene.util.fst.OffHeapFSTStore; + +/** + * Wraps an {@link FSDirectory} to read and write a compiled {@link SynonymMap}. When reading, the + * FST and output words are kept off-heap. + */ +public class SynonymMapDirectory implements Closeable { Review Comment: I was thinking that the user would create a `SynonymMapDirectory` and pass it to `SynonymMap.Builder.build(SynonymMapDirectory)` as the way of opting in to off-heap FSTs for their synonyms. Given the issue you called out below regarding the need to `close` the `IndexInput` for the FST, I feel like the user needs to hold onto "something" (other than the `SynonymMap`) that gives them an obligation to close filesystem resources when they're done. Alternatively, I'd be happy to make `SynonymMap` implement `Closeable`. Then I'd probably just ask the user to specify a `Path` instead. At that point, we could hide `SynonymMapDirectory` altogether. -- 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