format/src/main/java/com/github/sadikovi/riff/FileReader.java
/**
   * Evaluate and reduce stripes based on state. Returned stripes array will have at most all
   * elements of the original stripes. All stripes are sorted in ascending order based on offset.
   * @param stripes original array of stripes
   * @param state predicate state to evaluate, can be null
   * @return reduced stripe information
   */
Evaluate and reduce stripes based on state. Returned stripes array will have at most all
elements of the original stripes. All stripes are sorted in ascending order based on offset.
@param stripes original array of stripes
@param state predicate state to evaluate, can be null
@return reduced stripe information
Evaluate and reduce stripes based on state . Returned stripes array will have at most all elements of the original stripes . All stripes are sorted in ascending order based on offset . @param stripes original array of stripes @param state predicate state to evaluate can be null @return reduced stripe information
protected static StripeInformation[] evaluateStripes(
      StripeInformation[] stripes,
      PredicateState state) {
    if (state != null) {
      int stripesLeft = stripes.length;
      for (int i = 0; i < stripes.length; i++) {
        boolean keep = true;
        if (stripes[i].hasStatistics()) {
          if (state.hasIndexedTreeOnly()) {
            keep = state.indexTree().evaluateState(stripes[i].getStatistics());
          } else {
            keep = state.tree().evaluateState(stripes[i].getStatistics());
          }
        }
        if (keep && stripes[i].hasColumnFilters()) {
          if (state.hasIndexedTreeOnly()) {
            keep = state.indexTree().evaluateState(stripes[i].getColumnFilters());
          } else {
            keep = state.tree().evaluateState(stripes[i].getColumnFilters());
          }
        }
        if (!keep) {
          stripes[i] = null;
          stripesLeft--;
        }
      }
      if (stripesLeft < stripes.length) {
        StripeInformation[] reducedStripes = new StripeInformation[stripesLeft];
        for (int i = stripes.length - 1; i >= 0; i--) {
          if (stripes[i] != null) {
            reducedStripes[--stripesLeft] = stripes[i];
          }
        }
        stripes = reducedStripes;
      }
    }
    Arrays.sort(stripes);
    return stripes;
  }
protected static StripeInformation [ ] evaluateStripes ( StripeInformation [ ] stripes , PredicateState state ) { if ( state != null ) { int stripesLeft = stripes . length ; for ( int i = 0 ; i < stripes . length ; i ++ ) { boolean keep = true ; if ( stripes [ i ] . hasStatistics ( ) ) { if ( state . hasIndexedTreeOnly ( ) ) { keep = state . indexTree ( ) . evaluateState ( stripes [ i ] . getStatistics ( ) ) ; } else { keep = state . tree ( ) . evaluateState ( stripes [ i ] . getStatistics ( ) ) ; } } if ( keep && stripes [ i ] . hasColumnFilters ( ) ) { if ( state . hasIndexedTreeOnly ( ) ) { keep = state . indexTree ( ) . evaluateState ( stripes [ i ] . getColumnFilters ( ) ) ; } else { keep = state . tree ( ) . evaluateState ( stripes [ i ] . getColumnFilters ( ) ) ; } } if ( ! keep ) { stripes [ i ] = null ; stripesLeft -- ; } } if ( stripesLeft < stripes . length ) { StripeInformation [ ] reducedStripes = new StripeInformation [ stripesLeft ] ; for ( int i = stripes . length - 1 ; i >= 0 ; i -- ) { if ( stripes [ i ] != null ) { reducedStripes [ -- stripesLeft ] = stripes [ i ] ; } } stripes = reducedStripes ; } } Arrays . sort ( stripes ) ; return stripes ; }
Evaluate and reduce stripes based on state.
Evaluate and reduce stripes based on state .
// if stripe has statistics it is evaluated against predicate state, otherwise it is always // included in final result // if predicate passes statistics, evaluate column filters // write stripes preserving original order