Search in sources :

Example 36 with JoinedRowData

use of org.apache.flink.table.data.utils.JoinedRowData in project flink by apache.

the class NonBufferOverWindowOperator method open.

@Override
public void open() throws Exception {
    super.open();
    ClassLoader cl = getUserCodeClassloader();
    serializer = (AbstractRowDataSerializer) getOperatorConfig().getTypeSerializerIn1(cl);
    partitionComparator = genComparator.newInstance(cl);
    genComparator = null;
    collector = new StreamRecordCollector<>(output);
    processors = new AggsHandleFunction[aggsHandlers.length];
    joinedRows = new JoinedRowData[aggsHandlers.length];
    for (int i = 0; i < aggsHandlers.length; i++) {
        AggsHandleFunction func = aggsHandlers[i].newInstance(cl);
        func.open(new PerKeyStateDataViewStore(getRuntimeContext()));
        processors[i] = func;
        joinedRows[i] = new JoinedRowData();
    }
    aggsHandlers = null;
}
Also used : JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) AggsHandleFunction(org.apache.flink.table.runtime.generated.AggsHandleFunction) GeneratedAggsHandleFunction(org.apache.flink.table.runtime.generated.GeneratedAggsHandleFunction) PerKeyStateDataViewStore(org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore)

Example 37 with JoinedRowData

use of org.apache.flink.table.data.utils.JoinedRowData in project flink by apache.

the class NonBufferOverWindowOperator method processElement.

@Override
public void processElement(StreamRecord<RowData> element) throws Exception {
    RowData input = element.getValue();
    boolean changePartition = lastInput == null || partitionComparator.compare(lastInput, input) != 0;
    // calculate the ACC
    RowData output = input;
    for (int i = 0; i < processors.length; i++) {
        AggsHandleFunction processor = processors[i];
        if (changePartition || resetAccumulators[i]) {
            processor.setAccumulators(processor.createAccumulators());
        }
        // TODO Reform AggsHandleFunction.getValue instead of use JoinedRowData. Multilayer
        // JoinedRowData is slow.
        processor.accumulate(input);
        RowData value = processor.getValue();
        output = joinedRows[i].replace(output, value);
    }
    collector.collect(output);
    if (changePartition) {
        lastInput = serializer.copy(input);
    }
}
Also used : RowData(org.apache.flink.table.data.RowData) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) AggsHandleFunction(org.apache.flink.table.runtime.generated.AggsHandleFunction) GeneratedAggsHandleFunction(org.apache.flink.table.runtime.generated.GeneratedAggsHandleFunction)

Example 38 with JoinedRowData

use of org.apache.flink.table.data.utils.JoinedRowData in project flink by apache.

the class BufferDataOverWindowOperator method open.

@Override
public void open() throws Exception {
    super.open();
    ClassLoader cl = getUserCodeClassloader();
    serializer = (AbstractRowDataSerializer) getOperatorConfig().getTypeSerializerIn1(cl);
    partitionComparator = genComparator.newInstance(cl);
    genComparator = null;
    MemoryManager memManager = getContainingTask().getEnvironment().getMemoryManager();
    LazyMemorySegmentPool pool = new LazyMemorySegmentPool(this, memManager, (int) (computeMemorySize() / memManager.getPageSize()));
    this.currentData = new ResettableExternalBuffer(getContainingTask().getEnvironment().getIOManager(), pool, serializer, isRowAllInFixedPart);
    collector = new StreamRecordCollector<>(output);
    joinedRows = new JoinedRowData[overWindowFrames.length];
    for (int i = 0; i < overWindowFrames.length; i++) {
        overWindowFrames[i].open(new ExecutionContextImpl(this, getRuntimeContext()));
        joinedRows[i] = new JoinedRowData();
    }
}
Also used : LazyMemorySegmentPool(org.apache.flink.table.runtime.util.LazyMemorySegmentPool) ResettableExternalBuffer(org.apache.flink.table.runtime.util.ResettableExternalBuffer) ExecutionContextImpl(org.apache.flink.table.runtime.context.ExecutionContextImpl) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) MemoryManager(org.apache.flink.runtime.memory.MemoryManager)

Example 39 with JoinedRowData

use of org.apache.flink.table.data.utils.JoinedRowData in project flink by apache.

the class ProcTimeRangeBoundedPrecedingFunction method open.

