Add read-only directory support - #3058
Conversation
|
This is a just a read only directory, and that functionality can leave outside of tantivy, so this is just about including batteries, correct? I would call it immutable more than read only maybe. |
|
Thanks for the feedback @fulmicoton . Correct, this is mainly about including the batteries. Rust users can implement a custom directory wrapper outside tantivy, but tantivy-py users cannot provide their own directory implementation. Including this in tantivy would allow the python bindings to open a static index from a read only filesystem. I agree Immutable communicates the api better than read only. Shall I rename the directory and methods accordingly ?
|
Summary
Adds
ReadOnlyDirectoryfor opening an immutable index without requiring write access to its directory.META_LOCK.Two convenience methods are included:
Motivation
IndexReaderacquiresMETA_LOCKwhile loading segment readers. This requires write access to the index directory, even when the index is immutable and used only for searching.ReadOnlyDirectoryskips this lock so an index can be used from a read-only filesystem.A custom
Directorywrapper can provide similar behaviour in Rust, but this workaround is not available to users of bindings such astantivy-py, because theDirectoryinterface is not exposed to Python. ProvidingReadOnlyDirectoryin Tantivy allows bindings to expose the same behaviour without maintaining their own implementation.The underlying index must remain unchanged while it is open. This mode must not be used while another process is writing to or garbage-collecting the same index.
Addresses #557 #557 (comment)
Testing
Tests cover:
.tantivy-meta.lockis not created.Built with GPT-5.6 Sol in the Codex desktop harness.