mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-11-09 13:25:29 +08:00
Refresh old FoundationDB read transactions (code cleanup)
This commit is contained in:
parent
b53c3d120e
commit
56ca136aa6
2 changed files with 6 additions and 8 deletions
|
|
@ -85,10 +85,9 @@ impl FdbStore {
|
||||||
let end = params.end.serialize(WITH_SUBSPACE);
|
let end = params.end.serialize(WITH_SUBSPACE);
|
||||||
|
|
||||||
if !params.first {
|
if !params.first {
|
||||||
let mut has_more = true;
|
|
||||||
let mut begin_selector = KeySelector::first_greater_or_equal(&begin);
|
let mut begin_selector = KeySelector::first_greater_or_equal(&begin);
|
||||||
|
|
||||||
while has_more {
|
loop {
|
||||||
let mut last_key_bytes = None;
|
let mut last_key_bytes = None;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -105,7 +104,6 @@ impl FdbStore {
|
||||||
);
|
);
|
||||||
|
|
||||||
while let Some(values) = values.try_next().await? {
|
while let Some(values) = values.try_next().await? {
|
||||||
has_more = values.more();
|
|
||||||
let mut last_key = &[] as &[u8];
|
let mut last_key = &[] as &[u8];
|
||||||
|
|
||||||
for value in values.iter() {
|
for value in values.iter() {
|
||||||
|
|
@ -115,7 +113,7 @@ impl FdbStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if has_more && trx.is_expired() {
|
if values.more() && trx.is_expired() {
|
||||||
last_key_bytes = last_key.to_vec().into();
|
last_key_bytes = last_key.to_vec().into();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,14 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::{collections::HashSet, time::Duration};
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use jmap_proto::types::{collection::Collection, property::Property};
|
use jmap_proto::types::{collection::Collection, property::Property};
|
||||||
use store::{
|
use store::{
|
||||||
write::{
|
write::{
|
||||||
BatchBuilder, BitmapClass, DirectoryClass, MaybeDynamicId, TagValue, ValueClass, F_CLEAR,
|
BatchBuilder, BitmapClass, DirectoryClass, MaybeDynamicId, TagValue, ValueClass, F_CLEAR,
|
||||||
},
|
},
|
||||||
BitmapKey, IterateParams, Store, ValueKey,
|
BitmapKey, Store, ValueKey,
|
||||||
};
|
};
|
||||||
|
|
||||||
// FDB max value
|
// FDB max value
|
||||||
|
|
@ -49,7 +49,7 @@ pub async fn test(db: Store) {
|
||||||
// Iterate over all keys
|
// Iterate over all keys
|
||||||
let mut n = 0;
|
let mut n = 0;
|
||||||
db.iterate(
|
db.iterate(
|
||||||
IterateParams::new(
|
store::IterateParams::new(
|
||||||
ValueKey {
|
ValueKey {
|
||||||
account_id: 0,
|
account_id: 0,
|
||||||
collection: 0,
|
collection: 0,
|
||||||
|
|
@ -69,7 +69,7 @@ pub async fn test(db: Store) {
|
||||||
n += 1;
|
n += 1;
|
||||||
if n % 10000 == 0 {
|
if n % 10000 == 0 {
|
||||||
println!("Iterated over {n} keys");
|
println!("Iterated over {n} keys");
|
||||||
std::thread::sleep(Duration::from_millis(1000));
|
std::thread::sleep(std::time::Duration::from_millis(1000));
|
||||||
}
|
}
|
||||||
Ok(true)
|
Ok(true)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue