aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/query/profile/compiled
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2021-01-08 12:06:23 +0100
committerJon Marius Venstad <venstad@gmail.com>2021-01-08 12:06:23 +0100
commit37a54bb3c5ab364b3dea8f8c20aeb9c7380c4834 (patch)
treee74ba53c60e70defd282827c645beb5ae835b53f /container-search/src/main/java/com/yahoo/search/query/profile/compiled
parent22f2fda9aaea0e132e46b01f62fbd85c87a2a07c (diff)
Generate all matching collections in one pass through the Trie
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query/profile/compiled')
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/compiled/DimensionalMap.java11
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/compiled/DimensionalValue.java14
2 files changed, 8 insertions, 17 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/DimensionalMap.java b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/DimensionalMap.java
index b6bd6dc5a6a..6dc5f61c1f6 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/DimensionalMap.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/DimensionalMap.java
@@ -46,14 +46,9 @@ public class DimensionalMap<VALUE> {
private final Map<CompoundName, DimensionalValue.Builder<VALUE>> entries = new HashMap<>();
- // TODO: DimensionBinding -> Binding?
- public void put(CompoundName key, DimensionBinding binding, VALUE value) {
- DimensionalValue.Builder<VALUE> entry = entries.get(key);
- if (entry == null) {
- entry = new DimensionalValue.Builder<>();
- entries.put(key, entry);
- }
- entry.add(value, binding);
+ public void put(CompoundName key, Binding binding, VALUE value) {
+ entries.computeIfAbsent(key, __ -> new DimensionalValue.Builder<>())
+ .add(value, binding);
}
public DimensionalMap<VALUE> build() {
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/DimensionalValue.java b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/DimensionalValue.java
index fb62cfca7d3..afe07b09d41 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/DimensionalValue.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/DimensionalValue.java
@@ -76,15 +76,11 @@ public class DimensionalValue<VALUE> {
return null;
}
- public void add(VALUE value, DimensionBinding variantBinding) {
+ public void add(VALUE value, Binding variantBinding) {
// Note: We know we can index by the value because its possible types are constrained
// to what query profiles allow: String, primitives and query profiles (wrapped as a ValueWithSource)
- Value.Builder<VALUE> variant = buildableVariants.get(value);
- if (variant == null) {
- variant = new Value.Builder<>(value);
- buildableVariants.put(value, variant);
- }
- variant.addVariant(variantBinding, value);
+ buildableVariants.computeIfAbsent(value, Value.Builder::new)
+ .addVariant(variantBinding, value);
}
public DimensionalValue<VALUE> build(Map<CompoundName, DimensionalValue.Builder<VALUE>> entries) {
@@ -156,8 +152,8 @@ public class DimensionalValue<VALUE> {
/** Add a binding this holds for */
@SuppressWarnings("unchecked")
- public void addVariant(DimensionBinding binding, VALUE newValue) {
- variants.add(Binding.createFrom(binding));
+ public void addVariant(Binding binding, VALUE newValue) {
+ variants.add(binding);
// We're combining values for efficiency, so remove incorrect provenance info
if (value instanceof ValueWithSource) {