use of org.apache.flink.table.data.GenericRowData in project flink by apache.
the class FirstValueAggFunction method accumulate.
public void accumulate(RowData rowData, Object value) {
GenericRowData acc = (GenericRowData) rowData;
if (value != null && acc.getLong(1) == Long.MAX_VALUE) {
acc.setField(0, value);
acc.setField(1, System.currentTimeMillis());
}
}
use of org.apache.flink.table.data.GenericRowData in project flink by apache.
the class FirstValueAggFunction method accumulate.
public void accumulate(RowData rowData, Object value, Long order) {
GenericRowData acc = (GenericRowData) rowData;
if (value != null && acc.getLong(1) > order) {
acc.setField(0, value);
acc.setField(1, order);
}
}
use of org.apache.flink.table.data.GenericRowData in project flink by apache.
the class LastValueAggFunction method createAccumulator.
// --------------------------------------------------------------------------------------------
// Runtime
// --------------------------------------------------------------------------------------------
@Override
public RowData createAccumulator() {
GenericRowData acc = new GenericRowData(2);
acc.setField(0, null);
acc.setField(1, Long.MIN_VALUE);
return acc;
}
use of org.apache.flink.table.data.GenericRowData in project flink by apache.
the class LastValueAggFunction method accumulate.
public void accumulate(RowData rowData, Object value, Long order) {
GenericRowData acc = (GenericRowData) rowData;
if (value != null && acc.getLong(1) < order) {
acc.setField(0, value);
acc.setField(1, order);
}
}
use of org.apache.flink.table.data.GenericRowData in project flink by apache.
the class WindowRankProcessor method open.
@Override
public void open(Context<Long> context) throws Exception {
this.ctx = context;
// compile comparator
sortKeyComparator = generatedSortKeyComparator.newInstance(ctx.getRuntimeContext().getUserCodeClassLoader());
final LongSerializer namespaceSerializer = LongSerializer.INSTANCE;
ListSerializer<RowData> listSerializer = new ListSerializer<>(inputSerializer);
MapStateDescriptor<RowData, List<RowData>> mapStateDescriptor = new MapStateDescriptor<>("window_rank", sortKeySerializer, listSerializer);
MapState<RowData, List<RowData>> state = ctx.getKeyedStateBackend().getOrCreateKeyedState(namespaceSerializer, mapStateDescriptor);
this.windowTimerService = new WindowTimerServiceImpl(ctx.getTimerService(), shiftTimeZone);
this.windowState = new WindowMapState<>((InternalMapState<RowData, Long, RowData, List<RowData>>) state);
this.windowBuffer = bufferFactory.create(ctx.getOperatorOwner(), ctx.getMemoryManager(), ctx.getMemorySize(), ctx.getRuntimeContext(), windowTimerService, ctx.getKeyedStateBackend(), windowState, true, shiftTimeZone);
this.reuseOutput = new JoinedRowData();
this.reuseRankRow = new GenericRowData(1);
this.currentProgress = Long.MIN_VALUE;
}
Aggregations