org.modeshape.jcr.query.engine.process

## Class CountableSequence

- java.lang.Object
- - org.modeshape.jcr.query.NodeSequence
  - - org.modeshape.jcr.query.engine.process.CountableSequence

- Direct Known Subclasses:
    PartialMemoryCountableSequence

      public class CountableSequence
      extends NodeSequence

  A sequence that will return an accurate size for a given NodeSequence by buffering and counting the nodes and then accessing the buffered sequence.
  See Also:
    `PartialMemoryCountableSequence`

- - ### Nested Class Summary

    - ### 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 AtomicLong` | `remainingRowCount`
    `protected int` | `width`
    `protected String` | `workspaceName`

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

      `LOGGER, NO_PASS_ROW_FILTER, PASS_ROW_FILTER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CountableSequence(String workspaceName, NodeSequence original, BufferManager bufferMgr, CachedNodeSupplier nodeCache, boolean useHeap)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected NodeSequence.Batch` | `batchFrom(Iterator<BufferedRows.BufferedRow> rows, long maxBatchSize)`
    `void` | `close()` Signal that this node sequence is no longer needed.
    `protected BufferedRows.BufferedRow` | `createRow(NodeSequence.Batch currentRow)`
    `protected void` | `doInitialize()`
    `protected NodeSequence.Batch` | `doNextBatch()`
    `long` | `getRowCount()` Get the number of rows in this sequence.
    `void` | `initialize()`
    `boolean` | `isEmpty()` Determine whether this results is known to be empty.
    `protected long` | `loadAll(NodeSequence sequence, BufferManager.QueueBuffer<BufferedRows.BufferedRow> buffer, AtomicLong batchSize)` Load all of the rows from the supplied sequence into the buffer.
    `protected long` | `loadAll(NodeSequence sequence, BufferManager.QueueBuffer<BufferedRows.BufferedRow> buffer, AtomicLong batchSize, Queue<NodeSequence.Batch> inMemoryBatches, int numRowsInMemory)` Load all of the rows from the supplied sequence into the buffer.
    `NodeSequence.Batch` | `nextBatch()` Get the next batch of `NodeKey` instances.
    `int` | `width()` Get the number of nodes in each row.

    - ### 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, 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

    - #### remainingRowCount

          protected final AtomicLong remainingRowCount

    - #### workspaceName

          protected final String workspaceName

    - #### width

          protected final int width

  - ### Constructor Detail

    - #### CountableSequence

          public CountableSequence(String workspaceName,
                           NodeSequence original,
                           BufferManager bufferMgr,
                           CachedNodeSupplier nodeCache,
                           boolean useHeap)

  - ### Method Detail

    - #### width

          public int width()

      Description copied from class: `NodeSequence`
      Get the number of nodes in each row.
      Specified by:
        `width` in class `NodeSequence`
      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.
      Specified by:
        `isEmpty` in class `NodeSequence`
      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

    - #### getRowCount

          public long getRowCount()

      Description copied from class: `NodeSequence`
      Get the number of rows in this sequence. If the actual number of rows is not known, this method returns -1.
      Specified by:
        `getRowCount` in class `NodeSequence`
      Returns:
        the number of rows, or -1 if the number of rows is not known or cannot be found with significant overhead

    - #### nextBatch

          public final NodeSequence.Batch nextBatch()

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

    - #### doNextBatch

          protected NodeSequence.Batch doNextBatch()

    - #### close

          public void close()

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

    - #### initialize

          public final void initialize()

    - #### doInitialize

          protected void doInitialize()

    - #### loadAll

          protected long loadAll(NodeSequence sequence,
                     BufferManager.QueueBuffer<BufferedRows.BufferedRow> buffer,
                     AtomicLong batchSize)

      Load all of the rows from the supplied sequence into the buffer.
      Parameters:
        `sequence` - the node sequence; may not be null
        `buffer` - the buffer into which all rows should be loaded; may not be null
        `batchSize` - the atomic that should be set with the size of the first batch
      Returns:
        the total number of rows

    - #### loadAll

          protected long loadAll(NodeSequence sequence,
                     BufferManager.QueueBuffer<BufferedRows.BufferedRow> buffer,
                     AtomicLong batchSize,
                     Queue<NodeSequence.Batch> inMemoryBatches,
                     int numRowsInMemory)

      Load all of the rows from the supplied sequence into the buffer.
      Parameters:
        `sequence` - the node sequence; may not be null
        `buffer` - the buffer into which all rows should be loaded; may not be null
        `batchSize` - the atomic that should be set with the size of the first batch
        `inMemoryBatches` - the queue into which batches that are kept in-memory; may be null, in which case all batches are placed into the buffer
        `numRowsInMemory` - the approximate number of rows that should be kept in-memory; may be non-positive if all batches are to be placed into the buffer
      Returns:
        the total number of rows

    - #### createRow

          protected BufferedRows.BufferedRow createRow(NodeSequence.Batch currentRow)

    - #### batchFrom

          protected NodeSequence.Batch batchFrom(Iterator<BufferedRows.BufferedRow> rows,
                                     long maxBatchSize)

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