@@ -1121,7 +1121,7 @@ impl TransmissionPlan {
11211121
11221122fn validate_runtime_rule_policy (
11231123 rule : & TransmissionRule ,
1124- family : & asap_types :: SummaryKind ,
1124+ family : & StateFamilyContract ,
11251125) -> Result < ( ) , TransmissionPlanError > {
11261126 let invalid = |reason : & str | TransmissionPlanError :: InvalidRuntimePolicy {
11271127 producer_id : rule. producer_id . clone ( ) ,
@@ -1138,11 +1138,17 @@ fn validate_runtime_rule_policy(
11381138 let supported = matches ! (
11391139 ( family, * estimator) ,
11401140 (
1141- asap_types:: SummaryKind :: Hll ,
1142- SamplingEstimator :: HashThreshold
1141+ StateFamilyContract :: Sketch {
1142+ algorithm: SketchAlgorithm :: Hll ,
1143+ ..
1144+ } ,
1145+ SamplingEstimator :: HashThreshold ,
11431146 ) | (
1144- asap_types:: SummaryKind :: Cms | asap_types:: SummaryKind :: CmsWithHeap ,
1145- SamplingEstimator :: GeometricAdmission
1147+ StateFamilyContract :: Sketch {
1148+ algorithm: SketchAlgorithm :: Cms | SketchAlgorithm :: CmsWithHeap ,
1149+ ..
1150+ } ,
1151+ SamplingEstimator :: GeometricAdmission ,
11461152 )
11471153 ) ;
11481154 if !supported {
@@ -1163,12 +1169,15 @@ fn validate_runtime_rule_policy(
11631169 }
11641170 if !matches ! (
11651171 family,
1166- asap_types:: SummaryKind :: DDSketch
1167- | asap_types:: SummaryKind :: Hll
1168- | asap_types:: SummaryKind :: Cms
1169- | asap_types:: SummaryKind :: CmsWithHeap
1170- | asap_types:: SummaryKind :: CountSketch
1171- | asap_types:: SummaryKind :: CountSketchWithHeap
1172+ StateFamilyContract :: Sketch {
1173+ algorithm: SketchAlgorithm :: DDSketch
1174+ | SketchAlgorithm :: Hll
1175+ | SketchAlgorithm :: Cms
1176+ | SketchAlgorithm :: CmsWithHeap
1177+ | SketchAlgorithm :: CountSketch
1178+ | SketchAlgorithm :: CountSketchWithHeap ,
1179+ ..
1180+ }
11721181 ) {
11731182 return Err ( invalid (
11741183 "delta transmission is not implemented for the materialization family" ,
@@ -1177,7 +1186,10 @@ fn validate_runtime_rule_policy(
11771186 if let Some ( gos) = & delta. gos {
11781187 if !matches ! (
11791188 family,
1180- asap_types:: SummaryKind :: CountSketch | asap_types:: SummaryKind :: CountSketchWithHeap
1189+ StateFamilyContract :: Sketch {
1190+ algorithm: SketchAlgorithm :: CountSketch | SketchAlgorithm :: CountSketchWithHeap ,
1191+ ..
1192+ }
11811193 ) || !gos. epsilon_staleness . is_finite ( )
11821194 || !( 0.0 ..=1.0 ) . contains ( & gos. epsilon_staleness )
11831195 || gos. epsilon_staleness == 0.0
@@ -2524,10 +2536,20 @@ mod tests {
25242536 probability : 0.5 ,
25252537 estimator : SamplingEstimator :: HashThreshold ,
25262538 } ;
2527- validate_runtime_rule_policy ( & rule, & asap_types:: SummaryKind :: Hll )
2528- . expect ( "HLL supports hash-threshold sampling" ) ;
2539+ let hll = StateFamilyContract :: Sketch {
2540+ algorithm : SketchAlgorithm :: Hll ,
2541+ parameters : SketchParams :: Hll { precision : 14 } ,
2542+ } ;
2543+ let count_sketch = StateFamilyContract :: Sketch {
2544+ algorithm : SketchAlgorithm :: CountSketch ,
2545+ parameters : SketchParams :: CountSketch {
2546+ width : 128 ,
2547+ depth : 4 ,
2548+ } ,
2549+ } ;
2550+ validate_runtime_rule_policy ( & rule, & hll) . expect ( "HLL supports hash-threshold sampling" ) ;
25292551 assert ! ( matches!(
2530- validate_runtime_rule_policy( & rule, & asap_types :: SummaryKind :: CountSketch ) ,
2552+ validate_runtime_rule_policy( & rule, & count_sketch ) ,
25312553 Err ( TransmissionPlanError :: InvalidRuntimePolicy { .. } )
25322554 ) ) ;
25332555
@@ -2542,10 +2564,9 @@ mod tests {
25422564 threshold_mode : GosThresholdMode :: Isotropic ,
25432565 } ) ,
25442566 } ) ;
2545- validate_runtime_rule_policy ( & rule, & asap_types:: SummaryKind :: CountSketch )
2546- . expect ( "CountSketch supports delta GOS" ) ;
2567+ validate_runtime_rule_policy ( & rule, & count_sketch) . expect ( "CountSketch supports delta GOS" ) ;
25472568 assert ! ( matches!(
2548- validate_runtime_rule_policy( & rule, & asap_types :: SummaryKind :: Hll ) ,
2569+ validate_runtime_rule_policy( & rule, & hll ) ,
25492570 Err ( TransmissionPlanError :: InvalidRuntimePolicy { .. } )
25502571 ) ) ;
25512572 }
0 commit comments