Package org.eclipse.rdf4j.repository.sparql.federation

## Class JoinExecutorBase<T>

- java.lang.Object
- - org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<E,​X>
  - - org.eclipse.rdf4j.common.iteration.LookAheadIteration<T,​QueryEvaluationException>
    - - org.eclipse.rdf4j.repository.sparql.federation.JoinExecutorBase<T>

- All Implemented Interfaces:
    `AutoCloseable`, `CloseableIteration<T,​QueryEvaluationException>`, `Iteration<T,​QueryEvaluationException>`
  Direct Known Subclasses:
    `JoinExecutorBase`

      public abstract class JoinExecutorBase<T>
      extends LookAheadIteration<T,​QueryEvaluationException>

  Base class for any join parallel join executor. Note that this class extends `LookAheadIteration` and thus any implementation of this class is applicable for pipelining when used in a different thread (access to shared variables is synchronized).
  Author:
    Andreas Schwarte

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected BindingSet` | `bindings` |
    `protected boolean` | `closed` | Deprecated. Use `AbstractCloseableIteration.isClosed()` instead.
    `protected boolean` | `finished` | Deprecated. Use `isFinished()` instead.
    `protected CloseableIteration<T,​QueryEvaluationException>` | `leftIter` |
    `protected static int` | `NEXT_JOIN_ID` | Deprecated. No replacement, don't use static shared int variables.
    `protected TupleExpr` | `rightArg` |
    `protected CloseableIteration<T,​QueryEvaluationException>` | `rightIter` |
    `protected QueueCursor<CloseableIteration<T,​QueryEvaluationException>>` | `rightQueue` |

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `JoinExecutorBase​(CloseableIteration<T,​QueryEvaluationException> leftIter, TupleExpr rightArg, BindingSet bindings)` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addResult​(CloseableIteration<T,​QueryEvaluationException> res)` |
    `void` | `done()` |
    `T` | `getNextElement()` | Gets the next element.
    `protected abstract void` | `handleBindings()` | Implementations must implement this method to handle bindings.
    `void` | `handleClose()` | Called by `AbstractCloseableIteration.close()` when it is called for the first time.
    `boolean` | `isFinished()` | Gets whether this executor is finished or aborted.
    `void` | `run()` |
    `void` | `toss​(Exception e)` |

    - ### Methods inherited from class org.eclipse.rdf4j.common.iteration.LookAheadIteration

      `hasNext, next, remove`

    - ### Methods inherited from class org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration

      `close, isClosed`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.rdf4j.common.iteration.Iteration

      `stream`

- - ### Field Detail

    - #### NEXT_JOIN_ID

          protected static int NEXT_JOIN_ID

      Deprecated.
      No replacement, don't use static shared int variables.

    - #### rightArg

          protected final TupleExpr rightArg

    - #### bindings

          protected final BindingSet bindings

    - #### leftIter

          protected final CloseableIteration<T,​QueryEvaluationException> leftIter

    - #### rightIter

          protected volatile CloseableIteration<T,​QueryEvaluationException> rightIter

    - #### closed

          protected volatile boolean closed

      Deprecated.
      Use `AbstractCloseableIteration.isClosed()` instead.

    - #### finished

          protected volatile boolean finished

      Deprecated.
      Use `isFinished()` instead.

    - #### rightQueue

          protected final QueueCursor<CloseableIteration<T,​QueryEvaluationException>> rightQueue

  - ### Constructor Detail

    - #### JoinExecutorBase

          protected JoinExecutorBase​(CloseableIteration<T,​QueryEvaluationException> leftIter,
                                     TupleExpr rightArg,
                                     BindingSet bindings)
                              throws QueryEvaluationException

      Throws:
        `QueryEvaluationException`

  - ### Method Detail

    - #### run

          public final void run()

    - #### handleBindings

          protected abstract void handleBindings()
                                          throws Exception

      Implementations must implement this method to handle bindings. Use the following as a template `while (!closed && leftIter.hasNext()) { // your code }` and add results to rightQueue. Note that addResult() is implemented synchronized and thus thread safe. In case you can guarantee sequential access, it is also possible to directly access rightQueue
      Throws:
        `Exception`

    - #### addResult

          public void addResult​(CloseableIteration<T,​QueryEvaluationException> res)

    - #### done

          public void done()

    - #### toss

          public void toss​(Exception e)

    - #### getNextElement

          public T getNextElement()
                           throws QueryEvaluationException

      Description copied from class: `LookAheadIteration`
      Gets the next element. Subclasses should implement this method so that it returns the next element.
      Specified by:
        `getNextElement` in class `LookAheadIteration<T,​QueryEvaluationException>`
      Returns:
        The next element, or null if no more elements are available.
      Throws:
        `QueryEvaluationException`

    - #### handleClose

          public void handleClose()
                           throws QueryEvaluationException

      Description copied from class: `AbstractCloseableIteration`
      Called by `AbstractCloseableIteration.close()` when it is called for the first time. This method is only called once on each iteration. By default, this method does nothing.
      Overrides:
        `handleClose` in class `LookAheadIteration<T,​QueryEvaluationException>`
      Throws:
        `QueryEvaluationException`

    - #### isFinished

          public boolean isFinished()

      Gets whether this executor is finished or aborted.
      Returns:
        true if this executor is finished or aborted