mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Move to zerocopy-lmdb
This commit is contained in:
parent
c332c7bc70
commit
1667e1b32f
25 changed files with 450 additions and 684 deletions
|
@ -14,7 +14,7 @@ use crate::DocumentId;
|
|||
#[derive(Debug)]
|
||||
pub enum DeserializerError {
|
||||
SerdeJson(SerdeJsonError),
|
||||
Rkv(rkv::StoreError),
|
||||
Zlmdb(zlmdb::Error),
|
||||
Custom(String),
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ impl fmt::Display for DeserializerError {
|
|||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
DeserializerError::SerdeJson(e) => write!(f, "serde json related error: {}", e),
|
||||
DeserializerError::Rkv(e) => write!(f, "rkv related error: {}", e),
|
||||
DeserializerError::Zlmdb(e) => write!(f, "zlmdb related error: {}", e),
|
||||
DeserializerError::Custom(s) => f.write_str(s),
|
||||
}
|
||||
}
|
||||
|
@ -42,23 +42,21 @@ impl From<SerdeJsonError> for DeserializerError {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<rkv::StoreError> for DeserializerError {
|
||||
fn from(error: rkv::StoreError) -> DeserializerError {
|
||||
DeserializerError::Rkv(error)
|
||||
impl From<zlmdb::Error> for DeserializerError {
|
||||
fn from(error: zlmdb::Error) -> DeserializerError {
|
||||
DeserializerError::Zlmdb(error)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Deserializer<'a, R> {
|
||||
pub struct Deserializer<'a> {
|
||||
pub document_id: DocumentId,
|
||||
pub reader: &'a R,
|
||||
pub reader: &'a zlmdb::RoTxn,
|
||||
pub documents_fields: DocumentsFields,
|
||||
pub schema: &'a Schema,
|
||||
pub attributes: Option<&'a HashSet<SchemaAttr>>,
|
||||
}
|
||||
|
||||
impl<'de, 'a, 'b, R: 'a> de::Deserializer<'de> for &'b mut Deserializer<'a, R>
|
||||
where R: rkv::Readable,
|
||||
{
|
||||
impl<'de, 'a, 'b> de::Deserializer<'de> for &'b mut Deserializer<'a> {
|
||||
type Error = DeserializerError;
|
||||
|
||||
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
|
|
|
@ -35,7 +35,7 @@ use crate::{DocumentId, ParseNumberError};
|
|||
pub enum SerializerError {
|
||||
DocumentIdNotFound,
|
||||
InvalidDocumentIdType,
|
||||
RkvError(rkv::StoreError),
|
||||
Zlmdb(zlmdb::Error),
|
||||
SerdeJson(SerdeJsonError),
|
||||
ParseNumber(ParseNumberError),
|
||||
UnserializableType { type_name: &'static str },
|
||||
|
@ -59,7 +59,7 @@ impl fmt::Display for SerializerError {
|
|||
SerializerError::InvalidDocumentIdType => {
|
||||
f.write_str("document identifier can only be of type string or number")
|
||||
},
|
||||
SerializerError::RkvError(e) => write!(f, "rkv related error: {}", e),
|
||||
SerializerError::Zlmdb(e) => write!(f, "zlmdb related error: {}", e),
|
||||
SerializerError::SerdeJson(e) => write!(f, "serde json error: {}", e),
|
||||
SerializerError::ParseNumber(e) => {
|
||||
write!(f, "error while trying to parse a number: {}", e)
|
||||
|
@ -92,9 +92,9 @@ impl From<SerdeJsonError> for SerializerError {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<rkv::StoreError> for SerializerError {
|
||||
fn from(error: rkv::StoreError) -> SerializerError {
|
||||
SerializerError::RkvError(error)
|
||||
impl From<zlmdb::Error> for SerializerError {
|
||||
fn from(error: zlmdb::Error) -> SerializerError {
|
||||
SerializerError::Zlmdb(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue