Search in sources :

Example 16 with BucketIdFactory

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

the class BucketSelectorTestCase method assertBucketCount.

public void assertBucketCount(String expr, int count) throws Exception {
    BucketIdFactory factory = new BucketIdFactory();
    BucketSelector selector = new BucketSelector(factory);
    Set<BucketId> buckets = selector.getBucketList(expr);
    assertEquals(count, buckets == null ? 0 : buckets.size());
}
Also used : BucketId(com.yahoo.document.BucketId) BucketIdFactory(com.yahoo.document.BucketIdFactory)

Example 17 with BucketIdFactory

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

the class BucketSelectorTestCase method assertBucket.

public void assertBucket(String expr, BucketId bucket) throws Exception {
    BucketIdFactory factory = new BucketIdFactory();
    BucketSelector selector = new BucketSelector(factory);
    Set<BucketId> buckets = selector.getBucketList(expr);
    assertEquals(1, buckets == null ? 0 : buckets.size());
    assertEquals(bucket, buckets.toArray()[0]);
}
Also used : BucketId(com.yahoo.document.BucketId) BucketIdFactory(com.yahoo.document.BucketIdFactory)

Example 18 with BucketIdFactory

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

the class BucketSelectorTestCase method assertBuckets.

public void assertBuckets(String expr, Set<BucketId> expected) throws Exception {
    BucketIdFactory factory = new BucketIdFactory();
    BucketSelector selector = new BucketSelector(factory);
    Set<BucketId> actual = new TreeSet<BucketId>(selector.getBucketList(expr));
    assertEquals(expected, actual);
}
Also used : TreeSet(java.util.TreeSet) BucketId(com.yahoo.document.BucketId) BucketIdFactory(com.yahoo.document.BucketIdFactory)

Example 19 with BucketIdFactory

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

the class BucketIdFactoryTestCase method testNormalUsage.

public void testNormalUsage() {
    BucketIdFactory factory = new BucketIdFactory();
    assertEquals(BucketId.COUNT_BITS, factory.getCountBitCount());
    assertEquals(64, factory.getLocationBitCount() + factory.getGidBitCount() + BucketId.COUNT_BITS);
}
Also used : BucketIdFactory(com.yahoo.document.BucketIdFactory)

Example 20 with BucketIdFactory

use of com.yahoo.document.BucketIdFactory 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)

Aggregations

BucketIdFactory (com.yahoo.document.BucketIdFactory)35 ProgressToken (com.yahoo.documentapi.ProgressToken)26 BucketId (com.yahoo.document.BucketId)25 VisitorIterator (com.yahoo.documentapi.VisitorIterator)25 DocumentId (com.yahoo.document.DocumentId)4 TreeSet (java.util.TreeSet)2 Map (java.util.Map)1 Vector (java.util.Vector)1