Skip to content

Commit

Permalink
Rename FastBackend => Indexedbackend, and move some tests into the pa…
Browse files Browse the repository at this point in the history
…ckage they test.
  • Loading branch information
baldersheim committed Mar 11, 2024
1 parent d51144a commit 354136d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package com.yahoo.vespa.model.container;

import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.prelude.fastsearch.IndexedBackend;
import com.yahoo.vespa.defaults.Defaults;

import java.nio.file.Path;
Expand Down Expand Up @@ -92,7 +93,7 @@ public static boolean isSearchAndDocprocClass(String className) {
com.yahoo.docproc.SimpleDocumentProcessor.class.getName(),
com.yahoo.language.simple.SimpleLinguistics.class.getName(),
com.yahoo.prelude.cluster.ClusterSearcher.class.getName(),
com.yahoo.prelude.fastsearch.FastBackend.class.getName(),
IndexedBackend.class.getName(),
com.yahoo.prelude.fastsearch.VespaBackend.class.getName(),
com.yahoo.prelude.querytransform.CJKSearcher.class.getName(),
com.yahoo.prelude.querytransform.CollapsePhraseSearcher.class.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ com.yahoo.prelude.searcher.XMLStringSearcher.source string default=""

## Default docsum class the QR server should ask the backend to
## use for representing hints as default.
com.yahoo.prelude.fastsearch.FastBackend.docsum.defaultclass string default=""
com.yahoo.prelude.fastsearch.IndexedBackend.docsum.defaultclass string default=""

com.yahoo.prelude.querytransform.PhrasingSearcher.automatonfile string default=""
com.yahoo.prelude.querytransform.NonPhrasingSearcher.automatonfile string default=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.yahoo.container.handler.VipStatus;
import com.yahoo.prelude.fastsearch.ClusterParams;
import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig;
import com.yahoo.prelude.fastsearch.FastBackend;
import com.yahoo.prelude.fastsearch.IndexedBackend;
import com.yahoo.prelude.fastsearch.SummaryParameters;
import com.yahoo.prelude.fastsearch.VespaBackend;
import com.yahoo.search.Query;
Expand Down Expand Up @@ -93,7 +93,7 @@ public ClusterSearcher(ComponentId id,
maxQueryCacheTimeout = ParameterParser.asMilliSeconds(clusterConfig.maxQueryCacheTimeout(), DEFAULT_MAX_QUERY_CACHE_TIMEOUT);

SummaryParameters docSumParams = new SummaryParameters(qrsConfig
.com().yahoo().prelude().fastsearch().FastBackend().docsum()
.com().yahoo().prelude().fastsearch().IndexedBackend().docsum()
.defaultclass());

String uniqueServerId = UUID.randomUUID().toString();
Expand Down Expand Up @@ -130,20 +130,20 @@ private static ClusterParams makeClusterParams(int searchclusterIndex) {
return new ClusterParams("sc" + searchclusterIndex + ".num" + 0);
}

private static FastBackend searchDispatch(int searchclusterIndex,
String searchClusterName,
String serverId,
SummaryParameters docSumParams,
DocumentdbInfoConfig documentdbInfoConfig,
SchemaInfo schemaInfo,
ComponentRegistry<Dispatcher> dispatchers) {
private static IndexedBackend searchDispatch(int searchclusterIndex,
String searchClusterName,
String serverId,
SummaryParameters docSumParams,
DocumentdbInfoConfig documentdbInfoConfig,
SchemaInfo schemaInfo,
ComponentRegistry<Dispatcher> dispatchers) {
ClusterParams clusterParams = makeClusterParams(searchclusterIndex);
ComponentId dispatcherComponentId = new ComponentId("dispatcher." + searchClusterName);
Dispatcher dispatcher = dispatchers.getComponent(dispatcherComponentId);
if (dispatcher == null)
throw new IllegalArgumentException("Configuration error: No dispatcher " + dispatcherComponentId +
" is configured");
return new FastBackend(serverId, dispatcher, docSumParams, clusterParams, documentdbInfoConfig, schemaInfo);
return new IndexedBackend(serverId, dispatcher, docSumParams, clusterParams, documentdbInfoConfig, schemaInfo);
}

private static StreamingBackend streamingCluster(String serverId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// errors on results and returning them. It could be handy to create a QueryHandlingErrorException
// or similar which could wrap an error message, and then just always throw that and
// catch and unwrap into a results with an error in high level methods. -Jon
public class FastBackend extends VespaBackend {
public class IndexedBackend extends VespaBackend {

/** Used to dispatch directly to search nodes over RPC, replacing the old fnet communication path */
private final Dispatcher dispatcher;
Expand All @@ -48,12 +48,12 @@ public class FastBackend extends VespaBackend {
* @param clusterParams the cluster number, and other cluster backend parameters
* @param documentdbInfoConfig document database parameters
*/
public FastBackend(String serverId,
Dispatcher dispatcher,
SummaryParameters docSumParams,
ClusterParams clusterParams,
DocumentdbInfoConfig documentdbInfoConfig,
SchemaInfo schemaInfo) {
public IndexedBackend(String serverId,
Dispatcher dispatcher,
SummaryParameters docSumParams,
ClusterParams clusterParams,
DocumentdbInfoConfig documentdbInfoConfig,
SchemaInfo schemaInfo) {
init(serverId, docSumParams, clusterParams, documentdbInfoConfig, schemaInfo);
this.dispatcher = dispatcher;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.fastsearch.test;
package com.yahoo.prelude.fastsearch;

import com.yahoo.prelude.fastsearch.ByteField;
import com.yahoo.prelude.fastsearch.DataField;
import com.yahoo.prelude.fastsearch.DocsumDefinition;
import com.yahoo.prelude.fastsearch.DocsumDefinitionSet;
import com.yahoo.prelude.fastsearch.FastHit;
import com.yahoo.prelude.fastsearch.IntegerField;
import com.yahoo.prelude.fastsearch.StringField;
import com.yahoo.document.DocumentId;
import com.yahoo.document.GlobalId;
import com.yahoo.search.schema.DocumentSummary;
import com.yahoo.search.schema.Schema;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.fastsearch.test;
package com.yahoo.prelude.fastsearch;

import com.yahoo.container.QrSearchersConfig;
import com.yahoo.container.handler.VipStatus;
import com.yahoo.container.protect.Error;
import com.yahoo.prelude.fastsearch.ClusterParams;
import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig;
import com.yahoo.prelude.fastsearch.FastBackend;
import com.yahoo.prelude.fastsearch.SummaryParameters;
import com.yahoo.prelude.fastsearch.VespaBackend;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.dispatch.MockDispatcher;
Expand Down Expand Up @@ -38,14 +33,14 @@
*
* @author bratseth
*/
public class FastSearcherTestCase {
public class IndexedBackendTestCase {
private static final String SCHEMA = "test";
private static final String CLUSTER = "test";

@Test
void testNullQuery() {
Logger.getLogger(FastBackend.class.getName()).setLevel(Level.ALL);
FastBackend fastSearcher = new FastBackend("container.0",
Logger.getLogger(IndexedBackend.class.getName()).setLevel(Level.ALL);
IndexedBackend fastSearcher = new IndexedBackend("container.0",
MockDispatcher.create(List.of()),
new SummaryParameters(null),
new ClusterParams("testhittype"),
Expand All @@ -70,7 +65,7 @@ private Result doSearch(VespaBackend searcher, Query query, int offset, int hits

@Test
void testSinglePassGroupingIsForcedWithSingleNodeGroups() {
FastBackend fastSearcher = new FastBackend("container.0",
IndexedBackend fastSearcher = new IndexedBackend("container.0",
MockDispatcher.create(List.of(new Node(CLUSTER, 0, "host0", 0))),
new SummaryParameters(null),
new ClusterParams("testhittype"),
Expand All @@ -93,7 +88,7 @@ void testSinglePassGroupingIsForcedWithSingleNodeGroups() {

@Test
void testRankProfileValidation() {
FastBackend fastSearcher = new FastBackend("container.0",
IndexedBackend fastSearcher = new IndexedBackend("container.0",
MockDispatcher.create(List.of(new Node(CLUSTER, 0, "host0", 0))),
new SummaryParameters(null),
new ClusterParams("testhittype"),
Expand All @@ -112,7 +107,7 @@ void testSummaryNeedsQuery() {
.add(new RankProfile.Builder("default").setHasRankFeatures(false)
.setHasSummaryFeatures(false)
.build());
FastBackend backend = new FastBackend("container.0",
IndexedBackend backend = new IndexedBackend("container.0",
MockDispatcher.create(Collections.singletonList(new Node(CLUSTER, 0, "host0", 0))),
new SummaryParameters(null),
new ClusterParams("testhittype"),
Expand All @@ -132,7 +127,7 @@ void testSummaryNeedsQuery() {
void testSinglePassGroupingIsNotForcedWithSingleNodeGroups() {
MockDispatcher dispatcher = MockDispatcher.create(List.of(new Node(CLUSTER, 0, "host0", 0), new Node(CLUSTER, 2, "host1", 0)));

FastBackend fastSearcher = new FastBackend("container.0",
IndexedBackend fastSearcher = new IndexedBackend("container.0",
dispatcher,
new SummaryParameters(null),
new ClusterParams("testhittype"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.fastsearch.test;
package com.yahoo.prelude.fastsearch;

import com.yahoo.component.chain.Chain;
import com.yahoo.prelude.fastsearch.FastHit;
import com.yahoo.prelude.fastsearch.VespaBackend;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.result.ErrorHit;
import com.yahoo.search.result.ErrorMessage;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -141,10 +137,4 @@ private void doFill(VespaBackend searcher, Result result, String summaryClass) {
searcher.fill(result, summaryClass);
}

private Chain<Searcher> chainedAsSearchChain(Searcher topOfChain) {
List<Searcher> searchers = new ArrayList<>();
searchers.add(topOfChain);
return new Chain<>(searchers);
}

}

0 comments on commit 354136d

Please sign in to comment.