Skip to content
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

Robustness of attribute_enumeration_likelihood #189

Merged
merged 1 commit into from
Nov 13, 2024
Merged
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
11 changes: 7 additions & 4 deletions tiledb/pod/src/array/schema/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct Requirements {
pub offsets_filters: Option<Rc<FilterRequirements>>,
pub validity_filters: Option<Rc<FilterRequirements>>,
pub sparse_tile_capacity: std::ops::RangeInclusive<u64>,
pub attribute_enumeration_likelihood: Probability,
pub attribute_enumeration_likelihood: f64,
}

impl Requirements {
Expand Down Expand Up @@ -73,7 +73,7 @@ impl Default for Requirements {
sparse_tile_capacity: Self::min_sparse_tile_capacity_default()
..=Self::max_sparse_tile_capacity_default(),
attribute_enumeration_likelihood:
Self::attribute_enumeration_likelihood_default().into(),
Self::attribute_enumeration_likelihood_default(),
}
}
}
Expand Down Expand Up @@ -162,11 +162,14 @@ fn prop_schema_for_domain(
let attribute_mapping = attributes
.iter()
.map(|_| {
if num_enumerations == 0 {
// NB: `weighted` is not friendly to 0.0 and 1.0
if num_enumerations == 0 || enumeration_likelihood <= 0.0 {
Just(None).boxed()
} else if enumeration_likelihood >= 1.0 {
(0..num_enumerations).prop_map(Some).boxed()
} else {
proptest::option::weighted(
enumeration_likelihood,
Probability::new(enumeration_likelihood),
0..num_enumerations,
)
.boxed()
Expand Down