Search in sources :

Example 16 with JoinedRowData

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

the class MiniBatchLocalGroupAggFunction method open.

@Override
public void open(ExecutionContext ctx) throws Exception {
    super.open(ctx);
    // instantiate function
    function = genAggsHandler.newInstance(ctx.getRuntimeContext().getUserCodeClassLoader());
    function.open(new PerKeyStateDataViewStore(ctx.getRuntimeContext()));
    resultRow = new JoinedRowData();
}
Also used : JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) PerKeyStateDataViewStore(org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore)

Example 17 with JoinedRowData

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

the class AbstractWindowAggProcessor method open.

@Override
public void open(Context<Long> context) throws Exception {
    this.ctx = context;
    final LongSerializer namespaceSerializer = LongSerializer.INSTANCE;
    ValueState<RowData> state = ctx.getKeyedStateBackend().getOrCreateKeyedState(namespaceSerializer, new ValueStateDescriptor<>("window-aggs", accSerializer));
    this.windowState = new WindowValueState<>((InternalValueState<RowData, Long, RowData>) state);
    this.clockService = ClockService.of(ctx.getTimerService());
    this.windowTimerService = new WindowTimerServiceImpl(ctx.getTimerService(), shiftTimeZone);
    this.aggregator = genAggsHandler.newInstance(ctx.getRuntimeContext().getUserCodeClassLoader());
    this.aggregator.open(new PerWindowStateDataViewStore(ctx.getKeyedStateBackend(), namespaceSerializer, ctx.getRuntimeContext()));
    this.windowBuffer = windowBufferFactory.create(ctx.getOperatorOwner(), ctx.getMemoryManager(), ctx.getMemorySize(), ctx.getRuntimeContext(), windowTimerService, ctx.getKeyedStateBackend(), windowState, isEventTime, shiftTimeZone);
    this.reuseOutput = new JoinedRowData();
    this.currentProgress = Long.MIN_VALUE;
    this.nextTriggerProgress = Long.MIN_VALUE;
}
Also used : RowData(org.apache.flink.table.data.RowData) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) InternalValueState(org.apache.flink.runtime.state.internal.InternalValueState) LongSerializer(org.apache.flink.api.common.typeutils.base.LongSerializer) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) PerWindowStateDataViewStore(org.apache.flink.table.runtime.dataview.PerWindowStateDataViewStore) WindowTimerServiceImpl(org.apache.flink.table.runtime.operators.window.slicing.WindowTimerServiceImpl)

Example 18 with JoinedRowData

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

the class MiniBatchIncrementalGroupAggFunction method open.

@Override
public void open(ExecutionContext ctx) throws Exception {
    super.open(ctx);
    ClassLoader classLoader = ctx.getRuntimeContext().getUserCodeClassLoader();
    StateTtlConfig ttlConfig = createTtlConfig(stateRetentionTime);
    partialAgg = genPartialAggsHandler.newInstance(classLoader);
    partialAgg.open(new PerKeyStateDataViewStore(ctx.getRuntimeContext()));
    finalAgg = genFinalAggsHandler.newInstance(classLoader);
    finalAgg.open(new PerKeyStateDataViewStore(ctx.getRuntimeContext(), ttlConfig));
    resultRow = new JoinedRowData();
}
Also used : JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) StateTtlConfig(org.apache.flink.api.common.state.StateTtlConfig) PerKeyStateDataViewStore(org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore)

Example 19 with JoinedRowData

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

the class SortMergeJoinOperator method open.

