Skip to content

Commit

Permalink
Robustness of attribute_enumeration_likelihood (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
rroelke authored Nov 13, 2024
1 parent b8ccc88 commit 9aafaae
Showing 1 changed file with 7 additions and 4 deletions.
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

0 comments on commit 9aafaae

Please sign in to comment.