use of com.yahoo.document.BucketId in project vespa by vespa-engine.
the class BucketSelectorTestCase method parenthesis_enclosed_expressions_inherit_bucket_selectors_from_children.
@Test
public void parenthesis_enclosed_expressions_inherit_bucket_selectors_from_children() throws Exception {
assertBucketCount("(id == \"userdoc:ns:123:foobar\")", 1);
assertBucket("(id = \"userdoc:ns:123:foobar\")", new BucketId(0xeafff5320000007bL));
assertBucketCount("(id.group = \"yahoo.com\" and (testdoctype1.hstringval == \"Doe\"))", 1);
assertBucket("(id.group = \"yahoo.com\" and (testdoctype1 and (id.namespace == 'foo')))", new BucketId(32, 0x035837189a1acd50L));
}
use of com.yahoo.document.BucketId in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testVisitAll.
@Test
public void testVisitAll() {
MockSender sender = new MockSender();
MockReceiver receiver = new MockReceiver();
sender.setMaxPending(1000);
MockAsyncTaskExecutor executor = new MockAsyncTaskExecutor();
VisitorParameters params = createVisitorParameters("");
MessageBusVisitorSession visitorSession = createVisitorSession(sender, receiver, executor, params);
visitorSession.start();
executor.expectAndProcessTasks(1);
assertEquals(2, sender.getMessageCount());
assertEquals("CreateVisitorMessage(buckets=[\n" + "BucketId(0x0400000000000000)\n" + "BucketId(0x0000000000000000)\n" + "]\n)", replyToCreateVisitor(sender, ProgressToken.FINISHED_BUCKET));
executor.expectAndProcessTasks(1);
// No new visitors yet.
executor.expectNoTasks();
assertEquals("CreateVisitorMessage(buckets=[\n" + "BucketId(0x0400000000000001)\n" + "BucketId(0x0000000000000000)\n" + "]\n)", replyToCreateVisitor(sender, new BucketId(8, 1 | (1 << 8))));
executor.expectAndProcessTasks(1);
// Send new visitor for bucket 1
executor.expectAndProcessTasks(1);
assertEquals("CreateVisitorMessage(buckets=[\n" + "BucketId(0x0400000000000001)\n" + "BucketId(0x2000000000000001)\n" + "]\n)", replyToCreateVisitor(sender, ProgressToken.FINISHED_BUCKET));
// Reply task
executor.expectAndProcessTasks(1);
// Visiting complete
executor.expectNoTasks();
assertTrue(visitorSession.isDone());
}
use of com.yahoo.document.BucketId in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testSendSingleCreateVisitor.
@Test
public void testSendSingleCreateVisitor() {
VisitorParameters params = createVisitorParameters("");
Set<BucketId> bucketsToVisit = new TreeSet<BucketId>();
BucketId bid = new BucketId(16, 1234);
bucketsToVisit.add(bid);
params.setBucketsToVisit(bucketsToVisit);
String expected = "CreateVisitorMessage(buckets=[\n" + bid + "\n" + "BucketId(0x0000000000000000)\n" + "]\n)";
doTestSingleBucketVisit(params, expected);
}
use of com.yahoo.document.BucketId in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testMaxTotalHitsEarlyCompletion.
/**
* Test visitor "prematurely" completing due to max total hits being
* reached when no other visitors are currently pending.
*/
@Test
public void testMaxTotalHitsEarlyCompletion() {
VisitorParameters visitorParameters = createVisitorParameters("id.user==1234");
visitorParameters.setMaxTotalHits(10);
ReplyModifier replyModifier1 = (reply) -> {
VisitorStatistics stats = new VisitorStatistics();
stats.setBucketsVisited(1);
stats.setDocumentsReturned(9);
reply.setVisitorStatistics(stats);
reply.setLastBucket(new BucketId(33, 1234 | (1L << 32)));
};
ReplyModifier replyModifier2 = (reply) -> {
VisitorStatistics stats = new VisitorStatistics();
stats.setBucketsVisited(1);
stats.setDocumentsReturned(1);
reply.setVisitorStatistics(stats);
reply.setLastBucket(new BucketId(34, 1234 | (1L << 33)));
};
doTestEarlyCompletion(visitorParameters, replyModifier1, replyModifier2);
}
use of com.yahoo.document.BucketId in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testIdUserSelection.
/**
* Test that using an id.user=foo selection only tries to visit a single
* superbucket for that user.
*/
@Test
public void testIdUserSelection() {
VisitorParameters params = createVisitorParameters("id.user=1234");
String expected = "CreateVisitorMessage(buckets=[\n" + new BucketId(32, 1234) + "\n" + "BucketId(0x0000000000000000)\n" + "]\n" + "selection='id.user=1234'\n)";
doTestSingleBucketVisit(params, expected);
}
Aggregations