use of org.knime.core.data.filestore.internal.NestedLoopStartWriteFileStoreHandler 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;
}
Aggregations