Skip to content

chore: rmreplace_columns, unused code #1251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/event/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ pub trait EventFormat: Sized {
rb = replace_columns(
rb.schema(),
&rb,
&[0],
&[Arc::new(get_timestamp_array(p_timestamp, rb.num_rows()))],
&[(0, Arc::new(get_timestamp_array(p_timestamp, rb.num_rows())))],
);

Ok((rb, is_first))
Expand Down
12 changes: 5 additions & 7 deletions src/utils/arrow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,19 @@ use serde_json::{Map, Value};
///
/// * `schema` - The schema of the record batch.
/// * `batch` - The record batch to modify.
/// * `indexes` - The indexes of the columns to replace.
/// * `arrays` - The new arrays to replace the columns with.
/// * `indexed_arrays` - A list of indexes and arrays to replace the columns indexed with.
///
/// # Returns
///
/// The modified record batch with the columns replaced.
pub fn replace_columns(
schema: Arc<Schema>,
batch: &RecordBatch,
indexes: &[usize],
arrays: &[Arc<dyn Array + 'static>],
indexed_arrays: &[(usize, Arc<dyn Array + 'static>)],
) -> RecordBatch {
let mut batch_arrays = batch.columns().iter().map(Arc::clone).collect_vec();
for (&index, arr) in indexes.iter().zip(arrays.iter()) {
batch_arrays[index] = Arc::clone(arr);
for (index, arr) in indexed_arrays {
batch_arrays[*index] = Arc::clone(arr);
}
RecordBatch::try_new(schema, batch_arrays).unwrap()
}
Expand Down Expand Up @@ -180,7 +178,7 @@ mod tests {

let arr: Arc<dyn Array + 'static> = Arc::new(Int32Array::from_value(0, 3));

let new_rb = replace_columns(schema_ref.clone(), &rb, &[2], &[arr]);
let new_rb = replace_columns(schema_ref.clone(), &rb, &[(2, arr)]);

assert_eq!(new_rb.schema(), schema_ref);
assert_eq!(new_rb.num_columns(), 3);
Expand Down
Loading