mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-10-06 11:52:40 +00:00
Minimize unrelated changes
This commit is contained in:
@@ -139,15 +139,21 @@ pub trait Directory: DirectoryClone + fmt::Debug + Send + Sync + 'static {
|
||||
/// Opens a writer for the *virtual file* associated with
|
||||
/// a [`Path`].
|
||||
///
|
||||
/// Depending on the directory implementation, [`Directory::sync_directory()`] may be required
|
||||
/// after terminating the writer to ensure that the file is durably created.
|
||||
/// After the writer is terminated, the file should be created and any subsequent call to
|
||||
/// [`Directory::open_read()`] for the same path should return a [`FileSlice`].
|
||||
///
|
||||
/// Write operations may be aggressively buffered. The client must call
|
||||
/// [`TerminatingWrite::terminate()`] to finalize the file and make all writes available to
|
||||
/// subsequent reads. The directory implementation owns its buffering strategy; clients should
|
||||
/// not rely on `flush()` making an incomplete file available.
|
||||
/// However, depending on the directory implementation,
|
||||
/// it might be required to call [`Directory::sync_directory()`] to ensure
|
||||
/// that the file is durably created.
|
||||
/// (The semantics here are the same when dealing with
|
||||
/// a POSIX filesystem.)
|
||||
///
|
||||
/// The user shall not rely on [`Drop`] finalizing the file.
|
||||
/// Write operations may be aggressively buffered.
|
||||
/// The client of this trait is responsible for calling terminate
|
||||
/// to ensure that subsequent `read` operations
|
||||
/// will take into account preceding `write` operations.
|
||||
///
|
||||
/// The user shall not rely on [`Drop`] triggering terminate.
|
||||
///
|
||||
/// The file may not previously exist.
|
||||
fn open_write(&self, path: &Path) -> Result<WritePtr, OpenWriteError>;
|
||||
|
||||
@@ -126,9 +126,9 @@ impl Footer {
|
||||
}
|
||||
|
||||
pub(crate) struct FooterProxy<W: TerminatingWrite> {
|
||||
/// Always `Some` except after `terminate()` is called.
|
||||
/// always Some except after terminate call
|
||||
hasher: Option<Hasher>,
|
||||
/// Always `Some` except after `terminate()` is called.
|
||||
/// always Some except after terminate call
|
||||
writer: Option<W>,
|
||||
}
|
||||
|
||||
|
||||
@@ -318,7 +318,8 @@ impl Drop for ReleaseLockFile {
|
||||
}
|
||||
}
|
||||
|
||||
/// Wraps a file and syncs its data when the writer is terminated.
|
||||
/// This Write wraps a File, but has the specificity of
|
||||
/// calling `sync_all` on terminate.
|
||||
struct SafeFileWriter(File);
|
||||
|
||||
impl SafeFileWriter {
|
||||
|
||||
@@ -60,7 +60,7 @@ impl Drop for MemoryUsageTracker {
|
||||
|
||||
/// Writer associated with the [`RamDirectory`].
|
||||
///
|
||||
/// The writer stores its buffer in the directory when terminated.
|
||||
/// The Writer just writes a buffer.
|
||||
struct VecWriter {
|
||||
path: PathBuf,
|
||||
shared_directory: RamDirectory,
|
||||
@@ -109,8 +109,6 @@ impl Write for VecWriter {
|
||||
Ok(buf.len())
|
||||
}
|
||||
|
||||
/// Nothing to flush since the data is stored in memory. The memory usage is updated on each
|
||||
/// write.
|
||||
fn flush(&mut self) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::DocId;
|
||||
/// Write an alive `BitSet`
|
||||
///
|
||||
/// where `alive_bitset` is the set of alive `DocId`.
|
||||
/// Warning: this function does not call `terminate()`. The caller is in charge of
|
||||
/// Warning: this function does not call terminate. The caller is in charge of
|
||||
/// closing the writer properly.
|
||||
pub fn write_alive_bitset<T: Write>(alive_bitset: &BitSet, writer: &mut T) -> io::Result<()> {
|
||||
alive_bitset.serialize(writer)?;
|
||||
|
||||
@@ -86,8 +86,8 @@ impl<W: io::Write> PositionSerializer<W> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Close the positions for this field.
|
||||
pub fn close(self) -> io::Result<()> {
|
||||
Ok(())
|
||||
/// Close the positions for this term and flushes the data.
|
||||
pub fn close(mut self) -> io::Result<()> {
|
||||
self.positions_wrt.flush()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user