@Override
public void open(Configuration parameters) throws Exception {
    function = genAggsHandler.newInstance(getRuntimeContext().getUserCodeClassLoader());
    function.open(new PerKeyStateDataViewStore(getRuntimeContext()));
    output = new JoinedRowData();
    // input element are all binary row as they are came from network
    InternalTypeInfo<RowData> inputType = InternalTypeInfo.ofFields(inputFieldTypes);
    // we keep the elements received in a map state indexed based on their ingestion time
    ListTypeInfo<RowData> rowListTypeInfo = new ListTypeInfo<>(inputType);
    MapStateDescriptor<Long, List<RowData>> mapStateDescriptor = new MapStateDescriptor<>("inputState", BasicTypeInfo.LONG_TYPE_INFO, rowListTypeInfo);
    inputState = getRuntimeContext().getMapState(mapStateDescriptor);
    InternalTypeInfo<RowData> accTypeInfo = InternalTypeInfo.ofFields(accTypes);
    ValueStateDescriptor<RowData> stateDescriptor = new ValueStateDescriptor<RowData>("accState", accTypeInfo);
    accState = getRuntimeContext().getState(stateDescriptor);
    ValueStateDescriptor<Long> cleanupTsStateDescriptor = new ValueStateDescriptor<>("cleanupTsState", Types.LONG);
    this.cleanupTsState = getRuntimeContext().getState(cleanupTsStateDescriptor);
}
Also used : MapStateDescriptor(org.apache.flink.api.common.state.MapStateDescriptor) ValueStateDescriptor(org.apache.flink.api.common.state.ValueStateDescriptor) RowData(org.apache.flink.table.data.RowData) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) ListTypeInfo(org.apache.flink.api.java.typeutils.ListTypeInfo) ArrayList(java.util.ArrayList) List(java.util.List) PerKeyStateDataViewStore(org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore)

Example 40 with JoinedRowData

use of org.apache.flink.table.data.utils.JoinedRowData in project flink by apache.

the class ProcTimeUnboundedPrecedingFunction method open.

@Override
public void open(Configuration parameters) throws Exception {
    function = genAggsHandler.newInstance(getRuntimeContext().getUserCodeClassLoader());
    function.open(new PerKeyStateDataViewStore(getRuntimeContext()));
    output = new JoinedRowData();
    InternalTypeInfo<RowData> accTypeInfo = InternalTypeInfo.ofFields(accTypes);
    ValueStateDescriptor<RowData> stateDescriptor = new ValueStateDescriptor<RowData>("accState", accTypeInfo);
    accState = getRuntimeContext().getState(stateDescriptor);
    initCleanupTimeState("ProcTimeUnboundedOverCleanupTime");
}
Also used : ValueStateDescriptor(org.apache.flink.api.common.state.ValueStateDescriptor) RowData(org.apache.flink.table.data.RowData) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) PerKeyStateDataViewStore(org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore)

Aggregations

JoinedRowData (org.apache.flink.table.data.utils.JoinedRowData)47 RowData (org.apache.flink.table.data.RowData)22 GenericRowData (org.apache.flink.table.data.GenericRowData)17 ValueStateDescriptor (org.apache.flink.api.common.state.ValueStateDescriptor)12 PerKeyStateDataViewStore (org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore)12 BinaryRowData (org.apache.flink.table.data.binary.BinaryRowData)11 ArrayList (java.util.ArrayList)7 List (java.util.List)7 MapStateDescriptor (org.apache.flink.api.common.state.MapStateDescriptor)7 ListTypeInfo (org.apache.flink.api.java.typeutils.ListTypeInfo)5 StreamOperator (org.apache.flink.streaming.api.operators.StreamOperator)5 Test (org.junit.Test)5 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)4 StateTtlConfig (org.apache.flink.api.common.state.StateTtlConfig)4 Configuration (org.apache.flink.configuration.Configuration)4 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)3 TwoInputStreamTask (org.apache.flink.streaming.runtime.tasks.TwoInputStreamTask)3 TwoInputStreamTaskTestHarness (org.apache.flink.streaming.runtime.tasks.TwoInputStreamTaskTestHarness)3 StreamRecordRowDataWrappingCollector (org.apache.flink.table.runtime.operators.python.utils.StreamRecordRowDataWrappingCollector)3 RowDataSerializer (org.apache.flink.table.runtime.typeutils.RowDataSerializer)3