summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/searchchain
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-04-21 15:56:41 +0200
committerJon Bratseth <bratseth@gmail.com>2022-04-21 15:56:41 +0200
commit4f2994d9301034e943620e106540fa80a6c3f01e (patch)
tree6b0a76afd976bbd314f1ba5c3764af12f88ef724 /container-search/src/main/java/com/yahoo/search/searchchain
parent50c7dfee0a9f32debb34d06191808cbd6ae67e4c (diff)
Resolve rank profile inputs
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/searchchain')
-rw-r--r--container-search/src/main/java/com/yahoo/search/searchchain/Execution.java112
-rw-r--r--container-search/src/main/java/com/yahoo/search/searchchain/ExecutionFactory.java48
2 files changed, 91 insertions, 69 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/searchchain/Execution.java b/container-search/src/main/java/com/yahoo/search/searchchain/Execution.java
index 9374027504e..baf9f35c72b 100644
--- a/container-search/src/main/java/com/yahoo/search/searchchain/Execution.java
+++ b/container-search/src/main/java/com/yahoo/search/searchchain/Execution.java
@@ -16,6 +16,7 @@ import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.cluster.PingableSearcher;
+import com.yahoo.search.config.SchemaInfo;
import com.yahoo.search.rendering.Renderer;
import com.yahoo.search.rendering.RendererRegistry;
import com.yahoo.search.statistics.TimeTracker;
@@ -78,6 +79,8 @@ public class Execution extends com.yahoo.processing.execution.Execution {
private IndexFacts indexFacts = null;
+ private SchemaInfo schemaInfo = SchemaInfo.empty();
+
/** The current set of special tokens */
private SpecialTokenRegistry tokenRegistry = null;
@@ -116,7 +119,7 @@ public class Execution extends com.yahoo.processing.execution.Execution {
* This context is never attached to an execution but is used to carry state into
* another context.
*/
- public Context(SearchChainRegistry searchChainRegistry, IndexFacts indexFacts,
+ public Context(SearchChainRegistry searchChainRegistry, IndexFacts indexFacts, SchemaInfo schemaInfo,
SpecialTokenRegistry tokenRegistry, RendererRegistry rendererRegistry, Linguistics linguistics,
Executor executor) {
owner = null;
@@ -125,50 +128,67 @@ public class Execution extends com.yahoo.processing.execution.Execution {
// obviously, the most complete constructor.
this.searchChainRegistry = searchChainRegistry;
this.indexFacts = indexFacts;
+ this.schemaInfo = Objects.requireNonNull(schemaInfo);
this.tokenRegistry = tokenRegistry;
this.rendererRegistry = rendererRegistry;
this.linguistics = linguistics;
this.executor = Objects.requireNonNull(executor, "The executor cannot be null");
}
+ /** @deprecated pass schemaInfo */
+ @Deprecated
+ public Context(SearchChainRegistry searchChainRegistry, IndexFacts indexFacts,
+ SpecialTokenRegistry tokenRegistry, RendererRegistry rendererRegistry, Linguistics linguistics,
+ Executor executor) {
+ this(searchChainRegistry, indexFacts, SchemaInfo.empty(), tokenRegistry, rendererRegistry, linguistics, Runnable::run);
+ }
+
/** @deprecated pass an executor */
@Deprecated // TODO: Remove on Vespa 8
public Context(SearchChainRegistry searchChainRegistry, IndexFacts indexFacts,
SpecialTokenRegistry tokenRegistry, RendererRegistry rendererRegistry, Linguistics linguistics) {
- this(searchChainRegistry, indexFacts, tokenRegistry, rendererRegistry, linguistics, Runnable::run);
+ this(searchChainRegistry, indexFacts, SchemaInfo.empty(), tokenRegistry, rendererRegistry, linguistics, Runnable::run);
}
/** Creates a Context instance where everything except the given arguments is empty. This is for unit testing.*/
public static Context createContextStub() {
- return createContextStub(null, null, null);
+ return createContextStub(null, null, SchemaInfo.empty(), null);
}
/** Creates a Context instance where everything except the given arguments is empty. This is for unit testing.*/
public static Context createContextStub(SearchChainRegistry searchChainRegistry) {
- return createContextStub(searchChainRegistry, null, null);
+ return createContextStub(searchChainRegistry, null, SchemaInfo.empty(), null);
}
/** Creates a Context instance where everything except the given arguments is empty. This is for unit testing.*/
public static Context createContextStub(IndexFacts indexFacts) {
- return createContextStub(null, indexFacts, null);
+ return createContextStub(null, indexFacts, SchemaInfo.empty(), null);
}
/** Creates a Context instance where everything except the given arguments is empty. This is for unit testing.*/
public static Context createContextStub(SearchChainRegistry searchChainRegistry, IndexFacts indexFacts) {
- return createContextStub(searchChainRegistry, indexFacts, null);
+ return createContextStub(searchChainRegistry, indexFacts, SchemaInfo.empty(), null);
}
/** Creates a Context instance where everything except the given arguments is empty. This is for unit testing.*/
public static Context createContextStub(IndexFacts indexFacts, Linguistics linguistics) {
- return createContextStub(null, indexFacts, linguistics);
+ return createContextStub(null, indexFacts, SchemaInfo.empty(), linguistics);
+ }
+
+ public static Context createContextStub(SearchChainRegistry searchChainRegistry,
+ IndexFacts indexFacts,
+ Linguistics linguistics) {
+ return createContextStub(searchChainRegistry, indexFacts, SchemaInfo.empty(), linguistics);
}
/** Creates a Context instance where everything except the given arguments is empty. This is for unit testing.*/
public static Context createContextStub(SearchChainRegistry searchChainRegistry,
IndexFacts indexFacts,
+ SchemaInfo schemaInfo,
Linguistics linguistics) {
return new Context(searchChainRegistry != null ? searchChainRegistry : new SearchChainRegistry(),
indexFacts != null ? indexFacts : new IndexFacts(),
+ schemaInfo,
null,
new RendererRegistry(Runnable::run),
linguistics != null ? linguistics : new SimpleLinguistics(),
@@ -188,6 +208,7 @@ public class Execution extends com.yahoo.processing.execution.Execution {
breakdown = sourceContext.breakdown;
if (indexFacts == null)
indexFacts = sourceContext.indexFacts;
+ schemaInfo = sourceContext.schemaInfo;
if (tokenRegistry == null)
tokenRegistry = sourceContext.tokenRegistry;
if (searchChainRegistry == null)
@@ -207,6 +228,7 @@ public class Execution extends com.yahoo.processing.execution.Execution {
void fill(Context other) {
searchChainRegistry = other.searchChainRegistry;
indexFacts = other.indexFacts;
+ schemaInfo = other.schemaInfo;
tokenRegistry = other.tokenRegistry;
rendererRegistry = other.rendererRegistry;
detailedDiagnostics = other.detailedDiagnostics;
@@ -219,18 +241,20 @@ public class Execution extends com.yahoo.processing.execution.Execution {
// equals() needs to be cheap, that's yet another reason we can only
// allow immutables and frozen objects in the context
return other.indexFacts == indexFacts
- && other.rendererRegistry == rendererRegistry
- && other.tokenRegistry == tokenRegistry
- && other.searchChainRegistry == searchChainRegistry
- && other.detailedDiagnostics == detailedDiagnostics
- && other.breakdown == breakdown
- && other.linguistics == linguistics
- && other.executor == executor;
+ && other.schemaInfo == schemaInfo
+ && other.rendererRegistry == rendererRegistry
+ && other.tokenRegistry == tokenRegistry
+ && other.searchChainRegistry == searchChainRegistry
+ && other.detailedDiagnostics == detailedDiagnostics
+ && other.breakdown == breakdown
+ && other.linguistics == linguistics
+ && other.executor == executor;
}
@Override
public int hashCode() {
return java.util.Objects.hash(indexFacts,
+ schemaInfo,
rendererRegistry, tokenRegistry, searchChainRegistry,
detailedDiagnostics, breakdown,
linguistics,
@@ -293,28 +317,25 @@ public class Execution extends com.yahoo.processing.execution.Execution {
this.indexFacts = indexFacts;
}
+ /** Returns information about the schemas specified in this application. This is never null. */
+ public SchemaInfo schemaInfo() { return schemaInfo; }
+
/**
* Returns the search chain registry to use with this execution. This is
* a snapshot taken at creation of this execution, use
* Context.shallowCopy() to get a correctly instantiated Context if
* making a custom Context instance.
*/
- public SearchChainRegistry searchChainRegistry() {
- return searchChainRegistry;
- }
+ public SearchChainRegistry searchChainRegistry() { return searchChainRegistry; }
/**
* Returns the template registry to use with this execution. This is
* a snapshot taken at creation of this execution.
*/
- public RendererRegistry rendererRegistry() {
- return rendererRegistry;
- }
+ public RendererRegistry rendererRegistry() { return rendererRegistry; }
/** Returns the current set of special strings for the query tokenizer */
- public SpecialTokenRegistry getTokenRegistry() {
- return tokenRegistry;
- }
+ public SpecialTokenRegistry getTokenRegistry() { return tokenRegistry; }
/**
* Wrapping the incoming special token registry and then setting the
@@ -324,13 +345,9 @@ public class Execution extends com.yahoo.processing.execution.Execution {
*
* @param tokenRegistry a new registry for overriding behavior of following searchers
*/
- public void setTokenRegistry(SpecialTokenRegistry tokenRegistry) {
- this.tokenRegistry = tokenRegistry;
- }
+ public void setTokenRegistry(SpecialTokenRegistry tokenRegistry) { this.tokenRegistry = tokenRegistry; }
- public void setDetailedDiagnostics(boolean breakdown) {
- this.detailedDiagnostics = breakdown;
- }
+ public void setDetailedDiagnostics(boolean breakdown) { this.detailedDiagnostics = breakdown; }
/**
* The container has some internal diagnostics mechanisms which may be
@@ -342,9 +359,7 @@ public class Execution extends com.yahoo.processing.execution.Execution {
* @return whether components exposing different level of diagnostics
* should go for the most detailed level
*/
- public boolean getDetailedDiagnostics() {
- return detailedDiagnostics;
- }
+ public boolean getDetailedDiagnostics() { return detailedDiagnostics; }
/**
* If too many queries time out, the search handler will assume the
@@ -352,27 +367,17 @@ public class Execution extends com.yahoo.processing.execution.Execution {
*
* @return whether the system is assumed to be in a breakdown state
*/
- public boolean getBreakdown() {
- return breakdown;
- }
+ public boolean getBreakdown() { return breakdown; }
- public void setBreakdown(boolean breakdown) {
- this.breakdown = breakdown;
- }
+ public void setBreakdown(boolean breakdown) { this.breakdown = breakdown; }
/**
* Returns the {@link Linguistics} object assigned to this Context. This object provides access to all the
* linguistic-related APIs, and comes pre-configured with the Execution given.
- *
- * @return The current Linguistics.
*/
- public Linguistics getLinguistics() {
- return linguistics;
- }
+ public Linguistics getLinguistics() { return linguistics; }
- public void setLinguistics(Linguistics linguistics) {
- this.linguistics = linguistics;
- }
+ public void setLinguistics(Linguistics linguistics) { this.linguistics = linguistics; }
/**
* Returns the executor that should be used to execute tasks as part of this execution.
@@ -474,15 +479,10 @@ public class Execution extends com.yahoo.processing.execution.Execution {
* to ensure only searchChain or searcher is null (and because it's long and
* cumbersome).
*
- * @param searchChain
- * the search chain to execute, must be null if searcher is set
- * @param context
- * execution context for the search
- * @param searcherIndex
- * index of the first searcher to invoke, see
- * Execution(Execution)
- * @throws IllegalArgumentException
- * if searchChain is null
+ * @param searchChain the search chain to execute, must be null if searcher is set
+ * @param context execution context for the search
+ * @param searcherIndex index of the first searcher to invoke, see Execution(Execution)
+ * @throws IllegalArgumentException if searchChain is null
*/
@SuppressWarnings("unchecked")
private Execution(Chain<? extends Processor> searchChain, Context context, int searcherIndex) {
@@ -493,7 +493,7 @@ public class Execution extends com.yahoo.processing.execution.Execution {
super(searchChain, searcherIndex, context.createChildTrace(), context.createChildEnvironment());
this.context.fill(context);
contextCache = new Context[searchChain.components().size()];
- entryIndex=searcherIndex;
+ entryIndex = searcherIndex;
timer = new TimeTracker(searchChain, searcherIndex);
}
diff --git a/container-search/src/main/java/com/yahoo/search/searchchain/ExecutionFactory.java b/container-search/src/main/java/com/yahoo/search/searchchain/ExecutionFactory.java
index 28c8ed8f3cf..06814a4c436 100644
--- a/container-search/src/main/java/com/yahoo/search/searchchain/ExecutionFactory.java
+++ b/container-search/src/main/java/com/yahoo/search/searchchain/ExecutionFactory.java
@@ -16,9 +16,11 @@ import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.prelude.IndexFacts;
import com.yahoo.prelude.IndexModel;
import com.yahoo.language.process.SpecialTokenRegistry;
+import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig;
import com.yahoo.processing.rendering.Renderer;
import com.yahoo.search.Searcher;
import com.yahoo.search.config.IndexInfoConfig;
+import com.yahoo.search.config.SchemaInfo;
import com.yahoo.search.rendering.RendererRegistry;
import com.yahoo.vespa.configdefinition.SpecialtokensConfig;
@@ -39,24 +41,17 @@ public class ExecutionFactory extends AbstractComponent {
private final SearchChainRegistry searchChainRegistry;
private final IndexFacts indexFacts;
+ private final SchemaInfo schemaInfo;
private final SpecialTokenRegistry specialTokens;
private final Linguistics linguistics;
private final ThreadPoolExecutor renderingExecutor;
private final RendererRegistry rendererRegistry;
private final Executor executor;
- private static ThreadPoolExecutor createRenderingExecutor() {
- int threadCount = Runtime.getRuntime().availableProcessors();
- ThreadPoolExecutor executor = new ThreadPoolExecutor(threadCount, threadCount, 1L, TimeUnit.SECONDS,
- new LinkedBlockingQueue<>(),
- ThreadFactoryFactory.getThreadFactory("common-rendering"));
- executor.prestartAllCoreThreads();
- return executor;
- }
-
@Inject
public ExecutionFactory(ChainsConfig chainsConfig,
IndexInfoConfig indexInfo,
+ DocumentdbInfoConfig documentdbInfo,
QrSearchersConfig clusters,
ComponentRegistry<Searcher> searchers,
SpecialtokensConfig specialTokens,
@@ -65,6 +60,7 @@ public class ExecutionFactory extends AbstractComponent {
Executor executor) {
this.searchChainRegistry = createSearchChainRegistry(searchers, chainsConfig);
this.indexFacts = new IndexFacts(new IndexModel(indexInfo, clusters)).freeze();
+ this.schemaInfo = new SchemaInfo(indexInfo, documentdbInfo, clusters);
this.specialTokens = new SpecialTokenRegistry(specialTokens);
this.linguistics = linguistics;
this.renderingExecutor = createRenderingExecutor();
@@ -72,6 +68,19 @@ public class ExecutionFactory extends AbstractComponent {
this.executor = executor != null ? executor : Executors.newSingleThreadExecutor();
}
+ /** @deprecated pass documentDbInfo */
+ @Deprecated
+ public ExecutionFactory(ChainsConfig chainsConfig,
+ IndexInfoConfig indexInfo,
+ QrSearchersConfig clusters,
+ ComponentRegistry<Searcher> searchers,
+ SpecialtokensConfig specialTokens,
+ Linguistics linguistics,
+ ComponentRegistry<Renderer> renderers,
+ Executor executor) {
+ this(chainsConfig, indexInfo, new DocumentdbInfoConfig.Builder().build(), clusters, searchers, specialTokens, linguistics, renderers, executor);
+ }
+
/** @deprecated pass the container threadpool */
@Deprecated // TODO: Remove on Vespa 8
public ExecutionFactory(ChainsConfig chainsConfig,
@@ -81,10 +90,11 @@ public class ExecutionFactory extends AbstractComponent {
SpecialtokensConfig specialTokens,
Linguistics linguistics,
ComponentRegistry<Renderer> renderers) {
- this(chainsConfig, indexInfo, clusters, searchers, specialTokens, linguistics, renderers, null);
+ this(chainsConfig, indexInfo, new DocumentdbInfoConfig.Builder().build(), clusters, searchers, specialTokens, linguistics, renderers, null);
}
- private SearchChainRegistry createSearchChainRegistry(ComponentRegistry<Searcher> searchers, ChainsConfig chainsConfig) {
+ private SearchChainRegistry createSearchChainRegistry(ComponentRegistry<Searcher> searchers,
+ ChainsConfig chainsConfig) {
SearchChainRegistry searchChainRegistry = new SearchChainRegistry(searchers);
ChainsModel chainsModel = ChainsModelBuilder.buildFromConfig(chainsConfig);
ChainsConfigurer.prepareChainRegistry(searchChainRegistry, chainsModel, searchers);
@@ -98,7 +108,7 @@ public class ExecutionFactory extends AbstractComponent {
*/
public Execution newExecution(Chain<? extends Searcher> searchChain) {
return new Execution(searchChain,
- new Execution.Context(searchChainRegistry, indexFacts, specialTokens, rendererRegistry, linguistics, executor));
+ new Execution.Context(searchChainRegistry, indexFacts, schemaInfo, specialTokens, rendererRegistry, linguistics, executor));
}
/**
@@ -107,7 +117,7 @@ public class ExecutionFactory extends AbstractComponent {
*/
public Execution newExecution(String searchChainId) {
return new Execution(searchChainRegistry().getChain(searchChainId),
- new Execution.Context(searchChainRegistry, indexFacts, specialTokens, rendererRegistry, linguistics, executor));
+ new Execution.Context(searchChainRegistry, indexFacts, schemaInfo, specialTokens, rendererRegistry, linguistics, executor));
}
/** Returns the search chain registry used by this */
@@ -116,6 +126,8 @@ public class ExecutionFactory extends AbstractComponent {
/** Returns the renderers known to this */
public RendererRegistry rendererRegistry() { return rendererRegistry; }
+ public SchemaInfo schemaInfo() { return schemaInfo; }
+
@Override
public void deconstruct() {
rendererRegistry.deconstruct();
@@ -132,6 +144,7 @@ public class ExecutionFactory extends AbstractComponent {
public static ExecutionFactory empty() {
return new ExecutionFactory(new ChainsConfig.Builder().build(),
new IndexInfoConfig.Builder().build(),
+ new DocumentdbInfoConfig.Builder().build(),
new QrSearchersConfig.Builder().build(),
new ComponentRegistry<>(),
new SpecialtokensConfig.Builder().build(),
@@ -140,4 +153,13 @@ public class ExecutionFactory extends AbstractComponent {
null);
}
+ private static ThreadPoolExecutor createRenderingExecutor() {
+ int threadCount = Runtime.getRuntime().availableProcessors();
+ ThreadPoolExecutor executor = new ThreadPoolExecutor(threadCount, threadCount, 1L, TimeUnit.SECONDS,
+ new LinkedBlockingQueue<>(),
+ ThreadFactoryFactory.getThreadFactory("common-rendering"));
+ executor.prestartAllCoreThreads();
+ return executor;
+ }
+
}