|
18 | 18 | //! Benchmarks for SparkUnsafeArray to Arrow array conversion. |
19 | 19 | //! This specifically tests the append_to_builder function used in shuffle read path. |
20 | 20 |
|
21 | | -use arrow::array::builder::{ArrayBuilder, Int32Builder, Int64Builder, Float64Builder, Date32Builder, TimestampMicrosecondBuilder}; |
| 21 | +use arrow::array::builder::{ |
| 22 | + ArrayBuilder, Date32Builder, Float64Builder, Int32Builder, Int64Builder, |
| 23 | + TimestampMicrosecondBuilder, |
| 24 | +}; |
22 | 25 | use arrow::datatypes::{DataType, TimeUnit}; |
23 | 26 | use comet::execution::shuffle::list::{append_to_builder, SparkUnsafeArray}; |
24 | 27 | use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; |
@@ -48,7 +51,8 @@ fn create_spark_unsafe_array_i32(num_elements: usize, with_nulls: bool) -> Vec<u |
48 | 51 | let word_idx = i / 64; |
49 | 52 | let bit_idx = i % 64; |
50 | 53 | let word_offset = 8 + word_idx * 8; |
51 | | - let current_word = i64::from_le_bytes(buffer[word_offset..word_offset + 8].try_into().unwrap()); |
| 54 | + let current_word = |
| 55 | + i64::from_le_bytes(buffer[word_offset..word_offset + 8].try_into().unwrap()); |
52 | 56 | let new_word = current_word | (1i64 << bit_idx); |
53 | 57 | buffer[word_offset..word_offset + 8].copy_from_slice(&new_word.to_le_bytes()); |
54 | 58 | } |
@@ -81,7 +85,8 @@ fn create_spark_unsafe_array_i64(num_elements: usize, with_nulls: bool) -> Vec<u |
81 | 85 | let word_idx = i / 64; |
82 | 86 | let bit_idx = i % 64; |
83 | 87 | let word_offset = 8 + word_idx * 8; |
84 | | - let current_word = i64::from_le_bytes(buffer[word_offset..word_offset + 8].try_into().unwrap()); |
| 88 | + let current_word = |
| 89 | + i64::from_le_bytes(buffer[word_offset..word_offset + 8].try_into().unwrap()); |
85 | 90 | let new_word = current_word | (1i64 << bit_idx); |
86 | 91 | buffer[word_offset..word_offset + 8].copy_from_slice(&new_word.to_le_bytes()); |
87 | 92 | } |
@@ -114,7 +119,8 @@ fn create_spark_unsafe_array_f64(num_elements: usize, with_nulls: bool) -> Vec<u |
114 | 119 | let word_idx = i / 64; |
115 | 120 | let bit_idx = i % 64; |
116 | 121 | let word_offset = 8 + word_idx * 8; |
117 | | - let current_word = i64::from_le_bytes(buffer[word_offset..word_offset + 8].try_into().unwrap()); |
| 122 | + let current_word = |
| 123 | + i64::from_le_bytes(buffer[word_offset..word_offset + 8].try_into().unwrap()); |
118 | 124 | let new_word = current_word | (1i64 << bit_idx); |
119 | 125 | buffer[word_offset..word_offset + 8].copy_from_slice(&new_word.to_le_bytes()); |
120 | 126 | } |
@@ -193,7 +199,8 @@ fn benchmark_array_conversion(c: &mut Criterion) { |
193 | 199 | if with_nulls { |
194 | 200 | append_to_builder::<true>(&DataType::Float64, &mut builder, array).unwrap(); |
195 | 201 | } else { |
196 | | - append_to_builder::<false>(&DataType::Float64, &mut builder, array).unwrap(); |
| 202 | + append_to_builder::<false>(&DataType::Float64, &mut builder, array) |
| 203 | + .unwrap(); |
197 | 204 | } |
198 | 205 | builder.finish() |
199 | 206 | }); |
|
0 commit comments