Search in sources :

Example 46 with JoinedRowData

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

the class MiniBatchGlobalGroupAggFunction method open.

@Override
public void open(ExecutionContext ctx) throws Exception {
    super.open(ctx);
    StateTtlConfig ttlConfig = createTtlConfig(stateRetentionTime);
    localAgg = genLocalAggsHandler.newInstance(ctx.getRuntimeContext().getUserCodeClassLoader());
    localAgg.open(new PerKeyStateDataViewStore(ctx.getRuntimeContext()));
    globalAgg = genGlobalAggsHandler.newInstance(ctx.getRuntimeContext().getUserCodeClassLoader());
    globalAgg.open(new PerKeyStateDataViewStore(ctx.getRuntimeContext(), ttlConfig));
    equaliser = genRecordEqualiser.newInstance(ctx.getRuntimeContext().getUserCodeClassLoader());
    InternalTypeInfo<RowData> accTypeInfo = InternalTypeInfo.ofFields(accTypes);
    ValueStateDescriptor<RowData> accDesc = new ValueStateDescriptor<>("accState", accTypeInfo);
    if (ttlConfig.isEnabled()) {
        accDesc.enableTimeToLive(ttlConfig);
    }
    accState = ctx.getRuntimeContext().getState(accDesc);
    resultRow = new JoinedRowData();
}
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) StateTtlConfig(org.apache.flink.api.common.state.StateTtlConfig) PerKeyStateDataViewStore(org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore)

Example 47 with JoinedRowData

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

the class HashJoinOperator method open.

@Override
public void open() throws Exception {
    super.open();
    ClassLoader cl = getContainingTask().getUserCodeClassLoader();
    final AbstractRowDataSerializer buildSerializer = (AbstractRowDataSerializer) getOperatorConfig().getTypeSerializerIn1(getUserCodeClassloader());
    final AbstractRowDataSerializer probeSerializer = (AbstractRowDataSerializer) getOperatorConfig().getTypeSerializerIn2(getUserCodeClassloader());
    boolean hashJoinUseBitMaps = getContainingTask().getEnvironment().getTaskConfiguration().getBoolean(AlgorithmOptions.HASH_JOIN_BLOOM_FILTERS);
    int parallel = getRuntimeContext().getNumberOfParallelSubtasks();
    this.condition = parameter.condFuncCode.newInstance(cl);
    condition.setRuntimeContext(getRuntimeContext());
    condition.open(new Configuration());
    this.table = new BinaryHashTable(getContainingTask().getJobConfiguration(), getContainingTask(), buildSerializer, probeSerializer, parameter.buildProjectionCode.newInstance(cl), parameter.probeProjectionCode.newInstance(cl), getContainingTask().getEnvironment().getMemoryManager(), computeMemorySize(), getContainingTask().getEnvironment().getIOManager(), parameter.buildRowSize, parameter.buildRowCount / parallel, hashJoinUseBitMaps, type, condition, reverseJoinFunction, parameter.filterNullKeys, parameter.tryDistinctBuildRow);
    this.collector = new StreamRecordCollector<>(output);
    this.buildSideNullRow = new GenericRowData(buildSerializer.getArity());
    this.probeSideNullRow = new GenericRowData(probeSerializer.getArity());
    this.joinedRow = new JoinedRowData();
    this.buildEnd = false;
    getMetricGroup().gauge("memoryUsedSizeInBytes", table::getUsedMemoryInBytes);
    getMetricGroup().gauge("numSpillFiles", table::getNumSpillFiles);
    getMetricGroup().gauge("spillInBytes", table::getSpillInBytes);
    parameter.condFuncCode = null;
    parameter.buildProjectionCode = null;
    parameter.probeProjectionCode = null;
}
Also used : AbstractRowDataSerializer(org.apache.flink.table.runtime.typeutils.AbstractRowDataSerializer) Configuration(org.apache.flink.configuration.Configuration) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) BinaryHashTable(org.apache.flink.table.runtime.hashtable.BinaryHashTable) GenericRowData(org.apache.flink.table.data.GenericRowData) InputSelectable(org.apache.flink.streaming.api.operators.InputSelectable)

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