42
42
import org .apache .calcite .util .ImmutableBitSet ;
43
43
import org .apache .datasketches .kll .KllFloatsSketch ;
44
44
import org .apache .datasketches .memory .Memory ;
45
+ import org .apache .datasketches .quantilescommon .QuantileSearchCriteria ;
45
46
import org .apache .hadoop .hive .ql .optimizer .calcite .HiveCalciteUtil ;
46
47
import org .apache .hadoop .hive .ql .optimizer .calcite .HiveConfPlannerContext ;
47
48
import org .apache .hadoop .hive .ql .optimizer .calcite .RelOptHiveTable ;
@@ -489,7 +490,7 @@ public Double visitLiteral(RexLiteral literal) {
489
490
490
491
private static double rangedSelectivity (KllFloatsSketch kll , float val1 , float val2 ) {
491
492
float [] splitPoints = new float [] { val1 , val2 };
492
- double [] boundaries = kll .getCDF (splitPoints );
493
+ double [] boundaries = kll .getCDF (splitPoints , QuantileSearchCriteria . EXCLUSIVE );
493
494
return boundaries [1 ] - boundaries [0 ];
494
495
}
495
496
@@ -500,7 +501,7 @@ private static double rangedSelectivity(KllFloatsSketch kll, float val1, float v
500
501
* @return the selectivity of a predicate "column > value" in the range [0, 1]
501
502
*/
502
503
public static double greaterThanSelectivity (KllFloatsSketch kll , float value ) {
503
- float max = kll .getMaxValue ();
504
+ float max = kll .getMaxItem ();
504
505
if (value > max ) {
505
506
return 0 ;
506
507
}
@@ -518,10 +519,10 @@ public static double greaterThanSelectivity(KllFloatsSketch kll, float value) {
518
519
* @return the selectivity of a predicate "column >= value" in the range [0, 1]
519
520
*/
520
521
public static double greaterThanOrEqualSelectivity (KllFloatsSketch kll , float value ) {
521
- if (value > kll .getMaxValue ()) {
522
+ if (value > kll .getMaxItem ()) {
522
523
return 0 ;
523
524
}
524
- return rangedSelectivity (kll , value , Math .nextUp (kll .getMaxValue ()));
525
+ return rangedSelectivity (kll , value , Math .nextUp (kll .getMaxItem ()));
525
526
}
526
527
527
528
/**
@@ -531,10 +532,10 @@ public static double greaterThanOrEqualSelectivity(KllFloatsSketch kll, float va
531
532
* @return the selectivity of a predicate "column <= value" in the range [0, 1]
532
533
*/
533
534
public static double lessThanOrEqualSelectivity (KllFloatsSketch kll , float value ) {
534
- if (value < kll .getMinValue ()) {
535
+ if (value < kll .getMinItem ()) {
535
536
return 0 ;
536
537
}
537
- return kll .getCDF (new float [] { Math .nextUp (value ) })[0 ];
538
+ return kll .getCDF (new float [] { Math .nextUp (value ) }, QuantileSearchCriteria . EXCLUSIVE )[0 ];
538
539
}
539
540
540
541
/**
@@ -544,14 +545,14 @@ public static double lessThanOrEqualSelectivity(KllFloatsSketch kll, float value
544
545
* @return the selectivity of a predicate "column < value" in the range [0, 1]
545
546
*/
546
547
public static double lessThanSelectivity (KllFloatsSketch kll , float value ) {
547
- float min = kll .getMinValue ();
548
+ float min = kll .getMinItem ();
548
549
if (value < min ) {
549
550
return 0 ;
550
551
}
551
552
if (Double .compare (value , min ) == 0 || Double .compare (Math .nextUp (value ), min ) == 0 ) {
552
553
return 0 ;
553
554
}
554
- return kll .getCDF (new float [] { value })[0 ];
555
+ return kll .getCDF (new float [] { value }, QuantileSearchCriteria . EXCLUSIVE )[0 ];
555
556
}
556
557
557
558
/**
0 commit comments