mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-24 03:53:09 +08:00
96 lines
1.9 KiB
Rust
96 lines
1.9 KiB
Rust
use heed::RoTxn;
|
|
use obkv::KvReader;
|
|
|
|
use super::indexer::KvReaderFieldId;
|
|
use crate::{DocumentId, FieldId};
|
|
|
|
pub enum DocumentChange {
|
|
Deletion(Deletion),
|
|
Update(Update),
|
|
Insertion(Insertion),
|
|
}
|
|
|
|
pub struct Deletion {
|
|
docid: DocumentId,
|
|
external_docid: String, // ?
|
|
current: Box<KvReaderFieldId>,
|
|
}
|
|
|
|
pub struct Update {
|
|
docid: DocumentId,
|
|
external_docid: String, // ?
|
|
current: Box<KvReaderFieldId>,
|
|
new: Box<KvReaderFieldId>,
|
|
}
|
|
|
|
pub struct Insertion {
|
|
docid: DocumentId,
|
|
external_docid: String, // ?
|
|
new: Box<KvReaderFieldId>,
|
|
}
|
|
|
|
impl DocumentChange {
|
|
fn docid(&self) -> DocumentId {
|
|
match &self {
|
|
Self::Deletion(inner) => inner.docid(),
|
|
Self::Update(inner) => inner.docid(),
|
|
Self::Insertion(inner) => inner.docid(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Deletion {
|
|
pub fn create(
|
|
docid: DocumentId,
|
|
external_docid: String,
|
|
current: Box<KvReaderFieldId>,
|
|
) -> Self {
|
|
Self { docid, external_docid, current }
|
|
}
|
|
|
|
fn docid(&self) -> DocumentId {
|
|
self.docid
|
|
}
|
|
|
|
fn current(&self, rtxn: &RoTxn) -> &KvReader<FieldId> {
|
|
unimplemented!()
|
|
}
|
|
}
|
|
|
|
impl Insertion {
|
|
pub fn create(docid: DocumentId, external_docid: String, new: Box<KvReaderFieldId>) -> Self {
|
|
Insertion { docid, external_docid, new }
|
|
}
|
|
|
|
fn docid(&self) -> DocumentId {
|
|
self.docid
|
|
}
|
|
|
|
fn new(&self) -> &KvReader<FieldId> {
|
|
unimplemented!()
|
|
}
|
|
}
|
|
|
|
impl Update {
|
|
pub fn create(
|
|
docid: DocumentId,
|
|
external_docid: String,
|
|
current: Box<KvReaderFieldId>,
|
|
new: Box<KvReaderFieldId>,
|
|
) -> Self {
|
|
Update { docid, external_docid, current, new }
|
|
}
|
|
|
|
fn docid(&self) -> DocumentId {
|
|
self.docid
|
|
}
|
|
|
|
fn current(&self, rtxn: &RoTxn) -> &KvReader<FieldId> {
|
|
unimplemented!()
|
|
}
|
|
|
|
fn new(&self) -> &KvReader<FieldId> {
|
|
unimplemented!()
|
|
}
|
|
}
|