Skip to content

Commit 23b90b2

Browse files
authored
Merge pull request #35803 from vespa-engine/bratseth/totalTargetHits
Bratseth/total target hits
2 parents b1d49e4 + 3b709ad commit 23b90b2

87 files changed

Lines changed: 796 additions & 534 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

container-search/abi-spec.json

Lines changed: 63 additions & 41 deletions
Large diffs are not rendered by default.

container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private void fill(Result result, String summaryClass) {
182182
} else {
183183
if (result.hits().getErrorHit() == null) {
184184
result.hits().addError(ErrorMessage.createTimeout("No time left to get summaries, query timeout was " +
185-
query.getTimeout() + " ms"));
185+
query.getTimeout() + " ms"));
186186
}
187187
}
188188
}
@@ -225,9 +225,9 @@ private Result doSearch(Query query) {
225225
}
226226

227227
private Result perSchemaSearch(String schema, Query query) {
228-
Set<String> restrict = query.getModel().getRestrict();
229-
if (restrict.size() != 1) {
230-
throw new IllegalStateException("perSchemaSearch must always be called with 1 schema, got: " + restrict.size());
228+
if (query.getModel().getRestrict().size() != 1) {
229+
throw new IllegalStateException("perSchemaSearch must always be called with 1 schema, got: " +
230+
query.getModel().getRestrict());
231231
}
232232
int rerankCount = globalPhaseRanker != null ? globalPhaseRanker.getRerankCount(query, schema) : 0;
233233
boolean useGlobalPhase = rerankCount > 0;

container-search/src/main/java/com/yahoo/prelude/fastsearch/IndexedBackend.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
// catch and unwrap into a results with an error in high level methods. -Jon
3333
public class IndexedBackend extends VespaBackend {
3434

35-
/** Used to dispatch directly to search nodes over RPC, replacing the old fnet communication path */
3635
private final Dispatcher dispatcher;
3736

3837
/**
@@ -44,14 +43,14 @@ public class IndexedBackend extends VespaBackend {
4443
* backend.
4544
* @param clusterParams the cluster number, and other cluster backend parameters
4645
*/
47-
public IndexedBackend(ClusterParams clusterParams, Dispatcher dispatcher)
48-
{
46+
public IndexedBackend(ClusterParams clusterParams, Dispatcher dispatcher) {
4947
super(clusterParams);
5048
this.dispatcher = dispatcher;
5149
}
5250

5351
@Override
5452
protected void transformQuery(Query query) {
53+
super.transformQuery(query);
5554
QueryRewrite.rewriteSddocname(query);
5655
}
5756

@@ -68,7 +67,7 @@ public Result doSearch2(String schema, Query query) {
6867
if (dispatcher.allGroupsHaveSize1())
6968
forceSinglePassGrouping(query);
7069
try (SearchInvoker invoker = getSearchInvoker(query)) {
71-
Result result = invoker.search(query);
70+
Result result = invoker.search(query, 1.0);
7271
injectSource(result.hits());
7372

7473
if (query.properties().getBoolean(Ranking.RANKFEATURES, false)) {
@@ -98,7 +97,7 @@ public Result doSearch2(String schema, Query query) {
9897
*
9998
* @param result result containing a partition of the unfilled hits
10099
* @param summaryClass the summary class we want to fill with
101-
**/
100+
*/
102101
@Override
103102
protected void doPartialFill(Result result, String summaryClass) {
104103
if (result.isFilled(summaryClass)) return;

container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackend.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ protected VespaBackend(ClusterParams clusterParams) {
8585
protected abstract void doPartialFill(Result result, String summaryClass);
8686

8787
private boolean hasLocation(Item tree) {
88-
if (tree instanceof GeoLocationItem) {
89-
return true;
90-
}
88+
if (tree instanceof GeoLocationItem) return true;
9189
if (tree instanceof CompositeItem composite) {
9290
for (Item child : composite.items()) {
9391
if (hasLocation(child)) return true;
@@ -118,7 +116,6 @@ public boolean summaryNeedsQuery(Query query) {
118116
if (query.getRanking().getListFeatures()) return true;
119117

120118
// (Don't just add other checks here as there is a return false above)
121-
122119
return false;
123120
}
124121

@@ -128,28 +125,24 @@ public DocumentDatabase getDocumentDatabase(Query query) {
128125
if (query.getModel().getRestrict().size() == 1) {
129126
String docTypeName = (String)query.getModel().getRestrict().toArray()[0];
130127
DocumentDatabase db = documentDbs.get(docTypeName);
131-
if (db != null) {
132-
return db;
133-
}
128+
if (db != null) return db;
134129
}
135130
return defaultDocumentDb;
136131
}
137132

138-
private void resolveDocumentDatabase(Query query) {
139-
DocumentDatabase docDb = getDocumentDatabase(query);
140-
if (docDb != null) {
141-
query.getModel().setDocumentDb(docDb.schema().name());
142-
}
133+
private DocumentDatabase resolveDocumentDatabase(Query query) {
134+
DocumentDatabase documentDb = getDocumentDatabase(query);
135+
if (documentDb != null)
136+
query.getModel().setDocumentDb(documentDb.schema().name());
137+
return documentDb;
143138
}
144139

145140
protected void transformQuery(Query query) { }
146141

147142
public Result search(String schema, Query query) {
148-
// query root should not be null here
149143
Item root = query.getModel().getQueryTree().getRoot();
150-
if (root == null || root instanceof NullItem) {
144+
if (root == null || root instanceof NullItem)
151145
return new Result(query, ErrorMessage.createNullQuery(query.getUri().toString()));
152-
}
153146

154147
if ( ! getDocumentDatabase(query).schema().rankProfiles().containsKey(query.getRanking().getProfile()))
155148
return new Result(query, ErrorMessage.createInvalidQueryParameter(getDocumentDatabase(query).schema() +
@@ -206,7 +199,7 @@ private static List<Result> partitionHits(Result result, String summaryClass) {
206199
return parts;
207200
}
208201

209-
//TODO Add schema here too.
202+
// TODO: Add schema here too.
210203
public void fill(Result result, String summaryClass) {
211204
if (result.isFilled(summaryClass)) return; // TODO: Checked in the superclass - remove
212205

container-search/src/main/java/com/yahoo/prelude/query/AndItem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public String getName() {
2121
}
2222

2323
@Override
24-
SearchProtocol.QueryTreeItem toProtobuf() {
24+
SearchProtocol.QueryTreeItem toProtobuf(SerializationContext context) {
2525
var builder = SearchProtocol.ItemAnd.newBuilder();
2626
for (var child : items()) {
27-
builder.addChildren(child.toProtobuf());
27+
builder.addChildren(child.toProtobuf(context));
2828
}
2929
return SearchProtocol.QueryTreeItem.newBuilder()
3030
.setItemAnd(builder.build())

container-search/src/main/java/com/yahoo/prelude/query/AndSegmentItem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ public void setWeight(int w) {
6060
}
6161

6262
@Override
63-
SearchProtocol.QueryTreeItem toProtobuf() {
63+
SearchProtocol.QueryTreeItem toProtobuf(SerializationContext context) {
6464
// AndSegmentItem should be folded/converted before serialization
6565
var builder = SearchProtocol.ItemAnd.newBuilder();
6666
for (var child : items()) {
67-
builder.addChildren(child.toProtobuf());
67+
builder.addChildren(child.toProtobuf(context));
6868
}
6969
return SearchProtocol.QueryTreeItem.newBuilder()
7070
.setItemAnd(builder.build())

container-search/src/main/java/com/yahoo/prelude/query/BoolItem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public BoolItem(boolean value, String indexName, boolean isFromQuery) {
3434
public String getName() { return "BOOL"; }
3535

3636
@Override
37-
protected void encodeThis(ByteBuffer buffer) {
38-
super.encodeThis(buffer); // takes care of index bytes
37+
protected void encodeThis(ByteBuffer buffer, SerializationContext context) {
38+
super.encodeThis(buffer, context); // takes care of index bytes
3939
putString(stringValue(), buffer);
4040
}
4141

@@ -105,7 +105,7 @@ public boolean equals(Object object) {
105105
public boolean isWords() { return false; }
106106

107107
@Override
108-
SearchProtocol.QueryTreeItem toProtobuf() {
108+
SearchProtocol.QueryTreeItem toProtobuf(SerializationContext context) {
109109
// BoolItem is serialized as a word term
110110
var builder = SearchProtocol.ItemWordTerm.newBuilder();
111111
builder.setProperties(ToProtobuf.buildTermProperties(this, getIndexName()));

container-search/src/main/java/com/yahoo/prelude/query/CompositeIndexedItem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public String getIndexName() {
2828
}
2929

3030
// encode index bytes
31-
protected void encodeThis(ByteBuffer buffer) {
32-
super.encodeThis(buffer);
31+
protected void encodeThis(ByteBuffer buffer, SerializationContext context) {
32+
super.encodeThis(buffer, context);
3333
putString(index, buffer);
3434
}
3535

container-search/src/main/java/com/yahoo/prelude/query/CompositeItem.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,21 @@ public ListIterator<Item> getItemIterator() {
169169
/** Returns a read only list of the immediate children of this */
170170
public List<Item> items() { return Collections.unmodifiableList(subitems); }
171171

172-
public int encode(ByteBuffer buffer) {
173-
encodeThis(buffer);
172+
public int encode(ByteBuffer buffer, SerializationContext context) {
173+
encodeThis(buffer, context);
174174
int itemCount = 1;
175175

176176
for (Iterator<Item> i = getItemIterator(); i.hasNext();) {
177177
Item subitem = i.next();
178178

179-
itemCount += subitem.encode(buffer);
179+
itemCount += subitem.encode(buffer, context);
180180
}
181181
return itemCount;
182182
}
183183

184184
/** Encodes just this item, not its regular subitems, to the given buffer. */
185-
protected void encodeThis(ByteBuffer buffer) {
186-
super.encodeThis(buffer);
185+
protected void encodeThis(ByteBuffer buffer, SerializationContext context) {
186+
super.encodeThis(buffer, context);
187187
IntegerCompressor.putCompressedPositiveNumber(encodingArity(), buffer);
188188
}
189189

container-search/src/main/java/com/yahoo/prelude/query/DotProductItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class DotProductItem extends WeightedSetItem {
2121
public ItemType getItemType() { return ItemType.DOTPRODUCT; }
2222

2323
@Override
24-
SearchProtocol.QueryTreeItem toProtobuf() {
24+
SearchProtocol.QueryTreeItem toProtobuf(SerializationContext context) {
2525
if (hasOnlyLongs()) {
2626
var builder = SearchProtocol.ItemDotProductOfLong.newBuilder();
2727
builder.setProperties(ToProtobuf.buildTermProperties(this, getIndexName()));

0 commit comments

Comments
 (0)