Skip to main content

fast_cache/storage/embedded_store_sharded/
bootstrap.rs

1use super::*;
2
3impl WorkerLocalEmbeddedStoreBootstrap {
4    pub fn from_embedded(store: EmbeddedStore, worker_count: usize) -> Self {
5        store.into_local_store_bootstrap(worker_count)
6    }
7
8    pub fn len(&self) -> usize {
9        self.stores.len()
10    }
11
12    pub fn is_empty(&self) -> bool {
13        self.stores.is_empty()
14    }
15
16    pub fn into_stores(self) -> Vec<WorkerLocalEmbeddedStore> {
17        self.stores
18    }
19}
20
21impl EmbeddedStore {
22    /// Partition this store into worker-local embedded stores.
23    pub fn into_local_store_bootstrap(
24        self,
25        worker_count: usize,
26    ) -> WorkerLocalEmbeddedStoreBootstrap {
27        WorkerLocalEmbeddedStoreBootstrap {
28            stores: self
29                .into_owned_workers(worker_count)
30                .into_iter()
31                .map(WorkerLocalEmbeddedStore::from_owned_worker)
32                .collect(),
33        }
34    }
35
36    /// Partition this store and return the worker-local stores directly.
37    pub fn into_local_stores(self, worker_count: usize) -> Vec<WorkerLocalEmbeddedStore> {
38        self.into_local_store_bootstrap(worker_count).into_stores()
39    }
40}