org.modeshape.jcr.query.engine.process

## Class JoinSequence

- java.lang.Object
- - org.modeshape.jcr.query.NodeSequence
  - - org.modeshape.jcr.query.engine.process.DelegatingSequence
    - - org.modeshape.jcr.query.engine.process.BufferingSequence
      - - org.modeshape.jcr.query.engine.process.JoinSequence

- Direct Known Subclasses:
    HashJoinSequence

      @NotThreadSafe
      public abstract class JoinSequence
      extends BufferingSequence

  A `NodeSequence` implementation that performs a join of two delegate sequences.
  See Also:
    `HashJoinSequence`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static interface` | `JoinSequence.BatchFactory` A factory for batches.
    `protected class` | `JoinSequence.EmptyBatchFactory` A `JoinSequence.BatchFactory` that always returns null.
    `protected class` | `JoinSequence.LeftOnlyBatch`
    `protected class` | `JoinSequence.LeftOnlyBatchFactory` A `JoinSequence.BatchFactory` for batches that return only the left-hand rows.
    `static class` | `JoinSequence.Range<K>`
    `static interface` | `JoinSequence.RangeProducer<K>`
    `protected class` | `JoinSequence.RightOnlyBatch`
    `protected class` | `JoinSequence.RightOnlyBatchFactory` A `JoinSequence.BatchFactory` for batches that return only the right-hand rows.

    - ### Nested classes/interfaces inherited from class org.modeshape.jcr.query.NodeSequence

      `NodeSequence.AlternateSizeBatch, NodeSequence.Batch, NodeSequence.LimitBatch, NodeSequence.MultiWidthBatch, NodeSequence.Restartable, NodeSequence.RowAccessor, NodeSequence.RowFilter, NodeSequence.SingleWidthBatch`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `batchSize`
    `protected NodeSequence.Batch` | `currentLeft`
    `protected JoinType` | `joinType`
    `protected NodeSequence` | `left`
    `protected RowExtractors.ExtractFromRow` | `leftExtractor`
    `protected int` | `leftWidth`
    `protected int` | `totalWidth`

    - ### Fields inherited from class org.modeshape.jcr.query.engine.process.BufferingSequence

      `buffer, cache, extractor, logger, remainingRowCount, rowFactory, trace, width, workspaceName`

    - ### Fields inherited from class org.modeshape.jcr.query.engine.process.DelegatingSequence

      `delegate`

    - ### Fields inherited from class org.modeshape.jcr.query.NodeSequence

      `LOGGER, NO_PASS_ROW_FILTER, PASS_ROW_FILTER`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `JoinSequence(String workspaceName, NodeSequence left, NodeSequence right, RowExtractors.ExtractFromRow leftExtractor, RowExtractors.ExtractFromRow rightExtractor, JoinType joinType, BufferManager bufferMgr, CachedNodeSupplier nodeCache, boolean pack, boolean useHeap, boolean allowDuplicates)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Signal that this node sequence is no longer needed.
    `protected NodeSequence.Batch` | `findNextNonEmptyLeftBatch()`
    `protected abstract JoinSequence.BatchFactory` | `initialize()` Called once when the implementation is to create a `JoinSequence.BatchFactory` for all batches returned by this join sequence.
    `boolean` | `isEmpty()` Determine whether this results is known to be empty.
    `NodeSequence.Batch` | `nextBatch()` Get the next batch of `NodeKey` instances.
    `protected boolean` | `useAllLeftRowsWhenNoMatchingRightRows()` Determine whether the algorithm that encounters a left row with no matching right rows should still include such left rows in the result.
    `protected boolean` | `useAllRightRowsWhenNoLeftRows()` Determine whether the algorithm that encounters no left rows should process the right rows.
    `protected boolean` | `useNonMatchingRightRows()` Determine whether the algorithm should return rows from the right-side of the join that were no matched to left rows.
    `int` | `width()` Get the number of nodes in each row.

    - ### Methods inherited from class org.modeshape.jcr.query.engine.process.BufferingSequence

      `batchFrom, createRow, loadAll, rowCount`

    - ### Methods inherited from class org.modeshape.jcr.query.engine.process.DelegatingSequence

      `getRowCount`

    - ### Methods inherited from class org.modeshape.jcr.query.NodeSequence

      `append, batchFilteredWith, batchOf, batchOf, batchOf, batchOfKeys, batchOfKeys, batchOfKeys, batchOfKeys, batchWithCount, copy, emptyBatch, emptySequence, filter, keyFor, limit, limit, merging, requireBoth, requireEither, skip, slice, slicingBatch, withBatch, withBatches, withBatches, withNode, withNodeKeys, withNodeKeys, withNodeKeys, withNodeKeys, withNodes, withNodes`

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

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

