pub struct Layer { /* private fields */ }Expand description
Live documents and tombstones produced by applying operations in order.
§Examples
use itzma_core::layer::Layer;
use itzma_core::{Document, WalOp};
let doc = |id: &str| Document { id: id.into(), vector: vec![1.0], attrs: None, sparse: None };
let mut older = Layer::new();
older.apply(WalOp::Upsert(doc("a")));
let mut newer = Layer::new();
newer.apply(WalOp::Delete("a".into()));
older.overlay(newer);
assert_eq!(older.doc_count(), 0);
assert_eq!(older.sorted_tombstones(), ["a"]);Implementations§
Source§impl Layer
impl Layer
Sourcepub fn apply(&mut self, op: WalOp)
pub fn apply(&mut self, op: WalOp)
Apply one operation. An upsert replaces the document and clears any tombstone for its id. A delete removes the document and records a tombstone, even when the id is not in this layer, because it may be hiding a document in an older one.
Sourcepub fn apply_entry(&mut self, entry: WalEntry)
pub fn apply_entry(&mut self, entry: WalEntry)
Apply every operation of one WAL entry, in order.
Sourcepub fn apply_log(&mut self, log: Vec<(u64, WalEntry)>)
pub fn apply_log(&mut self, log: Vec<(u64, WalEntry)>)
Apply every operation of every entry, in log order.
Sourcepub fn overlay(&mut self, newer: Layer)
pub fn overlay(&mut self, newer: Layer)
Put a newer layer on top of this one: its tombstones remove documents here, then its documents replace or add. Folding a range of operations in two halves and overlaying the results equals replaying the whole range.
Sourcepub fn drop_tombstones(&mut self)
pub fn drop_tombstones(&mut self)
Forget every tombstone. Only right for a layer with nothing older beneath it, which is a segment that starts at WAL seq 1.
Sourcepub fn tombstone_count(&self) -> usize
pub fn tombstone_count(&self) -> usize
Number of tombstones.
Sourcepub fn sorted_docs(&self) -> Vec<&Document>
pub fn sorted_docs(&self) -> Vec<&Document>
Live documents in ascending id order. Sorting is what makes an encoded segment a pure function of the layer’s contents.
Sourcepub fn sorted_tombstones(&self) -> Vec<&str>
pub fn sorted_tombstones(&self) -> Vec<&str>
Tombstoned ids in ascending order.
Trait Implementations§
impl StructuralPartialEq for Layer
Auto Trait Implementations§
impl Freeze for Layer
impl RefUnwindSafe for Layer
impl Send for Layer
impl Sync for Layer
impl Unpin for Layer
impl UnsafeUnpin for Layer
impl UnwindSafe for Layer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more