Search in sources :

Example 21 with BucketId

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));
}
Also used : BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 22 with BucketId

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());
}
Also used : MessageBusVisitorSession(com.yahoo.documentapi.messagebus.MessageBusVisitorSession) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 23 with BucketId

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);
}
Also used : BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 24 with BucketId

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);
}
Also used : java.util(java.util) CyclicBarrier(java.util.concurrent.CyclicBarrier) com.yahoo.documentapi(com.yahoo.documentapi) com.yahoo.messagebus(com.yahoo.messagebus) DocumentId(com.yahoo.document.DocumentId) ParseException(com.yahoo.document.select.parser.ParseException) com.yahoo.documentapi.messagebus.protocol(com.yahoo.documentapi.messagebus.protocol) Test(org.junit.Test) Callable(java.util.concurrent.Callable) MessageBusVisitorSession(com.yahoo.documentapi.messagebus.MessageBusVisitorSession) Result(com.yahoo.messagebus.Result) Error(com.yahoo.messagebus.Error) RoutingTable(com.yahoo.messagebus.routing.RoutingTable) TimeUnit(java.util.concurrent.TimeUnit) Route(com.yahoo.messagebus.routing.Route) RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Charset(java.nio.charset.Charset) VisitorStatistics(com.yahoo.vdslib.VisitorStatistics) LoadType(com.yahoo.documentapi.messagebus.loadtypes.LoadType) Assert(org.junit.Assert) RouteSpec(com.yahoo.messagebus.routing.RouteSpec) BucketId(com.yahoo.document.BucketId) Assert.assertEquals(org.junit.Assert.assertEquals) VisitorStatistics(com.yahoo.vdslib.VisitorStatistics) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 25 with BucketId

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);
}
Also used : BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Aggregations

BucketId (com.yahoo.document.BucketId)67 BucketIdFactory (com.yahoo.document.BucketIdFactory)25 Test (org.junit.Test)24 ProgressToken (com.yahoo.documentapi.ProgressToken)22 VisitorIterator (com.yahoo.documentapi.VisitorIterator)19 DocumentId (com.yahoo.document.DocumentId)10 ClusterState (com.yahoo.vdslib.state.ClusterState)6 GetBucketListReply (com.yahoo.documentapi.messagebus.protocol.GetBucketListReply)5 Error (com.yahoo.messagebus.Error)5 TreeSet (java.util.TreeSet)5 MessageBusVisitorSession (com.yahoo.documentapi.messagebus.MessageBusVisitorSession)4 ParseException (com.yahoo.document.select.parser.ParseException)3 com.yahoo.documentapi (com.yahoo.documentapi)3 LoadType (com.yahoo.documentapi.messagebus.loadtypes.LoadType)3 com.yahoo.documentapi.messagebus.protocol (com.yahoo.documentapi.messagebus.protocol)3 com.yahoo.messagebus (com.yahoo.messagebus)3 Result (com.yahoo.messagebus.Result)3 Route (com.yahoo.messagebus.routing.Route)3 RouteSpec (com.yahoo.messagebus.routing.RouteSpec)3 RoutingTable (com.yahoo.messagebus.routing.RoutingTable)3