chore: Remove the NewIndexEvent type

This commit is contained in:
Clément Renault 2019-04-25 11:44:38 +02:00
parent 3dc057ca9c
commit 74acf83464
No known key found for this signature in database
GPG Key ID: 0151CDAB43460DAE
2 changed files with 0 additions and 46 deletions

View File

@ -1,45 +0,0 @@
use std::error::Error;
use byteorder::{ReadBytesExt, WriteBytesExt};
use meilidb_core::{Index as WordIndex};
use meilidb_core::data::DocIds;
use meilidb_core::write_to_bytes::WriteToBytes;
use meilidb_core::shared_data_cursor::{SharedDataCursor, FromSharedDataCursor};
enum NewIndexEvent<'a, S> {
RemovedDocuments(&'a DocIds),
UpdatedDocuments(&'a WordIndex<S>),
}
impl<'a, S> WriteToBytes for NewIndexEvent<'a, S> {
fn write_to_bytes(&self, bytes: &mut Vec<u8>) {
match self {
NewIndexEvent::RemovedDocuments(doc_ids) => {
let _ = bytes.write_u8(0);
doc_ids.write_to_bytes(bytes);
},
NewIndexEvent::UpdatedDocuments(index) => {
let _ = bytes.write_u8(1);
// index.write_to_bytes(bytes);
}
}
}
}
enum IndexEvent<S> {
RemovedDocuments(DocIds),
UpdatedDocuments(WordIndex<S>),
}
impl<S> FromSharedDataCursor for IndexEvent<S> {
type Error = Box<Error>;
fn from_shared_data_cursor(cursor: &mut SharedDataCursor) -> Result<Self, Self::Error> {
match cursor.read_u8()? {
0 => DocIds::from_shared_data_cursor(cursor).map(IndexEvent::RemovedDocuments),
// 1 => WordIndex::from_shared_data_cursor(cursor).map(IndexEvent::UpdatedDocuments),
_ => Err("invalid index event type".into()),
}
}
}

View File

@ -1,5 +1,4 @@
mod database;
mod index_event;
mod indexer;
mod number;
mod ranked_map;