format/src/main/java/com/github/sadikovi/riff/IndexedRowReader.java
/**
   * Read row from input stream based on current predicate state.
   * If row is not accepted by predicate state null is return and this row should be skipped in
   * row buffer. State is guaranteed to be non-null and fully resolved. Because we can evaluate
   * index region separately, if row is discarded stream is automatically advanced to the data
   * region length.
   * @param in input stream
   * @param state valid predicate state
   * @return indexed row as InternalRow
   * @throws IOException
   */
Read row from input stream based on current predicate state.
If row is not accepted by predicate state null is return and this row should be skipped in
row buffer. State is guaranteed to be non-null and fully resolved. Because we can evaluate
index region separately, if row is discarded stream is automatically advanced to the data
region length.
@param in input stream
@param state valid predicate state
@return indexed row as InternalRow
@throws IOException
Read row from input stream based on current predicate state . If row is not accepted by predicate state null is return and this row should be skipped in row buffer . State is guaranteed to be non - null and fully resolved . Because we can evaluate index region separately if row is discarded stream is automatically advanced to the data region length . @param in input stream @param state valid predicate state @return indexed row as InternalRow @throws IOException
public InternalRow readRow(InStream in, PredicateState state) throws IOException {
    IndexedRow row = readRowHeader(in);
    int indexBytes = in.readInt();
    if (indexBytes > 0) {
      byte[] indexRegion = new byte[indexBytes];
      in.read(indexRegion, 0, indexBytes);
      row.setIndexRegion(indexRegion);
    }
    int dataBytes = in.readInt();
    if (!state.indexTree().evaluateState(row)) {
      in.skip(dataBytes);
      return null;
    }
    if (dataBytes > 0) {
      byte[] dataRegion = new byte[dataBytes];
      in.read(dataRegion, 0, dataBytes);
      row.setDataRegion(dataRegion);
    }
    if (state.hasIndexedTreeOnly()) return row;
    if (state.tree().evaluateState(row)) return row;
    return null;
  }
public InternalRow readRow ( InStream in , PredicateState state ) throws IOException { IndexedRow row = readRowHeader ( in ) ; int indexBytes = in . readInt ( ) ; if ( indexBytes > 0 ) { byte [ ] indexRegion = new byte [ indexBytes ] ; in . read ( indexRegion , 0 , indexBytes ) ; row . setIndexRegion ( indexRegion ) ; } int dataBytes = in . readInt ( ) ; if ( ! state . indexTree ( ) . evaluateState ( row ) ) { in . skip ( dataBytes ) ; return null ; } if ( dataBytes > 0 ) { byte [ ] dataRegion = new byte [ dataBytes ] ; in . read ( dataRegion , 0 , dataBytes ) ; row . setDataRegion ( dataRegion ) ; } if ( state . hasIndexedTreeOnly ( ) ) return row ; if ( state . tree ( ) . evaluateState ( row ) ) return row ; return null ; }
Read row from input stream based on current predicate state.
Read row from input stream based on current predicate state .
// read index region, note that if no bytes were written, we do not set index region at all // read data region, similarly we do not initialize data region, if no bytes were written // if index tree does not accept current row, return it and skip data region // at this point row passes predicate state for index region. // state contains index tree only, there is no need to evaluate predicate twice, return row // directly, otherwise run predicate state full tree on fully-read row. // we would have evaluated index tree in previous step // row passes predicate state