Search in sources :

Example 71 with GenericRowData

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());
    }
}
Also used : GenericRowData(org.apache.flink.table.data.GenericRowData)

Example 72 with GenericRowData

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);
    }
}
Also used : GenericRowData(org.apache.flink.table.data.GenericRowData)

Example 73 with GenericRowData

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;
}
Also used : GenericRowData(org.apache.flink.table.data.GenericRowData)

Example 74 with GenericRowData

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);
    }
}
Also used : GenericRowData(org.apache.flink.table.data.GenericRowData)

Example 75 with GenericRowData

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;
}
Also used : ListSerializer(org.apache.flink.api.common.typeutils.base.ListSerializer) LongSerializer(org.apache.flink.api.common.typeutils.base.LongSerializer) MapStateDescriptor(org.apache.flink.api.common.state.MapStateDescriptor) WindowTimerServiceImpl(org.apache.flink.table.runtime.operators.window.slicing.WindowTimerServiceImpl) GenericRowData(org.apache.flink.table.data.GenericRowData) RowData(org.apache.flink.table.data.RowData) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) InternalMapState(org.apache.flink.runtime.state.internal.InternalMapState) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) GenericRowData(org.apache.flink.table.data.GenericRowData) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

GenericRowData (org.apache.flink.table.data.GenericRowData)94 RowData (org.apache.flink.table.data.RowData)32 JoinedRowData (org.apache.flink.table.data.utils.JoinedRowData)16 Test (org.junit.Test)14 BinaryRowData (org.apache.flink.table.data.binary.BinaryRowData)13 RowType (org.apache.flink.table.types.logical.RowType)13 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)11 IntType (org.apache.flink.table.types.logical.IntType)11 List (java.util.List)9 LogicalType (org.apache.flink.table.types.logical.LogicalType)9 GenericArrayData (org.apache.flink.table.data.GenericArrayData)6 StringData (org.apache.flink.table.data.StringData)6 Arrays (java.util.Arrays)5 HashMap (java.util.HashMap)5 OutputStream (java.io.OutputStream)4 PrintStream (java.io.PrintStream)4 Collections (java.util.Collections)4 Random (java.util.Random)4 Consumer (java.util.function.Consumer)4