@@ -130,24 +130,21 @@ pub(crate) async fn save_chunk_internal(world: &World, chunk: Chunk) -> Result<(
130130 Ok ( ( ) )
131131}
132132
133- use rayon:: prelude:: * ;
134-
135133pub ( crate ) async fn save_chunk_internal_batch (
136134 world : & World ,
137135 chunks : Vec < Chunk > ,
138136) -> Result < ( ) , WorldError > {
139- // Prepare the batch data for the upsert using rayon's parallel iterator
140- let batch_data: Vec < _ > = chunks
141- . par_iter ( ) // parallel iterator over chunks
142- . map ( |chunk| {
143- // Compress the chunk and encode it
144- let as_bytes = world. compressor . compress ( & bitcode:: encode ( chunk) ) ?;
145- // Create the key for the chunk
146- let digest = create_key ( chunk. dimension . as_str ( ) , chunk. x , chunk. z ) ;
147- // Return the key-value pair
148- Ok ( ( digest, as_bytes) )
149- } )
150- . collect :: < Result < Vec < _ > , WorldError > > ( ) ?; // Collect into Result<Vec<_>>
137+ // Prepare the batch data for the upsert
138+ let mut batch_data = Vec :: new ( ) ;
139+
140+ for chunk in chunks. iter ( ) {
141+ // Compress the chunk and encode it
142+ let as_bytes = world. compressor . compress ( & bitcode:: encode ( chunk) ) ?;
143+ // Create the key for the chunk
144+ let digest = create_key ( chunk. dimension . as_str ( ) , chunk. x , chunk. z ) ;
145+ // Collect the key-value pair into the batch data
146+ batch_data. push ( ( digest, as_bytes) ) ;
147+ }
151148
152149 // Perform the batch upsert
153150 world
0 commit comments