summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java35
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java18
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileCompiler.java56
-rw-r--r--container-search/src/main/java/com/yahoo/search/searchchain/ExecutionFactory.java11
4 files changed, 87 insertions, 33 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
index 45303a3c646..a79c0d84054 100644
--- a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
+++ b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
@@ -122,23 +122,40 @@ public class SearchHandler extends LoggingRequestHandler {
QueryProfilesConfig queryProfileConfig,
ContainerHttpConfig containerHttpConfig,
ExecutionFactory executionFactory) {
+ this(statistics,
+ metric,
+ executor,
+ accessLog,
+ QueryProfileConfigurer.createFromConfig(queryProfileConfig).compile(),
+ executionFactory,
+ queryProfileConfig.enableGroupingSessionCache(),
+ containerHttpConfig.hostResponseHeaderKey().equals("") ?
+ Optional.empty() : Optional.of( containerHttpConfig.hostResponseHeaderKey()));
+ }
+
+ public SearchHandler(Statistics statistics,
+ Metric metric,
+ Executor executor,
+ AccessLog accessLog,
+ CompiledQueryProfileRegistry queryProfileRegistry,
+ ExecutionFactory executionFactory,
+ boolean enableGroupingSessionCache,
+ Optional<String> hostResponseHeaderKey) {
super(executor, accessLog, metric, true);
log.log(LogLevel.DEBUG, "SearchHandler.init " + System.identityHashCode(this));
- this.enableGroupingSessionCache = queryProfileConfig.enableGroupingSessionCache();
- QueryProfileRegistry queryProfileRegistry = QueryProfileConfigurer.createFromConfig(queryProfileConfig);
- this.queryProfileRegistry = queryProfileRegistry.compile();
+ this.enableGroupingSessionCache = enableGroupingSessionCache;
+ this.queryProfileRegistry = queryProfileRegistry;
this.executionFactory = executionFactory;
this.maxThreads = examineExecutor(executor);
searchConnections = new Value(SEARCH_CONNECTIONS, statistics,
new Value.Parameters().setLogRaw(true).setLogMax(true)
- .setLogMean(true).setLogMin(true)
- .setNameExtension(true)
- .setCallback(new MeanConnections()));
-
- this.hostResponseHeaderKey = containerHttpConfig.hostResponseHeaderKey().equals("") ?
- Optional.empty() : Optional.of( containerHttpConfig.hostResponseHeaderKey());
+ .setLogMean(true).setLogMin(true)
+ .setNameExtension(true)
+ .setCallback(new MeanConnections()));
+
+ this.hostResponseHeaderKey = hostResponseHeaderKey;
}
/** @deprecated use the other constructor */
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java
index 0e6af6113b5..acca2d403be 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java
@@ -330,21 +330,21 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
return node;
}
- final Object get(CompoundName name,DimensionBinding dimensionBinding) {
- return lookup(name,false,dimensionBinding);
+ final Object get(CompoundName name, DimensionBinding dimensionBinding) {
+ return lookup(name, false, dimensionBinding);
}
/**
* Returns the node at the position prescribed by the given name (without doing substitutions) -
* a primitive value, a substitutable string, a query profile, or null if not found.
*/
- public final Object lookup(String name, Map<String,String> context) {
+ public final Object lookup(String name, Map<String, String> context) {
return lookup(new CompoundName(name),true,DimensionBinding.createFrom(getDimensions(),context));
}
/** Sets a value in this or any nested profile using null as context */
public final void set(String name, Object value, QueryProfileRegistry registry) {
- set(name,value,(Map<String,String>)null, registry);
+ set(name, value, (Map<String, String>)null, registry);
}
/**
@@ -357,16 +357,16 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
* @throws IllegalArgumentException if the given name is illegal given the types of this or any nested query profile
* @throws IllegalStateException if this query profile is frozen
*/
- public final void set(CompoundName name,Object value,Map<String,String> context, QueryProfileRegistry registry) {
+ public final void set(CompoundName name, Object value, Map<String,String> context, QueryProfileRegistry registry) {
set(name, value, DimensionBinding.createFrom(getDimensions(), context), registry);
}
- public final void set(String name,Object value,Map<String,String> context, QueryProfileRegistry registry) {
+ public final void set(String name, Object value, Map<String,String> context, QueryProfileRegistry registry) {
set(new CompoundName(name), value, DimensionBinding.createFrom(getDimensions(), context), registry);
}
- public final void set(String name,Object value,String[] dimensionValues, QueryProfileRegistry registry) {
- set(name,value,DimensionValues.createFrom(dimensionValues), registry);
+ public final void set(String name, Object value, String[] dimensionValues, QueryProfileRegistry registry) {
+ set(name, value, DimensionValues.createFrom(dimensionValues), registry);
}
/**
@@ -382,7 +382,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable
* @throws IllegalArgumentException if the given name is illegal given the types of this or any nested query profile
* @throws IllegalStateException if this query profile is frozen
*/
- public final void set(String name,Object value,DimensionValues dimensionValues, QueryProfileRegistry registry) {
+ public final void set(String name,Object value, DimensionValues dimensionValues, QueryProfileRegistry registry) {
set(new CompoundName(name), value, DimensionBinding.createFrom(getDimensions(), dimensionValues), registry);
}
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileCompiler.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileCompiler.java
index a7cfaf84e98..f75d04a1311 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileCompiler.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileCompiler.java
@@ -38,8 +38,7 @@ public class QueryProfileCompiler {
DimensionalMap.Builder<CompoundName, Object> unoverridables = new DimensionalMap.Builder<>();
// Resolve values for each existing variant and combine into a single data structure
- Set<DimensionBindingForPath> variants = new HashSet<>();
- collectVariants(CompoundName.empty, in, DimensionBinding.nullBinding, variants);
+ Set<DimensionBindingForPath> variants = collectVariants(CompoundName.empty, in, DimensionBinding.nullBinding);
variants.add(new DimensionBindingForPath(DimensionBinding.nullBinding, CompoundName.empty)); // if this contains no variants
if (log.isLoggable(Level.FINE))
log.fine("Compiling " + in.toString() + " having " + variants.size() + " variants");
@@ -67,41 +66,68 @@ public class QueryProfileCompiler {
*
* @param profile the profile we are collecting the variants of
* @param currentVariant the variant we must have to arrive at this point in the query profile graph
- * @param allVariants the set of all variants accumulated so far
*/
- private static void collectVariants(CompoundName path, QueryProfile profile, DimensionBinding currentVariant, Set<DimensionBindingForPath> allVariants) {
+ private static Set<DimensionBindingForPath> collectVariants(CompoundName path, QueryProfile profile, DimensionBinding currentVariant) {
+ Set<DimensionBindingForPath> variants = new HashSet<>();
+ variants.addAll(collectVariantsFromValues(path, profile.getContent(), currentVariant));
+ variants.addAll(collectVariantsInThis(path, profile, currentVariant));
+ if (profile instanceof BackedOverridableQueryProfile)
+ variants.addAll(collectVariantsInThis(path, ((BackedOverridableQueryProfile) profile).getBacking(), currentVariant));
+
+ Set<DimensionBindingForPath> parentVariants = new HashSet<>();
for (QueryProfile inheritedProfile : profile.inherited())
- collectVariants(path, inheritedProfile, currentVariant, allVariants);
+ parentVariants = collectVariants(path, inheritedProfile, currentVariant);
+ variants.addAll(parentVariants);
+ variants.addAll(combined(variants, parentVariants)); // parents and children may have different variant dimensions
+ return variants;
+ }
- collectVariantsFromValues(path, profile.getContent(), currentVariant, allVariants);
+ /** Generates a set of all the (legal) combinations of the variants in the given sets */
+ private static Set<DimensionBindingForPath> combined(Set<DimensionBindingForPath> v1s,
+ Set<DimensionBindingForPath> v2s) {
+ Set<DimensionBindingForPath> combinedVariants = new HashSet<>();
+ for (DimensionBindingForPath v1 : v1s) {
+ for (DimensionBindingForPath v2 : v2s) {
+ if ( ! v1.path().equals(v2.path())) continue;
- collectVariantsInThis(path, profile, currentVariant, allVariants);
- if (profile instanceof BackedOverridableQueryProfile)
- collectVariantsInThis(path, ((BackedOverridableQueryProfile) profile).getBacking(), currentVariant, allVariants);
+ DimensionBinding combined = v1.binding().combineWith(v2.binding);
+ if ( combined.isInvalid() ) continue;
+
+ combinedVariants.add(new DimensionBindingForPath(combined, v1.path()));
+ }
+ }
+ return combinedVariants;
}
- private static void collectVariantsInThis(CompoundName path, QueryProfile profile, DimensionBinding currentVariant, Set<DimensionBindingForPath> allVariants) {
+ private static Set<DimensionBindingForPath> collectVariantsInThis(CompoundName path, QueryProfile profile, DimensionBinding currentVariant) {
QueryProfileVariants profileVariants = profile.getVariants();
+ Set<DimensionBindingForPath> variants = new HashSet<>();
if (profileVariants != null) {
for (QueryProfileVariant variant : profile.getVariants().getVariants()) {
DimensionBinding combinedVariant =
DimensionBinding.createFrom(profile.getDimensions(), variant.getDimensionValues()).combineWith(currentVariant);
if (combinedVariant.isInvalid()) continue; // values at this point in the graph are unreachable
- collectVariantsFromValues(path, variant.values(), combinedVariant, allVariants);
+
+ variants.addAll(collectVariantsFromValues(path, variant.values(), combinedVariant));
for (QueryProfile variantInheritedProfile : variant.inherited())
- collectVariants(path, variantInheritedProfile, combinedVariant, allVariants);
+ variants.addAll(collectVariants(path, variantInheritedProfile, combinedVariant));
}
}
+ return variants;
}
- private static void collectVariantsFromValues(CompoundName path, Map<String, Object> values, DimensionBinding currentVariant, Set<DimensionBindingForPath> allVariants) {
+ private static Set<DimensionBindingForPath> collectVariantsFromValues(CompoundName path,
+ Map<String, Object> values,
+ DimensionBinding currentVariant) {
+ Set<DimensionBindingForPath> variants = new HashSet<>();
if ( ! values.isEmpty())
- allVariants.add(new DimensionBindingForPath(currentVariant, path)); // there are actual values for this variant
+ variants.add(new DimensionBindingForPath(currentVariant, path)); // there are actual values for this variant
for (Map.Entry<String, Object> entry : values.entrySet()) {
if (entry.getValue() instanceof QueryProfile)
- collectVariants(path.append(entry.getKey()), (QueryProfile)entry.getValue(), currentVariant, allVariants);
+ variants.addAll(collectVariants(path.append(entry.getKey()), (QueryProfile)entry.getValue(), currentVariant));
}
+ return variants;
}
private static class DimensionBindingForPath {
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 470e74bb974..c619bf69e59 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
@@ -10,6 +10,7 @@ import com.yahoo.component.provider.ComponentRegistry;
import com.yahoo.container.QrSearchersConfig;
import com.yahoo.container.core.ChainsConfig;
import com.yahoo.language.Linguistics;
+import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.prelude.IndexFacts;
import com.yahoo.prelude.IndexModel;
import com.yahoo.prelude.query.parser.SpecialTokenRegistry;
@@ -76,4 +77,14 @@ public class ExecutionFactory extends AbstractComponent {
rendererRegistry.deconstruct();
}
+ public static ExecutionFactory empty() {
+ return new ExecutionFactory(new ChainsConfig.Builder().build(),
+ new IndexInfoConfig.Builder().build(),
+ new QrSearchersConfig.Builder().build(),
+ new ComponentRegistry<>(),
+ new SpecialtokensConfig.Builder().build(),
+ new SimpleLinguistics(),
+ new ComponentRegistry<>());
+ }
+
}