Skip to content

Commit c797e58

Browse files
committed
feat/bulk-insert:
Refactor `handle_bulk_insert.rs` to simplify row construction - Removed the mutable `current_row` vector and refactored `row_at` function to return a new vector directly. - Updated `record_batch_to_rows` to utilize the refactored `row_at` function for constructing rows.
1 parent b462a9e commit c797e58

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/mito2/src/worker/handle_bulk_insert.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,17 @@ fn record_batch_to_rows(
142142
})
143143
.collect::<error::Result<_>>()?;
144144

145-
let mut current_row = Vec::with_capacity(region_metadata.column_metadatas.len());
146145
for row_idx in 0..num_rows {
147-
row_at(&vectors, row_idx, &mut current_row);
148146
let row = Row {
149-
values: std::mem::take(&mut current_row),
147+
values: row_at(&vectors, row_idx),
150148
};
151149
rows.push(row);
152150
}
153151
Ok(rows)
154152
}
155153

156-
fn row_at(vectors: &[Option<VectorRef>], row_idx: usize, row: &mut Vec<api::v1::Value>) {
154+
fn row_at(vectors: &[Option<VectorRef>], row_idx: usize) -> Vec<api::v1::Value> {
155+
let mut row = Vec::with_capacity(vectors.len());
157156
for a in vectors {
158157
let value = if let Some(a) = a {
159158
value_to_grpc_value(a.get(row_idx))
@@ -162,6 +161,7 @@ fn row_at(vectors: &[Option<VectorRef>], row_idx: usize, row: &mut Vec<api::v1::
162161
};
163162
row.push(value)
164163
}
164+
row
165165
}
166166

167167
#[cfg(test)]

0 commit comments

Comments
 (0)