/** * Create a sequence of nodes that iterates over the supplied node keys. Note that the supplied iterator is accessed lazily as * the resulting sequence's {@link #nextBatch() first 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 cache the cache used to access the cached nodes; may be null only if the key sequence is null or empty * @return the sequence of nodes; never null */ public static NodeSequence withNodeKeys( final Collection<NodeKey> keys, final float score, final String workspaceName, final NodeCache cache ) { if (keys == null || keys.isEmpty()) return emptySequence(1); return withNodeKeys(keys.iterator(), keys.size(), score, workspaceName, cache); }
/** * Create a sequence of nodes that iterates over the supplied node keys. Note that the supplied iterator is accessed lazily as * the resulting sequence's {@link #nextBatch() first 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 sequence of nodes; never null */ public static NodeSequence withNodeKeys( final Collection<NodeKey> keys, final float score, final String workspaceName, final RepositoryCache repository ) { if (keys == null || keys.isEmpty()) return emptySequence(1); return withNodeKeys(keys.iterator(), keys.size(), score, workspaceName, repository); }
/** * Create a sequence of nodes that iterates over the supplied node keys. Note that the supplied iterator is accessed lazily as * the resulting sequence's {@link #nextBatch() first 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 cache the cache used to access the cached nodes; may be null only if the key sequence is null or empty * @return the sequence of nodes; never null */ public static NodeSequence withNodeKeys( final Collection<NodeKey> keys, final float score, final String workspaceName, final NodeCache cache ) { if (keys == null || keys.isEmpty()) return emptySequence(1); return withNodeKeys(keys.iterator(), keys.size(), score, workspaceName, cache); }
/** * Create a sequence of nodes that iterates over the supplied node keys. Note that the supplied iterator is accessed lazily as * the resulting sequence's {@link #nextBatch() first 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 sequence of nodes; never null */ public static NodeSequence withNodeKeys( final Collection<NodeKey> keys, final float score, final String workspaceName, final RepositoryCache repository ) { if (keys == null || keys.isEmpty()) return emptySequence(1); return withNodeKeys(keys.iterator(), keys.size(), score, workspaceName, repository); }
protected NodeSequence allNodes( float score ) { return NodeSequence.withNodeKeys(cache.getAllNodeKeys(), -1, score, workspaceName(), cache); }
/** * Obtain a {@link NodeSequence} that returns the (queryable) descendants of the node at the given path in the workspace, * where each descendant node is assigned the given score. * * @param ancestorPath the path of the ancestor of all descendants; may not be null * @param score the score for the nodes * @return the sequence of nodes; never null */ public NodeSequence descendantNodes( Path ancestorPath, float score ) { String workspaceName = getWorkspaceName(ancestorPath); // Get an iterator over all acceptable nodes in the workspace ... NodeCacheIterator iter = nodes(workspaceName, ancestorPath); if (iter != null) { if (iter.hasNext()) { // Skip the node at our path, which is to be excluded ... NodeKey key = iter.next(); assert ancestorPath.equals(path(workspaceName, key)) : "First node in results does not match the expected path"; } // Finally create and add a batch for this workspace ... return NodeSequence.withNodeKeys(iter, -1, score, workspaceName, repo); } return NodeSequence.emptySequence(1); }
/** * Obtain a {@link NodeSequence} that returns the (queryable) descendants of the node at the given path in the workspace, * where each descendant node is assigned the given score. * * @param ancestorPath the path of the ancestor of all descendants; may not be null * @param score the score for the nodes * @return the sequence of nodes; never null */ public NodeSequence descendantNodes( Path ancestorPath, float score ) { String workspaceName = getWorkspaceName(ancestorPath); // Get an iterator over all acceptable nodes in the workspace ... NodeCacheIterator iter = nodes(workspaceName, ancestorPath); if (iter != null) { if (iter.hasNext()) { // Skip the node at our path, which is to be excluded ... NodeKey key = iter.next(); assert ancestorPath.equals(path(workspaceName, key)) : "First node in results does not match the expected path"; } // Finally create and add a batch for this workspace ... return NodeSequence.withNodeKeys(iter, -1, score, workspaceName, repo); } return NodeSequence.emptySequence(1); }