Package org.openrefine.model
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 ifRowMapper
cannot be used.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description S
combine(S left, S right)
Combines two states produced by rows.static <S> RowScanMapper<S>
conditionalMapper(RowFilter filter, RowScanMapper<S> rowScanMapper, RowMapper negativeMapper)
Restricts aRowScanMapper
to only aggregate its state on filtered rows, and only apply the map function to those filtered rows.S
feed(long rowId, Row row)
Produces the state associated with a given row.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.default boolean
preservesRecordStructure()
Whether this mapper is guaranteed to preserve record structure after application.S
unit()
The initial state of the mapper.
-
-
-
Method Detail
-
feed
S feed(long rowId, Row row)
Produces the state associated with a given row.- Parameters:
rowId
- the index of the rowrow
- 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 aRowScanMapper
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 rowrowScanMapper
- the mapper for rows selected by the filternegativeMapper
- the mapper for rows not selected by the filter
-
-