summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/IndexFacts.java')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/IndexFacts.java31
1 files changed, 15 insertions, 16 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
index 90194f3ba6a..c9a855c2f34 100644
--- a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
+++ b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
@@ -1,16 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude;
+import com.google.common.collect.ImmutableList;
import com.yahoo.search.Query;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
+import java.util.*;
import static com.yahoo.text.Lowercase.toLowerCase;
@@ -63,6 +57,7 @@ public class IndexFacts {
public IndexFacts() {}
+ @SuppressWarnings({"deprecation"})
public IndexFacts(IndexModel indexModel) {
if (indexModel.getSearchDefinitions() != null) {
this.searchDefinitions = indexModel.getSearchDefinitions();
@@ -90,16 +85,20 @@ public class IndexFacts {
}
private static void addEntry(Map<String, List<String>> result, String key, String value) {
- List<String> values = result.computeIfAbsent(key, k -> new ArrayList<>());
+ List<String> values = result.get(key);
+ if (values == null) {
+ values = new ArrayList<>();
+ result.put(key, values);
+ }
values.add(value);
}
// Assumes that document names are equal to the search definition that contain them.
public List<String> clustersHavingSearchDefinition(String searchDefinitionName) {
- if (clusterByDocument == null) return List.of();
+ if (clusterByDocument == null) return Collections.emptyList();
List<String> clusters = clusterByDocument.get(searchDefinitionName);
- return clusters != null ? clusters : List.of();
+ return clusters != null ? clusters : Collections.<String>emptyList();
}
private boolean isInitialized() {
@@ -169,9 +168,9 @@ public class IndexFacts {
}
private Collection<Index> getIndexes(String documentType) {
- if ( ! isInitialized()) return List.of();
+ if ( ! isInitialized()) return Collections.emptyList();
SearchDefinition sd = searchDefinitions.get(documentType);
- if (sd == null) return List.of();
+ if (sd == null) return Collections.emptyList();
return sd.indices().values();
}
@@ -232,7 +231,7 @@ public class IndexFacts {
}
private Collection<String> emptyCollectionIfNull(Collection<String> collection) {
- return collection == null ? List.of() : collection;
+ return collection == null ? Collections.<String>emptyList() : collection;
}
/**
@@ -319,7 +318,7 @@ public class IndexFacts {
private final List<String> documentTypes;
private Session(Query query) {
- documentTypes = List.copyOf(resolveDocumentTypes(query));
+ documentTypes = ImmutableList.copyOf(resolveDocumentTypes(query));
}
private Session(Collection<String> sources, Collection<String> restrict) {
@@ -348,7 +347,7 @@ public class IndexFacts {
// currently by the flat structure in IndexFacts.
// That can be fixed without changing this API.
public Index getIndex(String indexName, String documentType) {
- return IndexFacts.this.getIndexFromDocumentTypes(indexName, List.of(documentType));
+ return IndexFacts.this.getIndexFromDocumentTypes(indexName, Collections.singletonList(documentType));
}
/** Returns all the indexes of a given search definition */