@NotThreadSafe public abstract class NodeSequence extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
NodeSequence.AlternateSizeBatch |
static interface |
NodeSequence.Batch
A batch of rows containing nodes and scores.
|
protected static class |
NodeSequence.LimitBatch |
protected static class |
NodeSequence.MultiWidthBatch |
static interface |
NodeSequence.Restartable |
static interface |
NodeSequence.RowAccessor
An interface that abstracts accessing the node(s) and score(s) in a row.
|
static interface |
NodeSequence.RowFilter
A filter of rows.
|
protected static class |
NodeSequence.SingleWidthBatch |
Modifier and Type | Field and Description |
---|---|
protected static Logger |
LOGGER |
static NodeSequence.RowFilter |
NO_PASS_ROW_FILTER |
static NodeSequence.RowFilter |
PASS_ROW_FILTER |
Constructor and Description |
---|
NodeSequence() |
Modifier and Type | Method and Description |
---|---|
static NodeSequence |
append(NodeSequence first,
NodeSequence second)
Create a sequence of nodes that contains the nodes from the first sequence followed by the second sequence.
|
static NodeSequence.Batch |
batchFilteredWith(NodeSequence.Batch batch,
NodeSequence.RowFilter filter)
Create a batch that applies the given filter to the supplied batch.
|
static NodeSequence.Batch |
batchOf(Collection<CachedNode> nodes,
float score,
String workspaceName)
Create a batch of nodes around the supplied iterable container.
|
static NodeSequence.Batch |
batchOf(Iterator<CachedNode> nodes,
long nodeCount,
float score,
String workspaceName)
Create a batch of nodes around the supplied iterator.
|
protected static NodeSequence.Batch |
batchOf(NodeSequence.Batch first,
NodeSequence.Batch second,
int firstWidth,
int secondWidth) |
static NodeSequence.Batch |
batchOfKeys(Collection<NodeKey> keys,
float score,
String workspaceName,
RepositoryCache repository)
Create a batch of nodes around the supplied iterable container.
|
static NodeSequence.Batch |
batchOfKeys(Iterator<NodeKey> keys,
Iterator<Float> scores,
long nodeCount,
String workspaceName,
RepositoryCache repository)
Create a batch of nodes around the supplied iterator and the scores iterator.
|
static NodeSequence.Batch |
batchOfKeys(Iterator<NodeKey> keys,
long nodeCount,
float score,
String workspaceName,
NodeCache cache)
Create a batch of nodes around the supplied iterator.
|
static NodeSequence.Batch |
batchOfKeys(Iterator<NodeKey> keys,
long nodeCount,
float score,
String workspaceName,
RepositoryCache repository)
Create a batch of nodes around the supplied iterator.
|
static NodeSequence.Batch |
batchWithCount(NodeSequence.Batch batch)
Create a batch that always has a
NodeSequence.Batch.rowCount() , even if that means returning a new Batch that buffers the
original's rows it into memory. |
abstract void |
close()
Signal that this node sequence is no longer needed.
|
static NodeSequence.Batch |
copy(NodeSequence.Batch batch)
Create a copy of a batch that always has a
NodeSequence.Batch.rowCount() . |
static NodeSequence.Batch |
emptyBatch(String workspaceName,
int width)
Get a batch of nodes that is empty.
|
static NodeSequence |
emptySequence(int width)
Get an empty node sequence.
|
static NodeSequence |
filter(NodeSequence sequence,
NodeSequence.RowFilter filter)
Create a sequence of nodes that all satisfy the supplied filter.
|
abstract long |
getRowCount()
Get the number of rows in this sequence.
|
abstract boolean |
isEmpty()
Determine whether this results is known to be empty.
|
protected static NodeKey |
keyFor(CachedNode node) |
static NodeSequence |
limit(NodeSequence sequence,
Limit limitAndOffset)
Create a sequence of nodes that skips a specified number of nodes before returning any nodes and that limits the number of
nodes returned.
|
static NodeSequence |
limit(NodeSequence sequence,
long maxRows)
Create a sequence of nodes that returns at most the supplied number of rows.
|
static NodeSequence |
merging(NodeSequence first,
NodeSequence second,
int totalWidth)
Create a sequence of nodes that merges the two supplied sequences.
|
abstract NodeSequence.Batch |
nextBatch()
Get the next batch of
NodeKey instances. |
static NodeSequence.RowFilter |
requireBoth(NodeSequence.RowFilter first,
NodeSequence.RowFilter second) |
static NodeSequence.RowFilter |
requireEither(NodeSequence.RowFilter first,
NodeSequence.RowFilter second) |
static NodeSequence |
skip(NodeSequence sequence,
int skip)
Create a sequence of nodes that skips a specified number of rows before returning any rows.
|
static NodeSequence |
slice(NodeSequence original,
QueryResults.Columns columns)
Create a sequence of nodes that include only those selectors defined by the given columns.
|
protected static NodeSequence.Batch |
slicingBatch(NodeSequence.Batch original,
int[] selectorIndexes) |
abstract int |
width()
Get the number of nodes in each row.
|
static NodeSequence |
withBatch(NodeSequence.Batch sequence)
Create a sequence of nodes that returns the supplied single batch of nodes.
|
static NodeSequence |
withBatches(Collection<NodeSequence.Batch> batches,
int width)
Create a sequence of nodes that iterates over the supplied batches of nodes.
|
static NodeSequence |
withBatches(Iterator<NodeSequence.Batch> batches,
int width,
long rowCount)
Create a sequence of nodes that iterates over the supplied batches of nodes.
|
static NodeSequence |
withNode(CachedNode node,
int width,
float score,
String workspaceName) |
static NodeSequence |
withNodeKeys(Collection<NodeKey> keys,
float score,
String workspaceName,
NodeCache cache)
Create a sequence of nodes that iterates over the supplied node keys.
|
static NodeSequence |
withNodeKeys(Collection<NodeKey> keys,
float score,
String workspaceName,
RepositoryCache repository)
Create a sequence of nodes that iterates over the supplied node keys.
|
static NodeSequence |
withNodeKeys(Iterator<NodeKey> keys,
long keyCount,
float score,
String workspaceName,
NodeCache cache)
Create a sequence of nodes that iterates over the supplied node keys.
|
static NodeSequence |
withNodeKeys(Iterator<NodeKey> keys,
long keyCount,
float score,
String workspaceName,
RepositoryCache repository)
Create a sequence of nodes that iterates over the supplied node keys.
|
static NodeSequence |
withNodes(Collection<CachedNode> nodes,
float score,
String workspaceName)
Create a sequence of nodes that iterates over the supplied nodes.
|
static NodeSequence |
withNodes(Iterator<CachedNode> nodes,
long nodeCount,
float score,
String workspaceName)
Create a sequence of nodes that iterates over the supplied nodes.
|
protected static final Logger LOGGER
public static final NodeSequence.RowFilter NO_PASS_ROW_FILTER
public static final NodeSequence.RowFilter PASS_ROW_FILTER
public abstract int width()
public abstract long getRowCount()
public abstract boolean isEmpty()
public abstract NodeSequence.Batch nextBatch()
NodeKey
instances.public abstract void close()
public static NodeSequence emptySequence(int width)
width
- the width of the batches; must be positivepublic static NodeSequence.Batch emptyBatch(String workspaceName, int width)
workspaceName
- the name of the workspacewidth
- the width of the batch; must be positivepublic static NodeSequence withBatch(NodeSequence.Batch sequence)
sequence
- the node keys to be returned; if null, an empty instance
is returnedpublic static NodeSequence withBatches(Collection<NodeSequence.Batch> batches, int width)
used
.batches
- the iterable container containing the node batches to be returned; if null, an empty
instance
is returnedwidth
- the width of the batch; must be positivepublic static NodeSequence withBatches(Iterator<NodeSequence.Batch> batches, int width, long rowCount)
used
.batches
- the iterator over the nodes to be returned; if null, an empty instance
is returnedwidth
- the width of the batch; must be positive, and must be the width of all the batchesrowCount
- the number of rows in the batches; must be -1 if not known, 0 if known to be empty, or a positive number if
the number of rows is knownwithBatches(Collection, int)
public static NodeSequence withNodes(Collection<CachedNode> nodes, float score, String workspaceName)
first batch
is used
.nodes
- the iterator over the nodes to be returned; if null, an empty instance
is returnedscore
- the score to return for all of the nodesworkspaceName
- the name of the workspace in which all of the nodes existpublic static NodeSequence withNodes(Iterator<CachedNode> nodes, long nodeCount, float score, String workspaceName)
first batch
is used
.nodes
- the iterator over the node keys to be returned; if null, an empty instance
is returnednodeCount
- the number of nodes in the iterator; must be -1 if not known, 0 if known to be empty, or a positive number
if the number of nodes is knownscore
- the score to return for all of the nodesworkspaceName
- the name of the workspace in which all of the nodes existpublic static NodeSequence withNode(CachedNode node, int width, float score, String workspaceName)
public static NodeSequence withNodeKeys(Collection<NodeKey> keys, float score, String workspaceName, RepositoryCache repository)
first batch
is used
.keys
- the iterator over the keys of the nodes to be returned; if null, an empty instance
is
returnedscore
- the score to return for all of the nodesworkspaceName
- the name of the workspace in which all of the nodes existrepository
- the repository cache used to access the workspaces and cached nodes; may be null only if the key sequence
is null or emptypublic static NodeSequence withNodeKeys(Collection<NodeKey> keys, float score, String workspaceName, NodeCache cache)
first batch
is used
.keys
- the iterator over the keys of the nodes to be returned; if null, an empty instance
is
returnedscore
- the score to return for all of the nodesworkspaceName
- the name of the workspace in which all of the nodes existcache
- the cache used to access the cached nodes; may be null only if the key sequence is null or emptypublic static NodeSequence withNodeKeys(Iterator<NodeKey> keys, long keyCount, float score, String workspaceName, RepositoryCache repository)
first batch
is used
.keys
- the iterator over the keys of the node keys to be returned; if null, an empty instance
is returnedkeyCount
- the number of node keys in the iterator; must be -1 if not known, 0 if known to be empty, or a positive
number if the number of node keys is knownscore
- the score to return for all of the nodesworkspaceName
- the name of the workspace in which all of the nodes existrepository
- the repository cache used to access the workspaces and cached nodes; may be null only if the key sequence
is null or emptypublic static NodeSequence withNodeKeys(Iterator<NodeKey> keys, long keyCount, float score, String workspaceName, NodeCache cache)
first batch
is used
.keys
- the iterator over the keys of the node keys to be returned; if null, an empty instance
is returnedkeyCount
- the number of node keys in the iterator; must be -1 if not known, 0 if known to be empty, or a positive
number if the number of node keys is knownscore
- the score to return for all of the nodesworkspaceName
- the name of the workspace in which all of the nodes existcache
- the node cache used to access the cached nodes; may be null only if the key sequence is null or emptypublic static NodeSequence limit(NodeSequence sequence, Limit limitAndOffset)
sequence
- the original sequence that is to be limited; may be nulllimitAndOffset
- the specification of the offset and limit; if null this method simply returns sequence
public static NodeSequence limit(NodeSequence sequence, long maxRows)
sequence
- the original sequence that is to be limited; may be nullmaxRows
- the maximum number of rows that are to be returned by the sequence; should be positive or this method simply
returns sequence
public static NodeSequence skip(NodeSequence sequence, int skip)
sequence
- the original sequence that is to be limited; may be nullskip
- the number of initial rows that should be skipped; should be positive or this method simply returns
sequence
skip
nodes are skipped; never nullpublic static NodeSequence filter(NodeSequence sequence, NodeSequence.RowFilter filter)
sequence
- the original sequence that is to be limited; may be nullfilter
- the filter to apply to the nodes; if null this method simply returns sequence
public static NodeSequence append(NodeSequence first, NodeSequence second)
first
- the first sequence; may be nullsecond
- the second sequence; may be nullIllegalArgumentException
- if the sequences have different widthspublic static NodeSequence slice(NodeSequence original, QueryResults.Columns columns)
original
- the original node sequence that might have more selectors than specified by the columnscolumns
- the columns defining the selectors that are to be exposedprotected static NodeSequence.Batch slicingBatch(NodeSequence.Batch original, int[] selectorIndexes)
public static NodeSequence merging(NodeSequence first, NodeSequence second, int totalWidth)
first
- the first sequence; may be nullsecond
- the second sequence; may be nulltotalWidth
- the total width of the sequences; should be equal to first.getWidth() + second.getWidth()
public static NodeSequence.Batch batchOf(Collection<CachedNode> nodes, float score, String workspaceName)
used
.nodes
- the collection of nodes to be returned; if null, an empty instance
is returnedscore
- the score to return for all of the nodesworkspaceName
- the name of the workspace in which all of the nodes existpublic static NodeSequence.Batch batchOf(Iterator<CachedNode> nodes, long nodeCount, float score, String workspaceName)
used
.nodes
- the iterator over the nodes to be returned; if null, an empty instance
is returnednodeCount
- the number of nodes in the iterator; must be -1 if not known, 0 if known to be empty, or a positive number
if the number of nodes is knownscore
- the score to return for all of the nodesworkspaceName
- the name of the workspace in which all of the nodes existpublic static NodeSequence.Batch batchOfKeys(Collection<NodeKey> keys, float score, String workspaceName, RepositoryCache repository)
used
.keys
- the iterator over the keys of the nodes to be returned; if null, an empty instance
is
returnedscore
- the score to return for all of the nodesworkspaceName
- the name of the workspace in which all of the nodes existrepository
- the repository cache used to access the workspaces and cached nodes; may be null only if the key sequence
is null or emptypublic static NodeSequence.Batch batchOfKeys(Iterator<NodeKey> keys, long nodeCount, float score, String workspaceName, NodeCache cache)
used
.keys
- the iterator over the keys of the nodes to be returned; if null, an empty instance
is
returnednodeCount
- the number of nodes in the iterator; must be -1 if not known, 0 if known to be empty, or a positive number
if the number of nodes is knownscore
- the score to return for all of the nodesworkspaceName
- the name of the workspace in which all of the nodes existcache
- the workspace cache used to access the cached nodes; may be null only if the key sequence is null or emptypublic static NodeSequence.Batch batchOfKeys(Iterator<NodeKey> keys, long nodeCount, float score, String workspaceName, RepositoryCache repository)
used
.keys
- the iterator over the keys of the nodes to be returned; if null, an empty instance
is
returnednodeCount
- the number of nodes in the iterator; must be -1 if not known, 0 if known to be empty, or a positive number
if the number of nodes is knownscore
- the score to return for all of the nodesworkspaceName
- the name of the workspace in which all of the nodes existrepository
- the repository cache used to access the workspaces and cached nodes; may be null only if the key sequence
is null or emptypublic static NodeSequence.Batch batchOfKeys(Iterator<NodeKey> keys, Iterator<Float> scores, long nodeCount, String workspaceName, RepositoryCache repository)
used
.keys
- the iterator over the keys of the nodes to be returned; if null, an empty instance
is
returnedscores
- the iterator over the scores of the nodes; must return the same number of values as nodes returned by the
keys
iteratornodeCount
- the number of nodes in the iterator; must be -1 if not known, 0 if known to be empty, or a positive number
if the number of nodes is knownworkspaceName
- the name of the workspace in which all of the nodes existrepository
- the repository cache used to access the workspaces and cached nodes; may be null only if the key sequence
is null or emptyprotected static NodeSequence.Batch batchOf(NodeSequence.Batch first, NodeSequence.Batch second, int firstWidth, int secondWidth)
protected static final NodeKey keyFor(CachedNode node)
public static NodeSequence.RowFilter requireBoth(NodeSequence.RowFilter first, NodeSequence.RowFilter second)
public static NodeSequence.RowFilter requireEither(NodeSequence.RowFilter first, NodeSequence.RowFilter second)
public static NodeSequence.Batch batchFilteredWith(NodeSequence.Batch batch, NodeSequence.RowFilter filter)
getRowCount()
is almost always -1 (except when the supplied batch is null or empty, or if
the filter is null.batch
- the batch to be filtered; if null an empty batch is returnedfilter
- the filter to be applied to the rows in the batch; if null an empty batch is returnedpublic static NodeSequence.Batch batchWithCount(NodeSequence.Batch batch)
NodeSequence.Batch.rowCount()
, even if that means returning a new Batch that buffers the
original's rows it into memory.batch
- the original batch; may be nullNodeSequence.Batch.rowCount()
, or the original batch if null or empty or if the original has a
non-negative row countpublic static NodeSequence.Batch copy(NodeSequence.Batch batch)
NodeSequence.Batch.rowCount()
.batch
- the original batch; may be nullNodeSequence.Batch.rowCount()
, or the original batch if null or empty or if the original has a
non-negative row countCopyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.