Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
use arrow_buffer::bit_mask::set_bits;
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use std::hint;
fn criterion_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("bit_mask");
for offset_write in [0, 5] {
for offset_read in [0, 5] {
for len in [1, 17, 65] {
for datum in [0u8, 0xADu8] {
let x = (offset_write, offset_read, len, datum);
group.bench_with_input(
BenchmarkId::new(
"set_bits",
format!(
"offset_write_{}_offset_read_{}_len_{}_datum_{}",
x.0, x.1, x.2, x.3
),
),
&x,
|b, &x| {
b.iter(|| {
set_bits(
hint::black_box(&mut [0u8; 9]),
hint::black_box(&[x.3; 9]),
hint::black_box(x.0),
hint::black_box(x.1),
hint::black_box(x.2),
)
});
},
);
}
}
}
}
group.finish();
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);
+93
View File
@@ -0,0 +1,93 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
use arrow_buffer::i256;
use criterion::*;
use num_traits::cast::ToPrimitive;
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use std::{hint, str::FromStr};
const SIZE: usize = 1024;
fn criterion_benchmark(c: &mut Criterion) {
let numbers = vec![
i256::ZERO,
i256::ONE,
i256::MINUS_ONE,
i256::from_i128(1233456789),
i256::from_i128(-1233456789),
i256::from_i128(i128::MAX),
i256::from_i128(i128::MIN),
i256::MIN,
i256::MAX,
];
for number in numbers.iter() {
let t = hint::black_box(number.to_string());
c.bench_function(&format!("i256_parse({t})"), |b| {
b.iter(|| i256::from_str(&t).unwrap());
});
}
for number in numbers.iter() {
c.bench_function(&format!("i256_to_f64({number})"), |b| {
b.iter(|| (*number).to_f64().unwrap())
});
}
let mut rng = StdRng::seed_from_u64(42);
let numerators: Vec<_> = (0..SIZE)
.map(|_| {
let high = rng.random_range(1000..i128::MAX);
let low = rng.random();
i256::from_parts(low, high)
})
.collect();
let divisors: Vec<_> = numerators
.iter()
.map(|n| {
let quotient = rng.random_range(1..100_i32);
n.wrapping_div(i256::from(quotient))
})
.collect();
c.bench_function("i256_div_rem small quotient", |b| {
b.iter(|| {
for (n, d) in numerators.iter().zip(&divisors) {
hint::black_box(n.wrapping_div(*d));
}
});
});
let divisors: Vec<_> = (0..SIZE)
.map(|_| i256::from(rng.random_range(1..100_i32)))
.collect();
c.bench_function("i256_div_rem small divisor", |b| {
b.iter(|| {
for (n, d) in numerators.iter().zip(&divisors) {
hint::black_box(n.wrapping_div(*d));
}
});
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);
@@ -0,0 +1,76 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
use arrow_buffer::Buffer;
use criterion::*;
use rand::distr::Alphanumeric;
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use std::hint;
fn criterion_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("MutableBuffer repeat slice");
let mut rng = StdRng::seed_from_u64(42);
for slice_length in [3, 20, 100] {
let slice_to_repeat: Vec<u8> = hint::black_box(
(&mut rng)
.sample_iter(&Alphanumeric)
.take(slice_length)
.collect(),
);
let slice_to_repeat: &[u8] = slice_to_repeat.as_ref();
for repeat_count in [3, 64, 1024, 8192] {
let parameter_string = format!("slice_len={slice_length} n={repeat_count}");
group.bench_with_input(
BenchmarkId::new("repeat_slice_n_times", &parameter_string),
&(repeat_count),
|b, &repeat_count| {
b.iter(|| {
let mut mutable_buffer = arrow_buffer::MutableBuffer::with_capacity(0);
mutable_buffer.repeat_slice_n_times(slice_to_repeat, repeat_count);
Buffer::from(mutable_buffer)
})
},
);
group.bench_with_input(
BenchmarkId::new("extend_from_slice loop", &parameter_string),
&(repeat_count),
|b, &repeat_count| {
b.iter(|| {
let mut mutable_buffer = arrow_buffer::MutableBuffer::with_capacity(
size_of_val(slice_to_repeat) * repeat_count,
);
for _ in 0..repeat_count {
mutable_buffer.extend_from_slice(slice_to_repeat);
}
Buffer::from(mutable_buffer)
})
},
);
}
}
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);
+50
View File
@@ -0,0 +1,50 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
use arrow_buffer::{OffsetBuffer, OffsetBufferBuilder};
use criterion::*;
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use std::hint;
const SIZE: usize = 1024;
fn criterion_benchmark(c: &mut Criterion) {
let mut rng = StdRng::seed_from_u64(42);
let lengths: Vec<usize> = hint::black_box((0..SIZE).map(|_| rng.random_range(0..40)).collect());
c.bench_function("OffsetBuffer::from_lengths", |b| {
b.iter(|| OffsetBuffer::<i32>::from_lengths(lengths.iter().copied()));
});
c.bench_function("OffsetBufferBuilder::push_length", |b| {
b.iter(|| {
let mut builder = OffsetBufferBuilder::<i32>::new(lengths.len());
lengths.iter().for_each(|x| builder.push_length(*x));
builder.finish()
});
});
let offsets = OffsetBuffer::<i32>::from_lengths(lengths.iter().copied()).into_inner();
c.bench_function("OffsetBuffer::new", |b| {
b.iter(|| OffsetBuffer::new(hint::black_box(offsets.clone())));
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);