diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2021-01-10 12:24:16 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2021-01-10 12:24:16 +0100 |
commit | 2f28c5bf5877a119022f6e6251e1ebd6af257b85 (patch) | |
tree | 29cbdbaff8699b5e70290b1b59cd92822d1ccf7a /container-search | |
parent | a0a55270b4b370238ee949eef62c9c69e82fd76b (diff) |
Add new class >_<
Diffstat (limited to 'container-search')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/query/profile/CompoundNameChildCache.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/CompoundNameChildCache.java b/container-search/src/main/java/com/yahoo/search/query/profile/CompoundNameChildCache.java new file mode 100644 index 00000000000..bc23db3871e --- /dev/null +++ b/container-search/src/main/java/com/yahoo/search/query/profile/CompoundNameChildCache.java @@ -0,0 +1,22 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.search.query.profile; + +import com.yahoo.processing.request.CompoundName; + +import java.util.HashMap; +import java.util.Map; + +/** + * Cache for compound names created through {@link CompoundName#append(String)}. + * + * @author jonmv + */ +public final class CompoundNameChildCache { + + private final Map<CompoundName, Map<String, CompoundName>> cache = new HashMap<>(); + + public CompoundName append(CompoundName prefix, String suffix) { + return cache.computeIfAbsent(prefix, __ -> new HashMap<>()).computeIfAbsent(suffix, prefix::append); + } + +} |