Interface RowScanMapper<S>

  • Type Parameters:
    S -
    All Superinterfaces:
    Serializable

    public interface RowScanMapper<S>
    extends Serializable
    A row mapper which is able to update a state as it reads rows. Only use this if RowMapper cannot be used.
    • Method Detail

      • feed

        S feed​(long rowId,
               Row row)
        Produces the state associated with a given row.
        Parameters:
        rowId - the index of the row
        row - the row to map to the corresponding state
      • combine

        S combine​(S left,
                  S right)
        Combines two states produced by rows. This needs to be associative and unital (for the unit provided below).
      • unit

        S unit()
        The initial state of the mapper.
      • map

        Row map​(S state,
                long rowId,
                Row row)
        Given the accumulated state of all the previous rows (the list of states produced by feed and merged using combine), transform the current row to a new one.
      • preservesRecordStructure

        default boolean preservesRecordStructure()
        Whether this mapper is guaranteed to preserve record structure after application.
      • conditionalMapper

        static <S> RowScanMapper<S> conditionalMapper​(RowFilter filter,
                                                      RowScanMapper<S> rowScanMapper,
                                                      RowMapper negativeMapper)
        Restricts a RowScanMapper to only aggregate its state on filtered rows, and only apply the map function to those filtered rows. A stateless mapper is applied to the other rows.
        Type Parameters:
        S - the internal state of the mapper
        Parameters:
        filter - the row filter used to determine which mapper to apply to a given row
        rowScanMapper - the mapper for rows selected by the filter
        negativeMapper - the mapper for rows not selected by the filter