use of com.yahoo.document.BucketId in project vespa by vespa-engine.
the class VisitorIteratorTestCase method testRangeDistributionBitInitialDrop.
// Test a drop from 31->11 bits upon iteration start
public void testRangeDistributionBitInitialDrop() throws ParseException {
int db = 31;
BucketIdFactory idFactory = new BucketIdFactory();
ProgressToken p = new ProgressToken();
VisitorIterator iter = VisitorIterator.createFromDocumentSelection("id.group != \"yahoo.com\"", idFactory, db, p);
VisitorIterator.BucketProgress[] bp = new VisitorIterator.BucketProgress[3];
bp[0] = iter.getNext();
bp[1] = iter.getNext();
bp[2] = iter.getNext();
iter.update(bp[2].getSuperbucket(), new BucketId());
iter.update(bp[1].getSuperbucket(), new BucketId());
assertEquals(p.getActiveBucketCount(), 1);
iter.setDistributionBitCount(11);
assertFalse(iter.hasNext());
assertFalse(iter.isDone());
assertEquals(p.getActiveBucketCount(), 1);
// Updating the active bucket allows the merging to take place
iter.update(new BucketId(31, 0), new BucketId());
assertTrue(iter.hasNext());
assertFalse(iter.isDone());
// All pending buckets should have been merged down to just 1 now
// Update: now rather gets reset
assertEquals(p.getPendingBucketCount(), 0);
assertEquals(p.getActiveBucketCount(), 0);
assertEquals(p.getFinishedBucketCount(), 0);
assertEquals(p.getBucketCursor(), 0);
bp[0] = iter.getNext();
assertEquals(bp[0].getSuperbucket(), new BucketId(11, 0));
}
use of com.yahoo.document.BucketId in project vespa by vespa-engine.
the class StoragePolicy method doSelect.
@Override
public void doSelect(RoutingContext context) {
if (context.shouldTrace(1)) {
context.trace(1, "Selecting route");
}
BucketId bucketId = bucketIdCalculator.handleBucketIdCalculation(context);
if (context.hasReply())
return;
String targetSpec = distributorSelectionLogic.getTargetSpec(context, bucketId);
if (context.hasReply())
return;
if (targetSpec != null) {
Route route = new Route(context.getRoute());
route.setHop(0, new Hop().addDirective(new VerbatimDirective(targetSpec)));
context.addChild(route);
} else {
context.setError(ErrorCode.NO_ADDRESS_FOR_SERVICE, "Could not resolve any distributors to send to in cluster " + parameters.clusterName);
}
}
use of com.yahoo.document.BucketId in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testVisitingCompletedFromSufficientFirstPassHits.
@Test
public void testVisitingCompletedFromSufficientFirstPassHits() {
VisitorParameters visitorParameters = createVisitorParameters("id.user==1234");
visitorParameters.setMaxFirstPassHits(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 testVisitingCompletedFromSecondPassHits.
@Test
public void testVisitingCompletedFromSecondPassHits() {
VisitorParameters visitorParameters = createVisitorParameters("id.user==1234");
visitorParameters.setMaxTotalHits(10);
ReplyModifier replyModifier1 = (reply) -> {
VisitorStatistics stats = new VisitorStatistics();
stats.setBucketsVisited(1);
stats.setDocumentsReturned(5);
stats.setSecondPassDocumentsReturned(4);
reply.setVisitorStatistics(stats);
reply.setLastBucket(new BucketId(33, 1234 | (1L << 32)));
};
ReplyModifier replyModifier2 = (reply) -> {
VisitorStatistics stats = new VisitorStatistics();
stats.setBucketsVisited(1);
stats.setSecondPassDocumentsReturned(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 createVisitorToString.
private String createVisitorToString(CreateVisitorMessage msg) {
StringBuilder sb = new StringBuilder();
sb.append("CreateVisitorMessage(buckets=[\n");
for (BucketId id : msg.getBuckets()) {
sb.append(id).append("\n");
}
sb.append("]\n");
if (!"".equals(msg.getDocumentSelection())) {
sb.append("selection='").append(msg.getDocumentSelection()).append("'\n");
}
if (msg.getTimeRemaining() != 5 * 60 * 1000) {
sb.append("time remaining=").append(msg.getTimeRemaining()).append("\n");
}
if (msg.getFromTimestamp() != 0) {
sb.append("from timestamp=").append(msg.getFromTimestamp()).append("\n");
}
if (msg.getToTimestamp() != 0) {
sb.append("to timestamp=").append(msg.getToTimestamp()).append("\n");
}
if (msg.getMaxPendingReplyCount() != 32) {
sb.append("max pending=").append(msg.getMaxPendingReplyCount()).append("\n");
}
if (!"[all]".equals(msg.getFieldSet())) {
sb.append("fieldset=").append(msg.getFieldSet()).append("\n");
}
if (msg.getVisitInconsistentBuckets()) {
sb.append("visit inconsistent=").append(msg.getVisitInconsistentBuckets()).append("\n");
}
if (msg.getVisitRemoves()) {
sb.append("visit removes=").append(msg.getVisitRemoves()).append("\n");
}
if (!msg.getParameters().isEmpty()) {
sb.append("parameters=[\n");
for (Map.Entry<String, byte[]> kv : msg.getParameters().entrySet()) {
sb.append(kv.getKey()).append(" -> ");
sb.append(new String(kv.getValue(), Charset.defaultCharset()));
sb.append("\n");
}
sb.append("]\n");
}
if (msg.getRoute() != null && !"storage".equals(msg.getRoute().toString())) {
sb.append("route=").append(msg.getRoute()).append("\n");
}
if (msg.getVisitorOrdering() != 0) {
sb.append("ordering=").append(msg.getVisitorOrdering()).append("\n");
}
if (msg.getMaxBucketsPerVisitor() != 1) {
sb.append("max buckets per visitor=").append(msg.getMaxBucketsPerVisitor()).append("\n");
}
if (msg.getLoadType() != LoadType.DEFAULT) {
sb.append("load type=").append(msg.getLoadType().getName()).append("\n");
}
if (msg.getPriority() != DocumentProtocol.Priority.NORMAL_3) {
sb.append("priority=").append(msg.getPriority()).append("\n");
}
if (!"DumpVisitor".equals(msg.getLibraryName())) {
sb.append("visitor library=").append(msg.getLibraryName()).append("\n");
}
if (msg.getTrace().getLevel() != 0) {
sb.append("trace level=").append(msg.getTrace().getLevel()).append("\n");
}
sb.append(")");
return sb.toString();
}
Aggregations