Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ coverage.xml
*.cover
*.py,cover
.hypothesis/
# hegeltest's example database, the Rust equivalent of .hypothesis/
.hegel/
.pytest_cache/
cover/

Expand Down
85 changes: 83 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ glob = "0.3.2"
goldenfile = "1"
half = { version = "2.7.1", features = ["std", "num-traits"] }
hashbrown = "0.17.1"
hegeltest = "0.28.7"
http = "1.5.0"
humansize = "2.1.3"
indicatif = "0.18.0"
Expand Down
2 changes: 2 additions & 0 deletions encodings/decimal-byte-parts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ vortex-session = { workspace = true }

[dev-dependencies]
divan = { workspace = true }
hegeltest = { workspace = true }
rand = { workspace = true }
rstest = { workspace = true }
vortex-array = { path = "../../vortex-array", features = ["_test-harness"] }
vortex-bench-support = { workspace = true }

[[bench]]
name = "dbp_assemble"
Expand Down
80 changes: 53 additions & 27 deletions encodings/decimal-byte-parts/benches/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,51 +1,77 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

//! Shared decimal inputs for splitting and assembly benchmarks.
//! Shared inputs for splitting and assembly benchmarks.

use rand::RngExt;
use rand::SeedableRng;
use rand::rngs::StdRng;
use vortex_array::arrays::DecimalArray;
use vortex_array::dtype::DecimalDType;
use vortex_array::dtype::DecimalType;
use vortex_array::dtype::i256;
use vortex_array::validity::Validity;
use vortex_buffer::Buffer;
use vortex_error::vortex_panic;

pub(super) fn cases() -> Vec<(DecimalType, usize)> {
[DecimalType::I64, DecimalType::I128, DecimalType::I256]
[DecimalType::I128, DecimalType::I256]
.into_iter()
.flat_map(|values_type| [1_024, 8_192].map(|len| (values_type, len)))
.collect()
}

pub(super) fn decimal_array(
values_type: DecimalType,
len: usize,
validity: Validity,
) -> DecimalArray {
pub(super) fn i128_values(len: usize) -> Buffer<i128> {
let mut rng = StdRng::seed_from_u64(42);
let max = 10i128.pow(38) - 1;
(0..len).map(|_| rng.random_range(-max..=max)).collect()
}

pub(super) fn i256_values(len: usize) -> Buffer<i256> {
let mut rng = StdRng::seed_from_u64(42);
// Keep the magnitude below 10^76 while exercising all four signed/unsigned words.
(0..len)
.map(|_| i256::from_parts(rng.random(), rng.random::<i128>() >> 4))
.collect()
}

#[cfg(not(codspeed))]
pub(super) mod arrays {
use rand::RngExt;
use rand::SeedableRng;
use rand::rngs::StdRng;
use vortex_array::arrays::DecimalArray;
use vortex_array::dtype::DecimalDType;
use vortex_array::dtype::DecimalType;
use vortex_array::validity::Validity;
use vortex_buffer::Buffer;
use vortex_error::vortex_panic;

use super::i128_values;
use super::i256_values;

macro_rules! decimal {
($T:ty, $precision:literal) => {{
let max = <$T>::pow(10, $precision) - 1;
let values: Buffer<$T> = (0..len).map(|_| rng.random_range(-max..=max)).collect();
DecimalArray::new(values, DecimalDType::new($precision, 2), validity)
}};
pub(crate) fn cases() -> Vec<(DecimalType, usize)> {
[DecimalType::I64, DecimalType::I128, DecimalType::I256]
.into_iter()
.flat_map(|values_type| [1_024, 8_192].map(|len| (values_type, len)))
.collect()
}

match values_type {
DecimalType::I64 => decimal!(i64, 18),
DecimalType::I128 => decimal!(i128, 38),
DecimalType::I256 => {
// Keep the magnitude below 10^76 while exercising all four signed/unsigned words.
let values: Buffer<i256> = (0..len)
.map(|_| i256::from_parts(rng.random(), rng.random::<i128>() >> 4))
.collect();
DecimalArray::new(values, DecimalDType::new(76, 2), validity)
pub(crate) fn decimal_array(
values_type: DecimalType,
len: usize,
validity: Validity,
) -> DecimalArray {
match values_type {
DecimalType::I64 => {
let mut rng = StdRng::seed_from_u64(42);
let max = 10i64.pow(18) - 1;
let values: Buffer<i64> = (0..len).map(|_| rng.random_range(-max..=max)).collect();
DecimalArray::new(values, DecimalDType::new(18, 2), validity)
}
DecimalType::I128 => {
DecimalArray::new(i128_values(len), DecimalDType::new(38, 2), validity)
}
DecimalType::I256 => {
DecimalArray::new(i256_values(len), DecimalDType::new(76, 2), validity)
}
_ => vortex_panic!("unsupported benchmark storage type: {values_type}"),
}
_ => vortex_panic!("unsupported benchmark storage type: {values_type}"),
}
}
Loading
Loading