How I stopped worrying and learned to love zero-copy deserialization
This commit is contained in:
@@ -8,7 +8,6 @@ resolver = "2"
|
||||
store = { path = "../store" }
|
||||
common = { path = "../common" }
|
||||
directory = { path = "../directory" }
|
||||
jmap = { path = "../jmap" }
|
||||
imap = { path = "../imap" }
|
||||
utils = { path = "../utils" }
|
||||
trc = { path = "../trc" }
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use common::listener::SessionStream;
|
||||
use email::mailbox::{INBOX_ID, UidMailbox, manage::MailboxFnc};
|
||||
use email::mailbox::{ArchivedMailbox, INBOX_ID, UidMailbox, manage::MailboxFnc};
|
||||
use jmap_proto::types::{collection::Collection, property::Property};
|
||||
use store::{
|
||||
IndexKey, IterateParams, Serialize, U32_LEN, ahash::AHashMap, write::key::DeserializeBigEndian,
|
||||
IndexKey, IterateParams, SerializeInfallible, U32_LEN,
|
||||
ahash::AHashMap,
|
||||
write::{ArchivedValue, key::DeserializeBigEndian},
|
||||
};
|
||||
use trc::AddContext;
|
||||
|
||||
@@ -59,24 +61,27 @@ impl<T: SessionStream> Session<T> {
|
||||
.mailbox_get_or_create(account_id)
|
||||
.await
|
||||
.caused_by(trc::location!())?;
|
||||
let uid_validity = self
|
||||
.server
|
||||
.get_property::<email::mailbox::Mailbox>(
|
||||
account_id,
|
||||
Collection::Mailbox,
|
||||
INBOX_ID,
|
||||
&Property::Value,
|
||||
)
|
||||
.await
|
||||
.caused_by(trc::location!())?
|
||||
.ok_or_else(|| {
|
||||
trc::StoreEvent::UnexpectedError
|
||||
.caused_by(trc::location!())
|
||||
.details("Failed to obtain UID validity")
|
||||
.account_id(account_id)
|
||||
.document_id(INBOX_ID)
|
||||
})?
|
||||
.uid_validity;
|
||||
let uid_validity = u32::from(
|
||||
self.server
|
||||
.get_property::<ArchivedValue<ArchivedMailbox>>(
|
||||
account_id,
|
||||
Collection::Mailbox,
|
||||
INBOX_ID,
|
||||
&Property::Value,
|
||||
)
|
||||
.await
|
||||
.caused_by(trc::location!())?
|
||||
.ok_or_else(|| {
|
||||
trc::StoreEvent::UnexpectedError
|
||||
.caused_by(trc::location!())
|
||||
.details("Failed to obtain UID validity")
|
||||
.account_id(account_id)
|
||||
.document_id(INBOX_ID)
|
||||
})?
|
||||
.unarchive()
|
||||
.caused_by(trc::location!())?
|
||||
.uid_validity,
|
||||
);
|
||||
|
||||
// Obtain message sizes
|
||||
self.server
|
||||
|
||||
@@ -9,7 +9,6 @@ use std::time::Instant;
|
||||
use common::listener::SessionStream;
|
||||
use directory::Permission;
|
||||
use email::message::metadata::MessageMetadata;
|
||||
use jmap::blob::download::BlobDownload;
|
||||
use jmap_proto::types::{collection::Collection, property::Property};
|
||||
use store::write::Bincode;
|
||||
use trc::AddContext;
|
||||
@@ -39,7 +38,8 @@ impl<T: SessionStream> Session<T> {
|
||||
{
|
||||
if let Some(bytes) = self
|
||||
.server
|
||||
.get_blob(&metadata.inner.blob_hash, 0..usize::MAX)
|
||||
.blob_store()
|
||||
.get_blob(metadata.inner.blob_hash.as_slice(), 0..usize::MAX)
|
||||
.await
|
||||
.caused_by(trc::location!())?
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user