@Override
public void open() throws Exception {
    super.open();
    Configuration conf = getContainingTask().getJobConfiguration();
    isFinished = new boolean[] { false, false };
    collector = new StreamRecordCollector<>(output);
    ClassLoader cl = getUserCodeClassloader();
    AbstractRowDataSerializer inputSerializer1 = (AbstractRowDataSerializer) getOperatorConfig().getTypeSerializerIn1(cl);
    this.serializer1 = new BinaryRowDataSerializer(inputSerializer1.getArity());
    AbstractRowDataSerializer inputSerializer2 = (AbstractRowDataSerializer) getOperatorConfig().getTypeSerializerIn2(cl);
    this.serializer2 = new BinaryRowDataSerializer(inputSerializer2.getArity());
    this.memManager = this.getContainingTask().getEnvironment().getMemoryManager();
    this.ioManager = this.getContainingTask().getEnvironment().getIOManager();
    long totalMemory = computeMemorySize();
    externalBufferMemory = (long) (totalMemory * externalBufferMemRatio);
    externalBufferMemory = Math.max(externalBufferMemory, ResettableExternalBuffer.MIN_NUM_MEMORY);
    long totalSortMem = totalMemory - (type.equals(FlinkJoinType.FULL) ? externalBufferMemory * 2 : externalBufferMemory);
    if (totalSortMem < 0) {
        throw new TableException("Memory size is too small: " + totalMemory + ", please increase manage memory of task manager.");
    }
    // sorter1
    this.sorter1 = new BinaryExternalSorter(this.getContainingTask(), memManager, totalSortMem / 2, ioManager, inputSerializer1, serializer1, computer1.newInstance(cl), comparator1.newInstance(cl), conf);
    this.sorter1.startThreads();
    // sorter2
    this.sorter2 = new BinaryExternalSorter(this.getContainingTask(), memManager, totalSortMem / 2, ioManager, inputSerializer2, serializer2, computer2.newInstance(cl), comparator2.newInstance(cl), conf);
    this.sorter2.startThreads();
    keyComparator = genKeyComparator.newInstance(cl);
    this.condFunc = condFuncCode.newInstance(cl);
    condFunc.setRuntimeContext(getRuntimeContext());
    condFunc.open(new Configuration());
    projection1 = projectionCode1.newInstance(cl);
    projection2 = projectionCode2.newInstance(cl);
    this.leftNullRow = new GenericRowData(serializer1.getArity());
    this.rightNullRow = new GenericRowData(serializer2.getArity());
    this.joinedRow = new JoinedRowData();
    condFuncCode = null;
    computer1 = null;
    comparator1 = null;
    computer2 = null;
    comparator2 = null;
    projectionCode1 = null;
    projectionCode2 = null;
    genKeyComparator = null;
    getMetricGroup().gauge("memoryUsedSizeInBytes", (Gauge<Long>) () -> sorter1.getUsedMemoryInBytes() + sorter2.getUsedMemoryInBytes());
    getMetricGroup().gauge("numSpillFiles", (Gauge<Long>) () -> sorter1.getNumSpillFiles() + sorter2.getNumSpillFiles());
    getMetricGroup().gauge("spillInBytes", (Gauge<Long>) () -> sorter1.getSpillInBytes() + sorter2.getSpillInBytes());
}
Also used : AbstractRowDataSerializer(org.apache.flink.table.runtime.typeutils.AbstractRowDataSerializer) TableException(org.apache.flink.table.api.TableException) Configuration(org.apache.flink.configuration.Configuration) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) BinaryExternalSorter(org.apache.flink.table.runtime.operators.sort.BinaryExternalSorter) GenericRowData(org.apache.flink.table.data.GenericRowData) BinaryRowDataSerializer(org.apache.flink.table.runtime.typeutils.BinaryRowDataSerializer)

Example 20 with JoinedRowData

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

the class IntervalJoinFunction method open.

@Override
public void open(Configuration config) throws Exception {
    this.joinCondition = joinConditionCode.newInstance(getRuntimeContext().getUserCodeClassLoader());
    this.joinConditionCode = null;
    this.joinCondition.setRuntimeContext(getRuntimeContext());
    this.joinCondition.open(config);
    this.reusedJoinRowData = new JoinedRowData();
}
Also used : JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData)

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