summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-08-24 13:21:47 +0200
committerJon Bratseth <bratseth@oath.com>2018-08-24 13:21:47 +0200
commita745e61162fba144bba003aabbfbab601456ed73 (patch)
tree9aee65bc8e2d76c8e87c73ba4c02647716a0c4f0 /config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java
parent4cfbebbc39f08218596e43fffbea8f9a4cd77538 (diff)
Cleanup rank profile registry
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java33
1 files changed, 16 insertions, 17 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java
index 8b1d6381a22..599eef57b2f 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java
@@ -1,8 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition;
-import com.yahoo.searchdefinition.expressiontransforms.ExpressionTransforms;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -16,7 +14,7 @@ import java.util.Set;
* Having both of these mappings consolidated here make it easier to remove dependencies on these mappings at
* run time, since it is essentially only used when building rank profile config at deployment time.
*
- * TODO: Rank profiles should be stored under its owning Search instance.
+ * Global rank profiles are represented by the Search key null.
*
* @author Ulf Lilleengen
*/
@@ -30,8 +28,8 @@ public class RankProfileRegistry {
public static RankProfileRegistry createRankProfileRegistryWithBuiltinRankProfiles(Search search) {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
- rankProfileRegistry.addRankProfile(new DefaultRankProfile(search, rankProfileRegistry));
- rankProfileRegistry.addRankProfile(new UnrankedRankProfile(search, rankProfileRegistry));
+ rankProfileRegistry.add(new DefaultRankProfile(search, rankProfileRegistry));
+ rankProfileRegistry.add(new UnrankedRankProfile(search, rankProfileRegistry));
return rankProfileRegistry;
}
@@ -40,16 +38,16 @@ public class RankProfileRegistry {
*
* @param rankProfile the rank profile to add
*/
- public void addRankProfile(RankProfile rankProfile) {
+ public void add(RankProfile rankProfile) {
if ( ! rankProfiles.containsKey(rankProfile.getSearch())) {
rankProfiles.put(rankProfile.getSearch(), new LinkedHashMap<>());
}
- checkForDuplicateRankProfile(rankProfile);
+ checkForDuplicate(rankProfile);
rankProfiles.get(rankProfile.getSearch()).put(rankProfile.getName(), rankProfile);
rankProfileToSearch.put(rankProfile, rankProfile.getSearch());
}
- private void checkForDuplicateRankProfile(RankProfile rankProfile) {
+ private void checkForDuplicate(RankProfile rankProfile) {
String rankProfileName = rankProfile.getName();
RankProfile existingRangProfileWithSameName = rankProfiles.get(rankProfile.getSearch()).get(rankProfileName);
if (existingRangProfileWithSameName == null) return;
@@ -63,11 +61,11 @@ public class RankProfileRegistry {
/**
* Returns a named rank profile, null if the search definition doesn't have one with the given name
*
- * @param search The {@link Search} that owns the rank profile.
- * @param name The name of the rank profile
- * @return The RankProfile to return.
+ * @param search the {@link Search} that owns the rank profile.
+ * @param name the name of the rank profile
+ * @return the RankProfile to return.
*/
- public RankProfile getRankProfile(Search search, String name) {
+ public RankProfile get(Search search, String name) {
return rankProfiles.get(search).get(name);
}
@@ -75,16 +73,17 @@ public class RankProfileRegistry {
* Rank profiles that are collected across clusters.
* @return A set of global {@link RankProfile} instances.
*/
- public Set<RankProfile> allRankProfiles() {
+ public Set<RankProfile> all() {
return rankProfileToSearch.keySet();
}
/**
- * Rank profiles that are collected for a given search definition
- * @param search {@link Search} to get rank profiles for.
- * @return A collection of local {@link RankProfile} instances.
+ * Returns the rank profiles of a given search definition.
+ *
+ * @param search {@link Search} to get rank profiles for
+ * @return a collection of {@link RankProfile} instances
*/
- public Collection<RankProfile> localRankProfiles(Search search) {
+ public Collection<RankProfile> rankProfilesOf(Search search) {
Map<String, RankProfile> mapping = rankProfiles.get(search);
if (mapping == null) {
return Collections.emptyList();