pub struct NoteStore(/* private fields */);Implementations§
Source§impl NoteStore
impl NoteStore
Sourcepub fn upsert_file(&self, input: NoteFileInput) -> Result<WriteReceipt<Note>>
pub fn upsert_file(&self, input: NoteFileInput) -> Result<WriteReceipt<Note>>
按文件路径同步一篇笔记。更新就是「先删后加」:同路径已有笔记,先把旧笔记连同 它的切片整条删掉(写锁内落主库标记、删向量行与主库行,出锁后摘索引词条), 再当新笔记写入;没有就直接新增。切片记录全部新开,向量由向量对账照主库重算。
Sourcepub fn upsert_files(
&self,
inputs: &[NoteFileInput],
) -> Result<WriteReceipt<Vec<Note>>>
pub fn upsert_files( &self, inputs: &[NoteFileInput], ) -> Result<WriteReceipt<Vec<Note>>>
批量版:一次写锁包住整批的 SQL,每篇各自完整地先删后加。 索引操作(摘词条、交文档)在写锁外,由 Tantivy 自己的锁管。 文件在动库之前全部读好切好——任何一处读取失败,整批原样拒绝,库一个字节都没动。
Sourcepub fn set_root(&self, namespace: &str, root: &str) -> Result<()>
pub fn set_root(&self, namespace: &str, root: &str) -> Result<()>
登记该知识领域的笔记根目录。登记之后写入的笔记路径必须是它的子路径: 库里存相对路径,相对路径按段拆出的标签挂到这篇的每一条切片上。
Sourcepub fn unset_root(&self, namespace: &str) -> Result<bool>
pub fn unset_root(&self, namespace: &str) -> Result<bool>
注销该领域的笔记根目录登记。只影响之后写入时的路径计算,已入库的笔记不动。 返回是否命中;没登记过的领域不报错。
pub fn get(&self, id: i64, filter: &ReadFilter) -> Result<Note>
Sourcepub fn get_many(
&self,
ids: &[i64],
filter: &ReadFilter,
) -> Result<BTreeMap<i64, Note>>
pub fn get_many( &self, ids: &[i64], filter: &ReadFilter, ) -> Result<BTreeMap<i64, Note>>
批量读取一批笔记,只返回满足 filter 的那些。
语义等同于对每个 id 依次调用 get,但把过滤压成一条 SQL、一次取回,
避免宿主逐条回库的往返开销。不满足过滤条件的 id 被静默跳过(不报错)。
pub fn list(&self, page: &PageRequest) -> Result<Page<Note>>
pub fn get_chunk(&self, id: i64, filter: &ReadFilter) -> Result<Chunk>
pub fn chunks(&self, note_id: i64, filter: &ReadFilter) -> Result<Vec<Chunk>>
Sourcepub fn delete(
&self,
ids: &[i64],
filter: &ReadFilter,
) -> Result<WriteReceipt<usize>>
pub fn delete( &self, ids: &[i64], filter: &ReadFilter, ) -> Result<WriteReceipt<usize>>
批量删除笔记:主库查 id,命中才继续;单条也是批量的一种。
每篇连同它的切片一起删(chunks.note_id 是 RESTRICT 引用):
写锁内落主库标记、删向量行与主库行,出锁后摘索引词条。
断电留下「正在删除」标记的,下次开机把这条删除做完。
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for NoteStore
impl !UnwindSafe for NoteStore
impl Freeze for NoteStore
impl Send for NoteStore
impl Sync for NoteStore
impl Unpin for NoteStore
impl UnsafeUnpin for NoteStore
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
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> ⓘ
Converts
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> ⓘ
Converts
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