Search in sources :

Example 1 with ExecutionContextImpl

use of org.apache.flink.table.runtime.context.ExecutionContextImpl 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 2 with ExecutionContextImpl

use of org.apache.flink.table.runtime.context.ExecutionContextImpl in project flink by apache.

the class AbstractMapBundleOperator method open.

@Override
public void open() throws Exception {
    super.open();
    function.open(new ExecutionContextImpl(this, getRuntimeContext()));
    this.numOfElements = 0;
    this.collector = new StreamRecordCollector<>(output);
    this.bundle = new HashMap<>();
    bundleTrigger.registerCallback(this);
    // reset trigger
    bundleTrigger.reset();
    LOG.info("BundleOperator's trigger info: " + bundleTrigger.explain());
    // counter metric to get the size of bundle
    getRuntimeContext().getMetricGroup().gauge("bundleSize", (Gauge<Integer>) () -> numOfElements);
    getRuntimeContext().getMetricGroup().gauge("bundleRatio", (Gauge<Double>) () -> {
        int numOfKeys = bundle.size();
        if (numOfKeys == 0) {
            return 0.0;
        } else {
            return 1.0 * numOfElements / numOfKeys;
        }
    });
}
Also used : ExecutionContextImpl(org.apache.flink.table.runtime.context.ExecutionContextImpl)

Aggregations

ExecutionContextImpl (org.apache.flink.table.runtime.context.ExecutionContextImpl)2 MemoryManager (org.apache.flink.runtime.memory.MemoryManager)1 JoinedRowData (org.apache.flink.table.data.utils.JoinedRowData)1 LazyMemorySegmentPool (org.apache.flink.table.runtime.util.LazyMemorySegmentPool)1 ResettableExternalBuffer (org.apache.flink.table.runtime.util.ResettableExternalBuffer)1