mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-05 16:52:55 +00:00
* fix windows build (#1) * Fix windows build * Add doc traits * Add field value iter * Add value and serialization * Adjust order * Fix bug * Correct type * Fix generic bugs * Reformat code * Add generic to index writer which I forgot about * Fix missing generics on single segment writer * Add missing type export * Add default methods for convenience * Cleanup * Fix more-like-this query to use standard types * Update API and fix tests * Add doc traits * Add field value iter * Add value and serialization * Adjust order * Fix bug * Correct type * Rebase main and fix conflicts * Reformat code * Merge upstream * Fix missing generics on single segment writer * Add missing type export * Add default methods for convenience * Cleanup * Fix more-like-this query to use standard types * Update API and fix tests * Add tokenizer improvements from previous commits * Add tokenizer improvements from previous commits * Reformat * Fix unit tests * Fix unit tests * Use enum in changes * Stage changes * Add new deserializer logic * Add serializer integration * Add document deserializer * Implement new (de)serialization api for existing types * Fix bugs and type errors * Add helper implementations * Fix errors * Reformat code * Add unit tests and some code organisation for serialization * Add unit tests to deserializer * Add some small docs * Add support for deserializing serde values * Reformat * Fix typo * Fix typo * Change repr of facet * Remove unused trait methods * Add child value type * Resolve comments * Fix build * Fix more build errors * Fix more build errors * Fix the tests I missed * Fix examples * fix numerical order, serialize PreTok Str * fix coverage * rename Document to TantivyDocument, rename DocumentAccess to Document add Binary prefix to binary de/serialization * fix coverage --------- Co-authored-by: Pascal Seitz <pascal.seitz@gmail.com>
54 lines
1.5 KiB
Rust
54 lines
1.5 KiB
Rust
use super::IndexWriter;
|
|
use crate::schema::document::Document;
|
|
use crate::{FutureResult, Opstamp, TantivyDocument};
|
|
|
|
/// A prepared commit
|
|
pub struct PreparedCommit<'a, D: Document = TantivyDocument> {
|
|
index_writer: &'a mut IndexWriter<D>,
|
|
payload: Option<String>,
|
|
opstamp: Opstamp,
|
|
}
|
|
|
|
impl<'a, D: Document> PreparedCommit<'a, D> {
|
|
pub(crate) fn new(index_writer: &'a mut IndexWriter<D>, opstamp: Opstamp) -> Self {
|
|
Self {
|
|
index_writer,
|
|
payload: None,
|
|
opstamp,
|
|
}
|
|
}
|
|
|
|
/// Returns the opstamp associated with the prepared commit.
|
|
pub fn opstamp(&self) -> Opstamp {
|
|
self.opstamp
|
|
}
|
|
|
|
/// Adds an arbitrary payload to the commit.
|
|
pub fn set_payload(&mut self, payload: &str) {
|
|
self.payload = Some(payload.to_string())
|
|
}
|
|
|
|
/// Rollbacks any change.
|
|
pub fn abort(self) -> crate::Result<Opstamp> {
|
|
self.index_writer.rollback()
|
|
}
|
|
|
|
/// Proceeds to commit.
|
|
/// See `.commit_future()`.
|
|
pub fn commit(self) -> crate::Result<Opstamp> {
|
|
self.commit_future().wait()
|
|
}
|
|
|
|
/// Proceeds to commit.
|
|
///
|
|
/// Unfortunately, contrary to what `PrepareCommit` may suggests,
|
|
/// this operation is not at all really light.
|
|
/// At this point deletes have not been flushed yet.
|
|
pub fn commit_future(self) -> FutureResult<Opstamp> {
|
|
info!("committing {}", self.opstamp);
|
|
self.index_writer
|
|
.segment_updater()
|
|
.schedule_commit(self.opstamp, self.payload)
|
|
}
|
|
}
|