From 045ea17c8db4ea6c03a2abd1e2acf49946cc17a2 Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Thu, 10 Apr 2025 09:08:05 -0700 Subject: [PATCH] Use the pool when creating a chunkedwriter. --- crates/core/src/host/instance_env.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/core/src/host/instance_env.rs b/crates/core/src/host/instance_env.rs index a5d7755b7c..c7a0025dc1 100644 --- a/crates/core/src/host/instance_env.rs +++ b/crates/core/src/host/instance_env.rs @@ -115,6 +115,14 @@ impl ChunkedWriter { } } + /// Creates a new `ChunkedWriter` with an empty chunk allocated from the pool. + fn new(pool: &mut ChunkPool) -> Self { + Self { + chunks: Vec::new(), + curr: pool.take(), + } + } + /// Finalises the writer and returns all the chunks. fn into_chunks(mut self) -> Vec> { if !self.curr.is_empty() { @@ -129,7 +137,7 @@ impl ChunkedWriter { rows_scanned: &mut usize, bytes_scanned: &mut usize, ) -> Vec> { - let mut chunked_writer = Self::default(); + let mut chunked_writer = Self::new(pool); // Consume the iterator, serializing each `item`, // while allowing a chunk to be created at boundaries. for item in iter {