format/src/main/java/com/github/sadikovi/riff/Buffers.java
/**
   * Select row buffer based on provided options.
   * @param in raw input stream
   * @param stripes stripe information, should be sorted by offsets in ascending order
   * @param td type description for records
   * @param codec compression codec, null - no compression
   * @param bufferSize buffer size for instream
   * @param state predicate state to use, null - no predicate, direct scan
   * @return row buffer based on input parameters
   */
Select row buffer based on provided options.
Select row buffer based on provided options .
public static RowBuffer prepareRowBuffer(
      FSDataInputStream in,
      StripeInformation[] stripes,
      TypeDescription td,
      CompressionCodec codec,
      int bufferSize,
      PredicateState state) throws IOException {
    RowBuffer rowbuf = null;
    if (stripes == null || stripes.length == 0) {
      rowbuf = new EmptyRowBuffer(in);
    } else {
      LOG.debug("Analyze state {}", state);
      if (state == null || state.result() == State.True) {
        rowbuf = new DirectScanRowBuffer(in, stripes, td, codec, bufferSize);
      } else if (state.result() == State.Unknown) {
        rowbuf = new PredicateScanRowBuffer(in, stripes, td, codec, bufferSize, state);
      } else {
        rowbuf = new EmptyRowBuffer(in);
      }
    }
    LOG.debug("Select row buffer {}", rowbuf);
    return rowbuf;
  }
public static RowBuffer prepareRowBuffer ( FSDataInputStream in , StripeInformation [ ] stripes , TypeDescription td , CompressionCodec codec , int bufferSize , PredicateState state ) throws IOException { RowBuffer rowbuf = null ; if ( stripes == null || stripes . length == 0 ) { rowbuf = new EmptyRowBuffer ( in ) ; } else { LOG . debug ( "Analyze state {}" , state ) ; if ( state == null || state . result ( ) == State . True ) { rowbuf = new DirectScanRowBuffer ( in , stripes , td , codec , bufferSize ) ; } else if ( state . result ( ) == State . Unknown ) { rowbuf = new PredicateScanRowBuffer ( in , stripes , td , codec , bufferSize , state ) ; } else { rowbuf = new EmptyRowBuffer ( in ) ; } } LOG . debug ( "Select row buffer {}" , rowbuf ) ; return rowbuf ; }
Select row buffer based on provided options.
Select row buffer based on provided options .
// resolve state: if state is negative trivial return empty buffer, otherwise choose // depending on availability of state