Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -231,12 +232,20 @@ int position() {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.getClass().getSimpleName()).append("[");
sb.append("maxPageSize = ").append(maxPageSize);
sb.append("shards = ").append(sortedUnion(processedShards, sliceQueue.remainingShardsIdentifiers()));
sb.append(", maxPageSize = ").append(maxPageSize);
describe(sb);
sb.append("]");
return sb.toString();
}

private static Set<String> sortedUnion(Collection<String> a, Collection<String> b) {
var result = new TreeSet<String>();
result.addAll(a);
result.addAll(b);
return result;
}

protected abstract void describe(StringBuilder sb);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Queue;
Expand Down Expand Up @@ -45,8 +46,8 @@ public int totalSlices() {
return totalSlices;
}

public Iterable<LuceneSlice> getSlices() {
return slices;
public Collection<String> remainingShardsIdentifiers() {
return slices.stream().map(slice -> slice.shardContext().shardIdentifier()).toList();
}

public static LuceneSliceQueue create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
* Source operator that builds Pages out of the output of a TopFieldCollector (aka TopN)
*/
public final class LuceneTopNSourceOperator extends LuceneOperator {

public static class Factory extends LuceneOperator.Factory {
private final int maxPageSize;
private final List<SortBuilder<?>> sorts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private LuceneCountOperator.Factory simple(DataPartitioning dataPartitioning, in

@Override
protected Matcher<String> expectedToStringOfSimple() {
return matchesRegex("LuceneCountOperator\\[maxPageSize = \\d+, remainingDocs=100]");
return matchesRegex("LuceneCountOperator\\[shards = \\[test], maxPageSize = \\d+, remainingDocs=100]");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private void testMax(Supplier<DriverContext> contexts, int size, int limit) {

@Override
protected final Matcher<String> expectedToStringOfSimple() {
return matchesRegex("LuceneMinMaxOperator\\[maxPageSize = \\d+, remainingDocs=100]");
return matchesRegex("LuceneMinMaxOperator\\[shards = \\[test\\], maxPageSize = \\d+, remainingDocs=100]");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private void testMin(Supplier<DriverContext> contexts, int size, int limit) {

@Override
protected final Matcher<String> expectedToStringOfSimple() {
return matchesRegex("LuceneMinMaxOperator\\[maxPageSize = \\d+, remainingDocs=100]");
return matchesRegex("LuceneMinMaxOperator\\[shards = \\[test], maxPageSize = \\d+, remainingDocs=100]");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private LuceneSourceOperator.Factory simple(DataPartitioning dataPartitioning, i

@Override
protected Matcher<String> expectedToStringOfSimple() {
return matchesRegex("LuceneSourceOperator\\[maxPageSize = \\d+, remainingDocs = \\d+]");
return matchesRegex("LuceneSourceOperator\\[shards = \\[test], maxPageSize = \\d+, remainingDocs = \\d+]");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ public Optional<SortAndFormats> buildSort(List<SortBuilder<?>> sorts) {

@Override
protected Matcher<String> expectedToStringOfSimple() {
return matchesRegex("LuceneTopNSourceOperator\\[maxPageSize = \\d+, limit = 100, scoreMode = COMPLETE, sorts = \\[\\{.+}]]");
return matchesRegex(
"LuceneTopNSourceOperator\\[shards = \\[test], maxPageSize = \\d+, limit = 100, scoreMode = COMPLETE, sorts = \\[\\{.+}]]"
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ public Optional<SortAndFormats> buildSort(List<SortBuilder<?>> sorts) {
@Override
protected Matcher<String> expectedToStringOfSimple() {
var s = scoring ? "COMPLETE" : "TOP_DOCS";
return matchesRegex("LuceneTopNSourceOperator\\[maxPageSize = \\d+, limit = 100, scoreMode = " + s + ", sorts = \\[\\{.+}]]");
return matchesRegex(
"LuceneTopNSourceOperator\\[shards = \\[test], maxPageSize = \\d+, limit = 100, scoreMode = " + s + ", sorts = \\[\\{.+}]]"
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void testTaskContents() throws Exception {
String taskDescription = status.taskDescription();
for (OperatorStatus o : status.activeOperators()) {
logger.info("status {}", o);
if (o.operator().startsWith("LuceneSourceOperator[maxPageSize = " + pageSize())) {
if (o.operator().startsWith("LuceneSourceOperator[")) {
assertThat(taskDescription, equalTo("data"));
LuceneSourceOperator.Status oStatus = (LuceneSourceOperator.Status) o.status();
assertThat(oStatus.processedSlices(), lessThanOrEqualTo(oStatus.totalSlices()));
Expand Down