private Supplier < DruidLongPredicate > getLongPredicateSupplier ( ) { return new Supplier < DruidLongPredicate > ( ) { private final Object initLock = new Object ( ) ; private DruidLongPredicate predicate ; private void initLongValues ( ) { if ( predicate != null ) { return ; } synchronized ( initLock ) { if ( predicate != null ) { return ; } LongArrayList longs = new LongArrayList ( values . size ( ) ) ; for ( String value : values ) { final Long longValue = DimensionHandlerUtils . getExactLongFromDecimalString ( value ) ; if ( longValue != null ) { longs . add ( longValue ) ; } } if ( longs . size ( ) > NUMERIC_HASHING_THRESHOLD ) { final LongOpenHashSet longHashSet = new LongOpenHashSet ( longs ) ; predicate = input -> longHashSet . contains ( input ) ; } else { final long [ ] longArray = longs . toLongArray ( ) ; Arrays . sort ( longArray ) ; predicate = input -> Arrays . binarySearch ( longArray , input ) >= 0 ; } } } @ Override public DruidLongPredicate get ( ) { initLongValues ( ) ; return predicate ; } } ; }
This supplier must be thread - safe since this DimFilter will be accessed in the query runners .