Search in sources :

Example 1 with BucketSelector

use of com.yahoo.document.select.BucketSelector in project vespa by vespa-engine.

the class VisitorIterator method createFromDocumentSelection.

/**
 * Create a new <code>VisitorIterator</code> instance based on the given document
 * selection string.
 *
 * @param documentSelection Document selection string used to create the
 * <code>VisitorIterator</code> instance. Depending on the characteristics of the
 * selection, the iterator may iterate over only a small subset of the buckets or
 * every bucket in the system. Both cases will be handled efficiently.
 * @param idFactory {@link BucketId} factory specifying the number of distribution bits
 * to use et al.
 * @param progress A unique {@link ProgressToken} instance which is used for maintaining the state
 * of the iterator. Can <em>not</em> be shared with other iterator instances at the same time.
 * If <code>progress</code> contains work done in an earlier iteration run, the iterator will pick
 * up from where it left off
 * @return A new <code>VisitorIterator</code> instance
 * @throws ParseException if <code>documentSelection</code> fails to properly parse
 */
public static VisitorIterator createFromDocumentSelection(String documentSelection, BucketIdFactory idFactory, int distributionBitCount, ProgressToken progress) throws ParseException {
    BucketSelector bucketSel = new BucketSelector(idFactory);
    Set<BucketId> rawBuckets = bucketSel.getBucketList(documentSelection);
    BucketSource src;
    // bit-based range source
    if (rawBuckets == null) {
        // Range source
        src = new DistributionRangeBucketSource(distributionBitCount, progress);
    } else {
        // Explicit source
        src = new ExplicitBucketSource(rawBuckets, distributionBitCount, progress);
    }
    return new VisitorIterator(progress, src);
}
Also used : BucketSelector(com.yahoo.document.select.BucketSelector) BucketId(com.yahoo.document.BucketId)

Aggregations

BucketId (com.yahoo.document.BucketId)1 BucketSelector (com.yahoo.document.select.BucketSelector)1