Search in sources :

Example 16 with ProgressToken

use of com.yahoo.documentapi.ProgressToken in project vespa by vespa-engine.

the class ContinuationHitTest method createMultiBucketProgress.

/**
 * Returns a ProgressToken whose base 64 representation will be _more_ than 76 bytes (MIME line limit)
 */
private ProgressToken createMultiBucketProgress() {
    ProgressToken token = new ProgressToken(16);
    Set<BucketId> buckets = new TreeSet<>();
    buckets.add(new BucketId(58, 0x123456789abcfeffL));
    buckets.add(new BucketId(58, 0x123456789abcfefaL));
    buckets.add(new BucketId(58, 0x123456789abcfefbL));
    // "Prime" the token.
    VisitorIterator.createFromExplicitBucketSet(buckets, 16, token);
    return token;
}
Also used : TreeSet(java.util.TreeSet) BucketId(com.yahoo.document.BucketId) ProgressToken(com.yahoo.documentapi.ProgressToken)

Example 17 with ProgressToken

use of com.yahoo.documentapi.ProgressToken in project vespa by vespa-engine.

the class ContinuationHitTest method createSingleBucketProgress.

/**
 * Returns a ProgressToken whose base 64 representation will be _less_ than 76 bytes (MIME line limit)
 */
private ProgressToken createSingleBucketProgress() {
    ProgressToken token = new ProgressToken(16);
    // Use explicit bucket set so we can better control the binary representation
    // of the buckets, and thus the values written as base 64.
    Set<BucketId> buckets = new TreeSet<>();
    // This particular bucket ID will contain +/ chars when output as non-URL safe base 64.
    buckets.add(new BucketId(58, 0x123456789abcfeffL));
    // "Prime" the token.
    VisitorIterator.createFromExplicitBucketSet(buckets, 16, token);
    return token;
}
Also used : TreeSet(java.util.TreeSet) BucketId(com.yahoo.document.BucketId) ProgressToken(com.yahoo.documentapi.ProgressToken)

Example 18 with ProgressToken

use of com.yahoo.documentapi.ProgressToken in project vespa by vespa-engine.

the class ContinuationHitTest method decodingAcceptsUrlSafeTokens.

@Test
public void decodingAcceptsUrlSafeTokens() throws Exception {
    final ProgressToken token = ContinuationHit.getToken(SINGLE_BUCKET_URL_SAFE_BASE64);
    // Roundtrip should yield identical results.
    assertEquals(SINGLE_BUCKET_URL_SAFE_BASE64, new ContinuationHit(token).getValue());
}
Also used : ProgressToken(com.yahoo.documentapi.ProgressToken) Test(org.junit.Test)

Example 19 with ProgressToken

use of com.yahoo.documentapi.ProgressToken in project vespa by vespa-engine.

the class VisitorIteratorTestCase method testExplicitDistributionImportNoTruncation.

public void testExplicitDistributionImportNoTruncation() throws ParseException {
    BucketIdFactory idFactory = new BucketIdFactory();
    ProgressToken p = new ProgressToken();
    VisitorIterator iter = VisitorIterator.createFromDocumentSelection("id.user == 1234 or id.user == 6789 or id.user == 8009", idFactory, 20, p);
    assertEquals(20, iter.getDistributionBitCount());
    assertEquals(20, p.getDistributionBitCount());
    assertEquals(20, iter.getBucketSource().getDistributionBitCount());
    iter.update(iter.getNext().getSuperbucket(), ProgressToken.FINISHED_BUCKET);
    // Make sure no truncation is done on import
    String serialized = p.toString();
    ProgressToken p2 = new ProgressToken(serialized);
    BucketIdFactory idFactory2 = new BucketIdFactory();
    VisitorIterator iter2 = VisitorIterator.createFromDocumentSelection("id.user == 1234 or id.user == 6789 or id.user == 8009", idFactory2, 1, p2);
    assertEquals(20, iter2.getDistributionBitCount());
    assertEquals(20, p2.getDistributionBitCount());
    assertEquals(20, iter2.getBucketSource().getDistributionBitCount());
    assertEquals(2, p2.getPendingBucketCount());
    assertEquals(1, p2.getFinishedBucketCount());
    assertEquals(3, p2.getTotalBucketCount());
}
Also used : VisitorIterator(com.yahoo.documentapi.VisitorIterator) BucketIdFactory(com.yahoo.document.BucketIdFactory) ProgressToken(com.yahoo.documentapi.ProgressToken)

Example 20 with ProgressToken

use of com.yahoo.documentapi.ProgressToken in project vespa by vespa-engine.

the class VisitorIteratorTestCase method testExplicitDistributionBitIncrease.

public void testExplicitDistributionBitIncrease() throws ParseException {
    int distBits = 12;
    BucketIdFactory idFactory = new BucketIdFactory();
    ProgressToken p = new ProgressToken();
    VisitorIterator iter = VisitorIterator.createFromDocumentSelection("id.user == 1234 or id.user == 6789 or id.user == 8009", idFactory, distBits, p);
    assertEquals(iter.getDistributionBitCount(), distBits);
    assertEquals(p.getDistributionBitCount(), distBits);
    assertEquals(iter.getBucketSource().getDistributionBitCount(), distBits);
    iter.update(iter.getNext().getSuperbucket(), ProgressToken.FINISHED_BUCKET);
    iter.setDistributionBitCount(16);
    assertEquals(iter.getDistributionBitCount(), 16);
    assertEquals(p.getDistributionBitCount(), 16);
    assertEquals(iter.getBucketSource().getDistributionBitCount(), 16);
    // Changing dist bits for explicit source should change nothing
    assertEquals(p.getPendingBucketCount(), 2);
    assertEquals(p.getFinishedBucketCount(), 1);
    assertEquals(p.getTotalBucketCount(), 3);
}
Also used : VisitorIterator(com.yahoo.documentapi.VisitorIterator) BucketIdFactory(com.yahoo.document.BucketIdFactory) ProgressToken(com.yahoo.documentapi.ProgressToken)

Aggregations

ProgressToken (com.yahoo.documentapi.ProgressToken)35 BucketIdFactory (com.yahoo.document.BucketIdFactory)26 VisitorIterator (com.yahoo.documentapi.VisitorIterator)25 BucketId (com.yahoo.document.BucketId)22 TreeSet (java.util.TreeSet)3 Test (org.junit.Test)3 ParseException (com.yahoo.document.select.parser.ParseException)1 VisitorParameters (com.yahoo.documentapi.VisitorParameters)1 Map (java.util.Map)1 Vector (java.util.Vector)1