Database schema optimization - part 8
This commit is contained in:
@@ -19,9 +19,8 @@ use directory::{
|
||||
};
|
||||
use mail_send::Credentials;
|
||||
use store::{
|
||||
BitmapKey, Store, ValueKey,
|
||||
roaring::RoaringBitmap,
|
||||
write::{BatchBuilder, BitmapClass, ValueClass},
|
||||
IndexKeyPrefix, IterateParams, Store, ValueKey,
|
||||
write::{BatchBuilder, ValueClass},
|
||||
};
|
||||
use types::collection::Collection;
|
||||
|
||||
@@ -655,7 +654,7 @@ async fn internal_directory() {
|
||||
BatchBuilder::new()
|
||||
.with_account_id(account_id)
|
||||
.with_collection(Collection::Email)
|
||||
.create_document(document_id)
|
||||
.with_document(document_id)
|
||||
.set(ValueClass::Property(0), "hello".as_bytes())
|
||||
.build_all(),
|
||||
)
|
||||
@@ -707,18 +706,7 @@ async fn internal_directory() {
|
||||
.map(|s| s.into())
|
||||
.collect::<AHashSet<_>>()
|
||||
);
|
||||
assert_eq!(
|
||||
store
|
||||
.get_bitmap(BitmapKey {
|
||||
account_id: john_id,
|
||||
collection: Collection::Email.into(),
|
||||
class: BitmapClass::DocumentIds,
|
||||
document_id: 0
|
||||
})
|
||||
.await
|
||||
.unwrap(),
|
||||
None
|
||||
);
|
||||
assert!(!account_has_emails(&store, john_id).await);
|
||||
assert_eq!(
|
||||
store
|
||||
.get_value::<String>(ValueKey {
|
||||
@@ -742,18 +730,7 @@ async fn internal_directory() {
|
||||
store.rcpt("jane@example.org").await.unwrap(),
|
||||
RcptType::Mailbox
|
||||
);
|
||||
assert_eq!(
|
||||
store
|
||||
.get_bitmap(BitmapKey {
|
||||
account_id: jane_id,
|
||||
collection: Collection::Email.into(),
|
||||
class: BitmapClass::DocumentIds,
|
||||
document_id: 0
|
||||
})
|
||||
.await
|
||||
.unwrap(),
|
||||
Some(RoaringBitmap::from_sorted_iter([document_id]).unwrap())
|
||||
);
|
||||
assert!(account_has_emails(&store, jane_id).await);
|
||||
assert_eq!(
|
||||
store
|
||||
.get_value::<String>(ValueKey {
|
||||
@@ -1026,6 +1003,33 @@ impl TestInternalDirectory for Store {
|
||||
}
|
||||
}
|
||||
|
||||
async fn account_has_emails(store: &Store, account_id: u32) -> bool {
|
||||
let mut has_emails = false;
|
||||
store
|
||||
.iterate(
|
||||
IterateParams::new(
|
||||
IndexKeyPrefix {
|
||||
account_id,
|
||||
collection: Collection::Email.into(),
|
||||
field: 0,
|
||||
},
|
||||
IndexKeyPrefix {
|
||||
account_id,
|
||||
collection: Collection::Email.into(),
|
||||
field: u8::MAX,
|
||||
},
|
||||
)
|
||||
.no_values(),
|
||||
|_, _| {
|
||||
has_emails = true;
|
||||
Ok(false)
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
has_emails
|
||||
}
|
||||
|
||||
async fn assert_list_members(
|
||||
store: &Store,
|
||||
list_addr: &str,
|
||||
|
||||
Reference in New Issue
Block a user