Search in sources :

Example 1 with LoopStartWriteFileStoreHandler

use of org.knime.core.data.filestore.internal.LoopStartWriteFileStoreHandler in project knime-core by knime.

the class NativeNodeContainer method initLoopScopeFileStoreHandler.

/**
 * Inits the file store handler if node is part of a loop scope (including start and end).
 *
 * @param upstreamFLC optional loop context this node might be part of
 * @param innerFLC optional loop context beginning at this node if this node is a loop start
 * @param targetFSH file store handler to be referenced if given
 * @return the file store handler or <code>null</code> if not a loop scope
 */
private IWriteFileStoreHandler initLoopScopeFileStoreHandler(final FlowLoopContext upstreamFLC, final FlowLoopContext innerFLC, final IWriteFileStoreHandler targetFSH) {
    IFileStoreHandler oldFSHandler = m_node.getFileStoreHandler();
    IWriteFileStoreHandler newFSHandler = null;
    if (innerFLC != null) {
        // node is a loop start node
        assert innerFLC.getIterationIndex() == 0;
        if (oldFSHandler instanceof IWriteFileStoreHandler) {
            assert false : "Loop Start " + getNameWithID() + " must not have file store handler at this point " + "(no iteration ran), disposing old handler";
            clearFileStoreHandler();
        }
        if (upstreamFLC != null) {
            ILoopStartWriteFileStoreHandler upStreamFSHandler = upstreamFLC.getFileStoreHandler();
            newFSHandler = new NestedLoopStartWriteFileStoreHandler(upStreamFSHandler, innerFLC);
        } else if (targetFSH != null) {
            // there is another target file store handler
            // -> loop start file store handler references it
            newFSHandler = new LoopStartWriteFileStoreHandler(this, targetFSH, innerFLC);
        } else {
            // create entirely new loop start file store handler (without referencing another handler)
            newFSHandler = new LoopStartWriteFileStoreHandler(this, UUID.randomUUID(), innerFLC);
        }
        innerFLC.setFileStoreHandler((ILoopStartWriteFileStoreHandler) newFSHandler);
    } else {
        // ordinary node contained in loop
        assert upstreamFLC != null;
        assert upstreamFLC.getIterationIndex() == 0;
        ILoopStartWriteFileStoreHandler upStreamFSHandler = upstreamFLC.getFileStoreHandler();
        if (upStreamFSHandler != null) {
            if (this.isModelCompatibleTo(LoopEndNode.class)) {
                newFSHandler = new LoopEndWriteFileStoreHandler(upStreamFSHandler);
            } else {
                newFSHandler = new ReferenceWriteFileStoreHandler(upStreamFSHandler);
            }
        } else {
            // for an 'InactiveBranchConsumer-loop end'
            assert this.isModelCompatibleTo(InactiveBranchConsumer.class);
        }
    }
    return newFSHandler;
}
Also used : LoopStartWriteFileStoreHandler(org.knime.core.data.filestore.internal.LoopStartWriteFileStoreHandler) NestedLoopStartWriteFileStoreHandler(org.knime.core.data.filestore.internal.NestedLoopStartWriteFileStoreHandler) ILoopStartWriteFileStoreHandler(org.knime.core.data.filestore.internal.ILoopStartWriteFileStoreHandler) IWriteFileStoreHandler(org.knime.core.data.filestore.internal.IWriteFileStoreHandler) NestedLoopStartWriteFileStoreHandler(org.knime.core.data.filestore.internal.NestedLoopStartWriteFileStoreHandler) IFileStoreHandler(org.knime.core.data.filestore.internal.IFileStoreHandler) ILoopStartWriteFileStoreHandler(org.knime.core.data.filestore.internal.ILoopStartWriteFileStoreHandler) ReferenceWriteFileStoreHandler(org.knime.core.data.filestore.internal.ReferenceWriteFileStoreHandler) LoopEndWriteFileStoreHandler(org.knime.core.data.filestore.internal.LoopEndWriteFileStoreHandler)

Aggregations

IFileStoreHandler (org.knime.core.data.filestore.internal.IFileStoreHandler)1 ILoopStartWriteFileStoreHandler (org.knime.core.data.filestore.internal.ILoopStartWriteFileStoreHandler)1 IWriteFileStoreHandler (org.knime.core.data.filestore.internal.IWriteFileStoreHandler)1 LoopEndWriteFileStoreHandler (org.knime.core.data.filestore.internal.LoopEndWriteFileStoreHandler)1 LoopStartWriteFileStoreHandler (org.knime.core.data.filestore.internal.LoopStartWriteFileStoreHandler)1 NestedLoopStartWriteFileStoreHandler (org.knime.core.data.filestore.internal.NestedLoopStartWriteFileStoreHandler)1 ReferenceWriteFileStoreHandler (org.knime.core.data.filestore.internal.ReferenceWriteFileStoreHandler)1