Search in sources :

Example 86 with GenericRowData

use of org.apache.flink.table.data.GenericRowData in project flink by apache.

the class LookupJoinRunner method open.

@Override
public void open(Configuration parameters) throws Exception {
    super.open(parameters);
    this.fetcher = generatedFetcher.newInstance(getRuntimeContext().getUserCodeClassLoader());
    this.collector = generatedCollector.newInstance(getRuntimeContext().getUserCodeClassLoader());
    FunctionUtils.setFunctionRuntimeContext(fetcher, getRuntimeContext());
    FunctionUtils.setFunctionRuntimeContext(collector, getRuntimeContext());
    FunctionUtils.openFunction(fetcher, parameters);
    FunctionUtils.openFunction(collector, parameters);
    this.nullRow = new GenericRowData(tableFieldsCount);
    this.outRow = new JoinedRowData();
}
Also used : JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) GenericRowData(org.apache.flink.table.data.GenericRowData)

Example 87 with GenericRowData

use of org.apache.flink.table.data.GenericRowData in project flink by apache.

the class TemporalRowTimeJoinOperator method open.

@Override
public void open() throws Exception {
    super.open();
    joinCondition = generatedJoinCondition.newInstance(getRuntimeContext().getUserCodeClassLoader());
    joinCondition.setRuntimeContext(getRuntimeContext());
    joinCondition.open(new Configuration());
    nextLeftIndex = getRuntimeContext().getState(new ValueStateDescriptor<>(NEXT_LEFT_INDEX_STATE_NAME, Types.LONG));
    leftState = getRuntimeContext().getMapState(new MapStateDescriptor<>(LEFT_STATE_NAME, Types.LONG, leftType));
    rightState = getRuntimeContext().getMapState(new MapStateDescriptor<>(RIGHT_STATE_NAME, Types.LONG, rightType));
    registeredTimer = getRuntimeContext().getState(new ValueStateDescriptor<>(REGISTERED_TIMER_STATE_NAME, Types.LONG));
    timerService = getInternalTimerService(TIMERS_STATE_NAME, VoidNamespaceSerializer.INSTANCE, this);
    outRow = new JoinedRowData();
    rightNullRow = new GenericRowData(rightType.toRowType().getFieldCount());
    collector = new TimestampedCollector<>(output);
}
Also used : ValueStateDescriptor(org.apache.flink.api.common.state.ValueStateDescriptor) MapStateDescriptor(org.apache.flink.api.common.state.MapStateDescriptor) Configuration(org.apache.flink.configuration.Configuration) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) GenericRowData(org.apache.flink.table.data.GenericRowData)

Example 88 with GenericRowData

use of org.apache.flink.table.data.GenericRowData in project flink by apache.

the class AbstractTopNFunction method createOutputRow.

private RowData createOutputRow(RowData inputRow, long rank, RowKind rowKind) {
    if (outputRankNumber) {
        GenericRowData rankRow = new GenericRowData(1);
        rankRow.setField(0, rank);
        outputRow.replace(inputRow, rankRow);
        outputRow.setRowKind(rowKind);
        return outputRow;
    } else {
        inputRow.setRowKind(rowKind);
        return inputRow;
    }
}
Also used : GenericRowData(org.apache.flink.table.data.GenericRowData)

Example 89 with GenericRowData

use of org.apache.flink.table.data.GenericRowData in project flink by apache.

the class TemporalProcessTimeJoinOperator method open.

@Override
public void open() throws Exception {
    super.open();
    this.joinCondition = generatedJoinCondition.newInstance(getRuntimeContext().getUserCodeClassLoader());
    FunctionUtils.setFunctionRuntimeContext(joinCondition, getRuntimeContext());
    FunctionUtils.openFunction(joinCondition, new Configuration());
    ValueStateDescriptor<RowData> rightStateDesc = new ValueStateDescriptor<>("right", rightType);
    this.rightState = getRuntimeContext().getState(rightStateDesc);
    this.collector = new TimestampedCollector<>(output);
    this.outRow = new JoinedRowData();
    this.rightNullRow = new GenericRowData(rightType.toRowSize());
    // consider watermark from left stream only.
    super.processWatermark2(Watermark.MAX_WATERMARK);
}
Also used : ValueStateDescriptor(org.apache.flink.api.common.state.ValueStateDescriptor) RowData(org.apache.flink.table.data.RowData) GenericRowData(org.apache.flink.table.data.GenericRowData) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) Configuration(org.apache.flink.configuration.Configuration) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) GenericRowData(org.apache.flink.table.data.GenericRowData)

Example 90 with GenericRowData

use of org.apache.flink.table.data.GenericRowData in project flink by apache.

the class SinkUpsertMaterializerTest method getEmittedRows.

private static List<RowData> getEmittedRows(OneInputStreamOperatorTestHarness<RowData, RowData> harness) {
    final List<RowData> rows = new ArrayList<>();
    Object o;
    while ((o = harness.getOutput().poll()) != null) {
        RowData value = (RowData) ((StreamRecord<?>) o).getValue();
        GenericRowData newRow = GenericRowData.of(value.getInt(0), value.getString(1));
        newRow.setRowKind(value.getRowKind());
        rows.add(newRow);
    }
    return rows;
}
Also used : RowData(org.apache.flink.table.data.RowData) GenericRowData(org.apache.flink.table.data.GenericRowData) ArrayList(java.util.ArrayList) GenericRowData(org.apache.flink.table.data.GenericRowData)

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