Search in sources :

Example 26 with GenericRowData

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

the class StreamingJoinOperator method open.

@Override
public void open() throws Exception {
    super.open();
    this.outRow = new JoinedRowData();
    this.leftNullRow = new GenericRowData(leftType.toRowSize());
    this.rightNullRow = new GenericRowData(rightType.toRowSize());
    // initialize states
    if (leftIsOuter) {
        this.leftRecordStateView = OuterJoinRecordStateViews.create(getRuntimeContext(), "left-records", leftInputSideSpec, leftType, stateRetentionTime);
    } else {
        this.leftRecordStateView = JoinRecordStateViews.create(getRuntimeContext(), "left-records", leftInputSideSpec, leftType, stateRetentionTime);
    }
    if (rightIsOuter) {
        this.rightRecordStateView = OuterJoinRecordStateViews.create(getRuntimeContext(), "right-records", rightInputSideSpec, rightType, stateRetentionTime);
    } else {
        this.rightRecordStateView = JoinRecordStateViews.create(getRuntimeContext(), "right-records", rightInputSideSpec, rightType, stateRetentionTime);
    }
}
Also used : JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) GenericRowData(org.apache.flink.table.data.GenericRowData)

Example 27 with GenericRowData

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

the class BufferDataOverWindowOperatorTest method test.

private void test(OverWindowFrame[] frames, GenericRowData[] expect) throws Exception {
    MockEnvironment env = new MockEnvironmentBuilder().setIOManager(ioManager).setMemoryManager(memoryManager).build();
    StreamTask<Object, StreamOperator<Object>> task = new StreamTask<Object, StreamOperator<Object>>(env) {

        @Override
        protected void init() {
        }
    };
    operator = new BufferDataOverWindowOperator(frames, comparator, true) {

        {
            output = new NonBufferOverWindowOperatorTest.ConsumerOutput(new Consumer<RowData>() {

                @Override
                public void accept(RowData r) {
                    collect.add(GenericRowData.of(r.getInt(0), r.getLong(1), r.getLong(2), r.getLong(3), r.getLong(4)));
                }
            });
        }

        @Override
        public ClassLoader getUserCodeClassloader() {
            return Thread.currentThread().getContextClassLoader();
        }

        @Override
        public StreamConfig getOperatorConfig() {
            StreamConfig conf = mock(StreamConfig.class);
            when(conf.<RowData>getTypeSerializerIn1(getUserCodeClassloader())).thenReturn(inputSer);
            when(conf.getManagedMemoryFractionOperatorUseCaseOfSlot(eq(ManagedMemoryUseCase.OPERATOR), any(Configuration.class), any(ClassLoader.class))).thenReturn(0.99);
            return conf;
        }

        @Override
        public StreamTask<?, ?> getContainingTask() {
            return task;
        }

        @Override
        public StreamingRuntimeContext getRuntimeContext() {
            return mock(StreamingRuntimeContext.class);
        }
    };
    operator.setProcessingTimeService(new TestProcessingTimeService());
    operator.open();
    addRow(0, 1L, 4L);
    /* 1 **/
    addRow(0, 1L, 1L);
    /* 2 **/
    addRow(0, 1L, 1L);
    /* 3 **/
    addRow(0, 1L, 1L);
    /* 4 **/
    addRow(1, 5L, 2L);
    /* 5 **/
    addRow(2, 5L, 4L);
    /* 6 **/
    addRow(2, 6L, 2L);
    /* 7 **/
    addRow(2, 6L, 2L);
    /* 8 **/
    addRow(2, 6L, 2L);
    /* 9 **/
    operator.endInput();
    GenericRowData[] outputs = this.collect.toArray(new GenericRowData[0]);
    Assert.assertArrayEquals(expect, outputs);
    operator.close();
}
Also used : MockEnvironmentBuilder(org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder) StreamingRuntimeContext(org.apache.flink.streaming.api.operators.StreamingRuntimeContext) StreamConfig(org.apache.flink.streaming.api.graph.StreamConfig) GenericRowData(org.apache.flink.table.data.GenericRowData) RowData(org.apache.flink.table.data.RowData) MockEnvironment(org.apache.flink.runtime.operators.testutils.MockEnvironment) TestProcessingTimeService(org.apache.flink.streaming.runtime.tasks.TestProcessingTimeService) GenericRowData(org.apache.flink.table.data.GenericRowData) StreamOperator(org.apache.flink.streaming.api.operators.StreamOperator) StreamTask(org.apache.flink.streaming.runtime.tasks.StreamTask)

Example 28 with GenericRowData

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

the class RankOperator method open.

@Override
public void open() throws Exception {
    super.open();
    ClassLoader cl = getUserCodeClassloader();
    inputSer = (AbstractRowDataSerializer) getOperatorConfig().getTypeSerializerIn1(cl);
    partitionByComp = partitionByGenComp.newInstance(cl);
    partitionByGenComp = null;
    orderByComp = orderByGenComp.newInstance(cl);
    orderByGenComp = null;
    if (outputRankFunColumn) {
        joinedRow = new JoinedRowData();
        rankValueRow = new GenericRowData(1);
    }
    collector = new StreamRecordCollector<>(output);
}
Also used : JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) GenericRowData(org.apache.flink.table.data.GenericRowData)

Example 29 with GenericRowData

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

the class FirstValueAggFunction method resetAccumulator.

public void resetAccumulator(RowData rowData) {
    GenericRowData acc = (GenericRowData) rowData;
    acc.setField(0, null);
    acc.setField(1, Long.MAX_VALUE);
}
Also used : GenericRowData(org.apache.flink.table.data.GenericRowData)

Example 30 with GenericRowData

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

the class LastValueAggFunction method resetAccumulator.

public void resetAccumulator(RowData rowData) {
    GenericRowData acc = (GenericRowData) rowData;
    acc.setField(0, null);
    acc.setField(1, Long.MIN_VALUE);
}
Also used : 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