/** * 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 sequence of nodes that iterates over the supplied nodes. Note that the supplied iterator is accessed lazily as the * resulting sequence's {@link #nextBatch() first batch} is {@link Batch#nextRow() used}. * * @param nodes the iterator over the node keys 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 * @return the sequence of nodes; never null */ public static NodeSequence withNodes( final Iterator<CachedNode> nodes, final long nodeCount, final float score, final String workspaceName ) { assert nodeCount >= -1; if (nodes == null) return emptySequence(1); return withBatch(batchOf(nodes, nodeCount, score, workspaceName)); }
/** * Create a sequence of nodes that iterates over the supplied nodes. Note that the supplied iterator is accessed lazily as the * resulting sequence's {@link #nextBatch() first batch} is {@link Batch#nextRow() used}. * * @param nodes the iterator over the node keys 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 * @return the sequence of nodes; never null */ public static NodeSequence withNodes( final Iterator<CachedNode> nodes, final long nodeCount, final float score, final String workspaceName ) { assert nodeCount >= -1; if (nodes == null) return emptySequence(1); return withBatch(batchOf(nodes, nodeCount, score, workspaceName)); }