private static final HllSketchImpl copyOrDownsampleHll ( final HllSketchImpl srcImpl , final int tgtLgK ) { assert srcImpl . getCurMode ( ) == HLL ; final AbstractHllArray src = ( AbstractHllArray ) srcImpl ; final int srcLgK = src . getLgConfigK ( ) ; if ( ( srcLgK <= tgtLgK ) && ( src . getTgtHllType ( ) == TgtHllType . HLL_8 ) ) { return src . copy ( ) ; } final int minLgK = Math . min ( srcLgK , tgtLgK ) ; final HllArray tgtHllArr = HllArray . newHeapHll ( minLgK , TgtHllType . HLL_8 ) ; final PairIterator srcItr = src . iterator ( ) ; while ( srcItr . nextValid ( ) ) { tgtHllArr . couponUpdate ( srcItr . getPair ( ) ) ; } //both of these are required for isomorphism tgtHllArr . putHipAccum ( src . getHipAccum ( ) ) ; tgtHllArr . putOutOfOrderFlag ( src . isOutOfOrderFlag ( ) ) ; return tgtHllArr ; }
Caller must ultimately manage oooFlag as caller has more info