Class LinearBlockHoppingScanner

  • All Implemented Interfaces:
    Iterable<FlowNode>, Iterator<FlowNode>, Filterator<FlowNode>

    public class LinearBlockHoppingScanner
    extends LinearScanner
    Extension of LinearScanner that skips nested blocks at the current level, useful for finding enclosing blocks. ONLY use this with nodes inside the flow graph, never the last node of a completed flow (it will jump over the whole flow).

    This is useful where you only care about FlowNodes that precede this one or are part of an enclosing scope (within a Block).


    • Where a BlockEndNode is encountered, the scanner will jump to the BlockStartNode and go to its first parent.
    • The only case where you visit branches of a parallel block is if you begin inside it.

    Specific use cases:

    • Finding out the executor workspace used to run a FlowNode
    • Finding the start of the parallel block enclosing the current node
    • Locating the label applying to a given FlowNode (if any) if using labelled blocks
    Sam Van Oort
    • Constructor Detail

      • LinearBlockHoppingScanner

        public LinearBlockHoppingScanner()
    • Method Detail

      • setup

        public boolean setup​(@CheckForNull
                             Collection<FlowNode> heads,
                             Collection<FlowNode> blackList)
        Description copied from class: LinearScanner
        Set up for iteration/analysis on a graph of nodes, initializing the internal state Includes null-checking on arguments to allow directly calling with unchecked inputs (simplifies use).
        setup in class LinearScanner
        heads - The head nodes we start walking from (the most recently executed nodes, i.e. FlowExecution.getCurrentHeads()
        blackList - Nodes that we cannot visit or walk past (useful to limit scanning to only nodes after a specific point)
        True if we can have nodes to work with, otherwise false
      • setHeads

        protected void setHeads​(@NonNull
                                Collection<FlowNode> heads)
        Description copied from class: LinearScanner
        Set up to begin flow scanning using the filteredHeads as starting points This method makes several assumptions: - AbstractFlowScanner.reset() has already been invoked to reset state - filteredHeads has already had any points in AbstractFlowScanner.myBlackList removed - none of the filteredHeads are null
        setHeads in class LinearScanner
        heads - Head nodes that have been filtered against denyList. Do not pass multiple heads.
      • jumpBlockScan

        protected FlowNode jumpBlockScan​(@CheckForNull
                                         FlowNode node,
                                         Collection<FlowNode> blacklistNodes)
        Keeps jumping over blocks until we hit the first node preceding a block
      • next

        protected FlowNode next​(@CheckForNull
                                FlowNode current,
                                Collection<FlowNode> blackList)
        Description copied from class: AbstractFlowScanner
        Actual meat of the iteration, get the next node to visit, using and updating state as needed
        next in class LinearScanner
        current - Current node to use in generating next value
        blackList - Nodes that are not eligible for visiting
        Next node to visit, or null if we've exhausted the node list