- - ### Field Detail

    - #### left

          protected final NodeSequence left

    - #### leftExtractor

          protected final RowExtractors.ExtractFromRow leftExtractor

    - #### leftWidth

          protected final int leftWidth

    - #### totalWidth

          protected final int totalWidth

    - #### joinType

          protected final JoinType joinType

    - #### batchSize

          protected int batchSize

    - #### currentLeft

          protected NodeSequence.Batch currentLeft

  - ### Constructor Detail

    - #### JoinSequence

          protected JoinSequence(String workspaceName,
                      NodeSequence left,
                      NodeSequence right,
                      RowExtractors.ExtractFromRow leftExtractor,
                      RowExtractors.ExtractFromRow rightExtractor,
                      JoinType joinType,
                      BufferManager bufferMgr,
                      CachedNodeSupplier nodeCache,
                      boolean pack,
                      boolean useHeap,
                      boolean allowDuplicates)

  - ### Method Detail

    - #### width

          public int width()

      Description copied from class: `NodeSequence`
      Get the number of nodes in each row.
      Overrides:
        `width` in class `DelegatingSequence`
      Returns:
        the width of each row; always positive

    - #### isEmpty

          public boolean isEmpty()

      Description copied from class: `NodeSequence`
      Determine whether this results is known to be empty.
      Overrides:
        `isEmpty` in class `BufferingSequence`
      Returns:
        the true if there are no results, or false if there is at least some or if the number of rows is not known

    - #### nextBatch

          public NodeSequence.Batch nextBatch()

      Description copied from class: `NodeSequence`
      Get the next batch of `NodeKey` instances.
      Overrides:
        `nextBatch` in class `DelegatingSequence`
      Returns:
        the next batch, or null if there are no more batches.

    - #### findNextNonEmptyLeftBatch

          protected NodeSequence.Batch findNextNonEmptyLeftBatch()

    - #### initialize

          protected abstract JoinSequence.BatchFactory initialize()

      Called once when the implementation is to create a `JoinSequence.BatchFactory` for all batches returned by this join sequence. This is called only when we know that there are at least some rows on the left side.
      Returns:
        the batch factory that should be used to obtain the batches; never null

    - #### useAllRightRowsWhenNoLeftRows

          protected boolean useAllRightRowsWhenNoLeftRows()

      Determine whether the algorithm that encounters no left rows should process the right rows. This method only returns true when the `join type` is a `right outer join`.

      The `cross join` (or Cartesian Product) is not included because the number of rows returned will be `Nleft x Nright`, where `Nleft` is the number of rows on the left-hand side, and `Nright` is the number of rows on the right-hand side. Therefore, if either is empty, the result is empty.

      Returns:
        true if the right rows should be returned when there are no left rows, or false otherwise

    - #### useAllLeftRowsWhenNoMatchingRightRows

          protected boolean useAllLeftRowsWhenNoMatchingRightRows()

      Determine whether the algorithm that encounters a left row with no matching right rows should still include such left rows in the result. This method only returns true when the `join type` is a `full outer join` or `left outer join`.
      Returns:
        true if the left rows should be returned even when there are no matching rows on the right, or false otherwise

    - #### useNonMatchingRightRows

          protected boolean useNonMatchingRightRows()

      Determine whether the algorithm should return rows from the right-side of the join that were no matched to left rows. This method only returns true when the `join type` is a `full outer join` or `right outer join`.
      Returns:
        true if the join algorithm should return rows on the right that did not match rows on the left, or false otherwise

    - #### close

          public void close()

      Description copied from class: `NodeSequence`
      Signal that this node sequence is no longer needed.
      Overrides:
        `close` in class `BufferingSequence`

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.