final String workspaceName ) { assert nodeCount >= -1; if (nodes == null) return emptyBatch(workspaceName, 1); return new Batch() { private CachedNode current;
final String workspaceName ) { assert nodeCount >= -1; if (nodes == null) return emptyBatch(workspaceName, 1); return new Batch() { private CachedNode current;
final NodeCache cache ) { assert nodeCount >= -1; if (keys == null) return emptyBatch(workspaceName, 1); return new Batch() { private CachedNode current;
final NodeCache cache ) { assert nodeCount >= -1; if (keys == null) return emptyBatch(workspaceName, 1); return new Batch() { private CachedNode current;
/** * Create a batch of nodes around the supplied iterable container. Note that the supplied iterator is accessed lazily only * when the batch is {@link Batch#nextRow() used}. * * @param nodes the collection of nodes to be returned; if null, an {@link #emptySequence empty instance} is returned * @param score the score to return for all of the nodes * @param workspaceName the name of the workspace in which all of the nodes exist * @return the batch of nodes; never null */ public static Batch batchOf( final Collection<CachedNode> nodes, final float score, final String workspaceName ) { if (nodes == null) return emptyBatch(workspaceName, 1); return batchOf(nodes.iterator(), nodes.size(), score, workspaceName); }
/** * Create a batch of nodes around the supplied iterable container. Note that the supplied iterator is accessed lazily only * when the batch is {@link Batch#nextRow() used}. * * @param nodes the collection of nodes to be returned; if null, an {@link #emptySequence empty instance} is returned * @param score the score to return for all of the nodes * @param workspaceName the name of the workspace in which all of the nodes exist * @return the batch of nodes; never null */ public static Batch batchOf( final Collection<CachedNode> nodes, final float score, final String workspaceName ) { if (nodes == null) return emptyBatch(workspaceName, 1); return batchOf(nodes.iterator(), nodes.size(), score, workspaceName); }
/** * Create a batch of nodes around the supplied iterable container. Note that the supplied iterator is accessed lazily only * when the batch is {@link Batch#nextRow() used}. * * @param keys the iterator over the keys of the nodes to be returned; if null, an {@link #emptySequence empty instance} is * returned * @param score the score to return for all of the nodes * @param workspaceName the name of the workspace in which all of the nodes exist * @param repository the repository cache used to access the workspaces and cached nodes; may be null only if the key sequence * is null or empty * @return the batch of nodes; never null */ public static Batch batchOfKeys( final Collection<NodeKey> keys, final float score, final String workspaceName, final RepositoryCache repository ) { if (keys == null) return emptyBatch(workspaceName, 1); return batchOfKeys(keys.iterator(), keys.size(), score, workspaceName, repository); }
/** * Create a batch of nodes around the supplied iterable container. Note that the supplied iterator is accessed lazily only * when the batch is {@link Batch#nextRow() used}. * * @param keys the iterator over the keys of the nodes to be returned; if null, an {@link #emptySequence empty instance} is * returned * @param score the score to return for all of the nodes * @param workspaceName the name of the workspace in which all of the nodes exist * @param repository the repository cache used to access the workspaces and cached nodes; may be null only if the key sequence * is null or empty * @return the batch of nodes; never null */ public static Batch batchOfKeys( final Collection<NodeKey> keys, final float score, final String workspaceName, final RepositoryCache repository ) { if (keys == null) return emptyBatch(workspaceName, 1); return batchOfKeys(keys.iterator(), keys.size(), score, workspaceName, repository); }
protected Batch batchFrom( final Iterator<BufferedRow> rows, final long maxBatchSize ) { if (remainingRowCount.get() <= 0 || !rows.hasNext()) return null; if (maxBatchSize == 0) return NodeSequence.emptyBatch(workspaceName, this.width); final long rowsInBatch = Math.min(maxBatchSize, remainingRowCount.get()); return new Batch() {
protected Batch batchFrom( final Iterator<BufferedRow> rows, final long maxBatchSize ) { if (remainingRowCount.get() <= 0 || !rows.hasNext()) return null; if (maxBatchSize == 0) return NodeSequence.emptyBatch(workspaceName, this.width); final long rowsInBatch = Math.min(maxBatchSize, remainingRowCount.get()); return new Batch() {
protected Batch batchFrom( final Iterator<BufferedRow> rows, final long maxBatchSize ) { if (remainingRowCount.get() <= 0 || !rows.hasNext()) return null; if (maxBatchSize == 0) return NodeSequence.emptyBatch(workspaceName, this.width); final long rowsInBatch = Math.min(maxBatchSize, remainingRowCount.get()); return new Batch() {
protected Batch batchFrom( final Iterator<BufferedRow> rows, final long maxBatchSize ) { if (remainingRowCount.get() <= 0 || !rows.hasNext()) return null; if (maxBatchSize == 0) return NodeSequence.emptyBatch(workspaceName, this.width); final long rowsInBatch = Math.min(maxBatchSize, remainingRowCount.get()); return new Batch() {
protected Batch batchFrom( final Iterator<BufferedRow> rows, final long maxBatchSize ) { if (rows == null || !rows.hasNext()) return null; if (maxBatchSize == 0 || remainingRowCount.get() <= 0) return NodeSequence.emptyBatch(workspaceName, this.width); final long rowsInBatch = Math.min(maxBatchSize, remainingRowCount.get()); rowsLeftInBatch.set(rowsInBatch);
protected Batch batchFrom( final Iterator<BufferedRow> rows, final long maxBatchSize ) { if (rows == null || !rows.hasNext()) return null; if (maxBatchSize == 0 || remainingRowCount.get() <= 0) return NodeSequence.emptyBatch(workspaceName, this.width); final long rowsInBatch = Math.min(maxBatchSize, remainingRowCount.get()); rowsLeftInBatch.set(rowsInBatch);
final RepositoryCache repository ) { assert nodeCount >= -1; if (keys == null) return emptyBatch(workspaceName, 1); final NodeCache cache = repository.getWorkspaceCache(workspaceName); return new Batch() {
final RepositoryCache repository ) { assert nodeCount >= -1; if (keys == null) return emptyBatch(workspaceName, 1); final NodeCache cache = repository.getWorkspaceCache(workspaceName); return new Batch() {
/** * Create a batch of nodes around the supplied iterator. Note that the supplied iterator is accessed lazily only when the * batch is {@link Batch#nextRow() used}. * * @param keys the iterator over the keys of the nodes to be returned; if null, an {@link #emptySequence empty instance} is * returned * @param nodeCount 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 known * @param score the score to return for all of the nodes * @param workspaceName the name of the workspace in which all of the nodes exist * @param repository the repository cache used to access the workspaces and cached nodes; may be null only if the key sequence * is null or empty * @return the batch of nodes; never null */ public static Batch batchOfKeys( final Iterator<NodeKey> keys, final long nodeCount, final float score, final String workspaceName, final RepositoryCache repository ) { assert nodeCount >= -1; if (keys == null) return emptyBatch(workspaceName, 1); final NodeCache cache = repository.getWorkspaceCache(workspaceName); return batchOfKeys(keys, nodeCount, score, workspaceName, cache); }
/** * Create a batch of nodes around the supplied iterator. Note that the supplied iterator is accessed lazily only when the * batch is {@link Batch#nextRow() used}. * * @param keys the iterator over the keys of the nodes to be returned; if null, an {@link #emptySequence empty instance} is * returned * @param nodeCount 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 known * @param score the score to return for all of the nodes * @param workspaceName the name of the workspace in which all of the nodes exist * @param repository the repository cache used to access the workspaces and cached nodes; may be null only if the key sequence * is null or empty * @return the batch of nodes; never null */ public static Batch batchOfKeys( final Iterator<NodeKey> keys, final long nodeCount, final float score, final String workspaceName, final RepositoryCache repository ) { assert nodeCount >= -1; if (keys == null) return emptyBatch(workspaceName, 1); final NodeCache cache = repository.getWorkspaceCache(workspaceName); return batchOfKeys(keys, nodeCount, score, workspaceName, cache); }
/** * Create a copy of a batch that always has a {@link Batch#rowCount()}. * * @param batch the original batch; may be null * @return the batch that has a true {@link Batch#rowCount()}, or the original batch if null or empty or if the original has a * non-negative row count */ public static Batch copy( Batch batch ) { if (batch == null) return batch; if (batch.isEmpty() || batch.width() < 1) return emptyBatch(batch.getWorkspaceName(), 1); // Otherwise, create a copy ... return batch.width() == 1 ? new SingleWidthBatch(batch) : new MultiWidthBatch(batch); }
/** * Create a copy of a batch that always has a {@link Batch#rowCount()}. * * @param batch the original batch; may be null * @return the batch that has a true {@link Batch#rowCount()}, or the original batch if null or empty or if the original has a * non-negative row count */ public static Batch copy( Batch batch ) { if (batch == null) return batch; if (batch.isEmpty() || batch.width() < 1) return emptyBatch(batch.getWorkspaceName(), 1); // Otherwise, create a copy ... return batch.width() == 1 ? new SingleWidthBatch(batch) : new MultiWidthBatch(batch); }