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();
}
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;
}
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();
}
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());
}
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();
}
Aggregations