diff --git a/arrow-row/src/lib.rs b/arrow-row/src/lib.rs index 182481f42b4d..17ede5a0c466 100644 --- a/arrow-row/src/lib.rs +++ b/arrow-row/src/lib.rs @@ -1221,7 +1221,7 @@ struct RowConfig { /// A row-oriented representation of arrow data, that is normalized for comparison. /// /// See the [module level documentation](self) and [`RowConverter`] for more details. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Rows { /// Underlying row bytes buffer: Vec, diff --git a/arrow/benches/row_format.rs b/arrow/benches/row_format.rs index f33d8d16b81f..6615a4d2307c 100644 --- a/arrow/benches/row_format.rs +++ b/arrow/benches/row_format.rs @@ -61,6 +61,29 @@ fn do_bench(c: &mut Criterion, name: &str, cols: Vec) { b.iter(|| hint::black_box(converter.convert_rows(&rows).unwrap())); }); + // Benchmark parsing strings which may need utf8 validation. + fn is_stringlike(array: &ArrayRef) -> bool { + matches!(array.data_type(), DataType::Utf8 | DataType::Utf8View) + } + if cols.iter().all(is_stringlike) { + // RowParser marks rows as requiring UTF-8 validation when they are decoded + // back into Arrow arrays by RowConverter::convert_rows. + let parser = converter.parser(); + let parsed_rows: Vec<_> = rows + .iter() + .map(|row| parser.parse(row.as_ref()).owned()) + .collect(); + c.bench_function(&format!("convert_rows_parsed {name}"), |b| { + b.iter(|| { + hint::black_box( + converter + .convert_rows(parsed_rows.iter().map(|row| row.row())) + .unwrap(), + ) + }); + }); + } + let mut rows = converter.empty_rows(0, 0); c.bench_function(&format!("append_rows {name}"), |b| { let cols = cols.clone();