/// Returns a serializable version of this map. All chunks are serialized with `bincode`, then compressed using some
/// `BytesCompression`. This can be used to serialize any kind of `ChunkMap`, regardless of chunk storage.
Returns a serializable version of this map. All chunks are serialized with `bincode`, then compressed using some
`BytesCompression`. This can be used to serialize any kind of `ChunkMap`, regardless of chunk storage.
Returns a serializable version of this map . All chunks are serialized with ` bincode ` then compressed using some ` BytesCompression ` . This can be used to serialize any kind of ` ChunkMap ` regardless of chunk storage .
pub async fn from_chunk_map<Store>(
        compression: BincodeCompression<Chunk<N, T, Meta>, B>,
        map: ChunkMap<N, T, Meta, Store>,
    ) -> Self
    where
        BincodeCompression<Chunk<N, T, Meta>, B>: Copy, // TODO: this should be inferred
        Store: IntoIterator<Item = (PointN<N>, Chunk<N, T, Meta>)>,
    {
        let builder = map.builder();
        let storage = map.take_storage();
        // Only do one parallel batch at a time to avoid decompressing the entire map at once (assuming the underlying storage
        // does compression).
        let mut compressed_chunks = FnvHashMap::default();
        for batch_of_chunks in &storage.into_iter().chunks(16) {
            for (key, compressed_chunk) in join_all(
                batch_of_chunks
                    .into_iter()
                    .map(|(key, chunk)| async move { (key, compression.compress(&chunk)) }),
            )
            .await
            .into_iter()
            {
                compressed_chunks.insert(key, compressed_chunk);
            }
        }
        Self {
            builder,
            compressed_chunks,
        }
    }
pub async fn from_chunk_map < Store > ( compression : BincodeCompression < Chunk < N , T , Meta > , B > , map : ChunkMap < N , T , Meta , Store > , ) -> Self where BincodeCompression < Chunk < N , T , Meta > , B > : Copy , // TODO: this should be inferred Store : IntoIterator < Item = ( PointN < N > , Chunk < N , T , Meta > ) > , { let builder = map . builder ( ) ; let storage = map . take_storage ( ) ; // Only do one parallel batch at a time to avoid decompressing the entire map at once (assuming the underlying storage // does compression). let mut compressed_chunks = FnvHashMap :: default ( ) ; for batch_of_chunks in & storage . into_iter ( ) . chunks ( 16 ) { for ( key , compressed_chunk ) in join_all ( batch_of_chunks . into_iter ( ) . map ( | ( key , chunk ) | async move { ( key , compression . compress ( & chunk ) ) } ) , ) . await . into_iter ( ) { compressed_chunks . insert ( key , compressed_chunk ) ; } } Self { builder , compressed_chunks , } }
Returns a serializable version of this map.
Returns a serializable version of this map .
compression
BincodeCompression<Chunk<N, T, Meta>, B>
map
ChunkMap<N, T, Meta, Store>