diff options
Diffstat (limited to 'container-search')
16 files changed, 58 insertions, 75 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/UnicodePropertyDump.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/UnicodePropertyDump.java index d5f72a3387e..0dc9a33e3f1 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/parser/UnicodePropertyDump.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/UnicodePropertyDump.java @@ -31,7 +31,7 @@ class UnicodePropertyDump { end = Integer.valueOf(arg[1]).intValue(); } if (arg.length > 2) { - debug = new Boolean(arg[2]).booleanValue(); + debug = Boolean.valueOf(arg[2]).booleanValue(); } dumpProperties(start, end, debug, System.out); } diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java index f9cfe843eb3..df944f5b102 100644 --- a/container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java @@ -54,7 +54,7 @@ public class QuotingSearcher extends Searcher { QrQuotetableConfig.Character character = (QrQuotetableConfig.Character)i.next(); if (character.ordinal() > 256) { newIsEmpty = false; - newQuoteMap.put(new Character((char)character.ordinal()), character.quoting()); + newQuoteMap.put((char)character.ordinal(), character.quoting()); newUseMap = true; if (minOrd == 0 || character.ordinal() < minOrd) minOrd = character.ordinal(); @@ -77,7 +77,7 @@ public class QuotingSearcher extends Searcher { public String get(char c) { if (isEmpty) return null; - int ord = (int)c; + int ord = c; if (ord < 256) { return lowerTable[ord]; } @@ -85,7 +85,7 @@ public class QuotingSearcher extends Searcher { if ((!useMap) || ord < lowerUncachedBound || ord > upperUncachedBound) return null; else - return quoteMap.get(new Character(c)); + return quoteMap.get(c); } } public boolean isEmpty() { diff --git a/container-search/src/main/java/com/yahoo/search/query/parser/ParserFactory.java b/container-search/src/main/java/com/yahoo/search/query/parser/ParserFactory.java index a57c0f98b45..4269f5e1c57 100644 --- a/container-search/src/main/java/com/yahoo/search/query/parser/ParserFactory.java +++ b/container-search/src/main/java/com/yahoo/search/query/parser/ParserFactory.java @@ -25,6 +25,7 @@ public final class ParserFactory { * @param environment the environment settings to attach to the Parser * @return the created Parser */ + @SuppressWarnings("deprecation") public static Parser newInstance(Query.Type type, ParserEnvironment environment) { switch (type) { case ALL: diff --git a/container-search/src/main/java/com/yahoo/search/query/textserialize/item/CompositeConverter.java b/container-search/src/main/java/com/yahoo/search/query/textserialize/item/CompositeConverter.java index 332f03c896c..0a935530a62 100644 --- a/container-search/src/main/java/com/yahoo/search/query/textserialize/item/CompositeConverter.java +++ b/container-search/src/main/java/com/yahoo/search/query/textserialize/item/CompositeConverter.java @@ -6,6 +6,7 @@ import com.yahoo.prelude.query.Item; import com.yahoo.search.query.textserialize.serializer.DispatchForm; import com.yahoo.search.query.textserialize.serializer.ItemIdMapper; +import java.lang.reflect.InvocationTargetException; import java.util.ListIterator; /** @@ -42,8 +43,8 @@ public class CompositeConverter<T extends CompositeItem> implements ItemFormConv private T newInstance() { try { - return itemClass.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { + return itemClass.getDeclaredConstructor().newInstance(); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } diff --git a/container-search/src/main/java/com/yahoo/search/result/FieldComparator.java b/container-search/src/main/java/com/yahoo/search/result/FieldComparator.java index 211d04a0eac..ccb9c728561 100644 --- a/container-search/src/main/java/com/yahoo/search/result/FieldComparator.java +++ b/container-search/src/main/java/com/yahoo/search/result/FieldComparator.java @@ -86,9 +86,9 @@ public class FieldComparator extends ChainableComparator { case BOOL: return (sub.asBool() ? Boolean.TRUE : Boolean.FALSE); case LONG: - return new Long(sub.asLong()); + return sub.asLong(); case DOUBLE: - return new Double(sub.asDouble()); + return sub.asDouble(); case STRING: return sub.asString(); } diff --git a/container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java b/container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java index ea4a07508b6..a270d935a97 100644 --- a/container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java +++ b/container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java @@ -1375,8 +1375,9 @@ final class ProgramParser { case yqlplusParser.STRING: return StringUnescaper.unquote(text); case yqlplusParser.TRUE: + return Boolean.valueOf(true); case yqlplusParser.FALSE: - return new Boolean(text); + return Boolean.valueOf(false); case yqlplusParser.LONG_INT: return Long.parseLong(text.substring(0, text.length()-1)); default: diff --git a/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java index 6970093fc9d..5b6a4b68930 100644 --- a/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.prelude.cluster; +import com.google.common.collect.ImmutableList; import com.yahoo.cloud.config.ClusterInfoConfig; import com.yahoo.component.ComponentId; import com.yahoo.component.provider.ComponentRegistry; @@ -28,6 +29,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -69,15 +71,14 @@ public class ClusterSearcherTestCase { clusters.put("cluster1", Arrays.asList("type1", "type2", "type3")); clusters.put("cluster2", Arrays.asList("type4", "type5")); clusters.put("type1", Arrays.asList("type6")); - Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>(); - searchDefs.put("type1", new SearchDefinition("type1")); - searchDefs.put("type2", new SearchDefinition("type2")); - searchDefs.put("type3", new SearchDefinition("type3")); - searchDefs.put("type4", new SearchDefinition("type4")); - searchDefs.put("type5", new SearchDefinition("type5")); - searchDefs.put("type6", new SearchDefinition("type6")); - SearchDefinition union = new SearchDefinition("union"); - return new IndexFacts(new IndexModel(clusters, searchDefs, union)); + Collection<SearchDefinition> searchDefs = ImmutableList.of( + new SearchDefinition("type1"), + new SearchDefinition("type2"), + new SearchDefinition("type3"), + new SearchDefinition("type4"), + new SearchDefinition("type5"), + new SearchDefinition("type6")); + return new IndexFacts(new IndexModel(clusters, searchDefs)); } private Set<String> resolve(ClusterSearcher searcher, String query) { diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java index 9850c80754f..12e756a07ee 100644 --- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.prelude.querytransform.test; +import com.google.common.collect.ImmutableList; import com.yahoo.prelude.Index; import com.yahoo.prelude.IndexFacts; import com.yahoo.prelude.IndexModel; @@ -11,10 +12,7 @@ import com.yahoo.search.searchchain.Execution; import com.yahoo.search.test.QueryTestCase; import org.junit.Test; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import static org.junit.Assert.assertEquals; @@ -87,15 +85,13 @@ public class LiteralBoostSearcherTestCase { Map<String, List<String>> clusters = new LinkedHashMap<>(); clusters.put("cluster1", Arrays.asList("type1", "type2", "type3")); clusters.put("cluster2", Arrays.asList("type4", "type5")); - Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>(); - searchDefs.put("type1", createSearchDefinitionWithFields("type1", true)); - searchDefs.put("type2", createSearchDefinitionWithFields("type2", false)); - searchDefs.put("type3", new SearchDefinition("type3")); - searchDefs.put("type3", new SearchDefinition("type3")); - searchDefs.put("type4", new SearchDefinition("type4")); - searchDefs.put("type5", new SearchDefinition("type5")); - SearchDefinition union = new SearchDefinition("union"); - return new IndexFacts(new IndexModel(clusters, searchDefs, union)); + Collection<SearchDefinition> searchDefs = ImmutableList.of( + createSearchDefinitionWithFields("type1", true), + createSearchDefinitionWithFields("type2", false), + new SearchDefinition("type3"), + new SearchDefinition("type4"), + new SearchDefinition("type5")); + return new IndexFacts(new IndexModel(clusters, searchDefs)); } private SearchDefinition createSearchDefinitionWithFields(String name, boolean literalBoost) { diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java index 77f7f057eea..bf1ab6fc397 100644 --- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java @@ -4,6 +4,7 @@ package com.yahoo.prelude.querytransform.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import com.google.common.collect.ImmutableList; import com.yahoo.language.Linguistics; import com.yahoo.language.simple.SimpleLinguistics; import com.yahoo.prelude.Index; @@ -24,6 +25,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -129,15 +131,13 @@ public class NormalizingSearcherTestCase { Map<String, List<String>> clusters = new LinkedHashMap<>(); clusters.put("cluster1", Arrays.asList("type1", "type2", "type3")); clusters.put("cluster2", Arrays.asList("type4", "type5")); - Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>(); - searchDefs.put("type1", createSearchDefinitionWithFields("type1", true)); - searchDefs.put("type2", createSearchDefinitionWithFields("type2", false)); - searchDefs.put("type3", new SearchDefinition("type3")); - searchDefs.put("type3", new SearchDefinition("type3")); - searchDefs.put("type4", new SearchDefinition("type4")); - searchDefs.put("type5", new SearchDefinition("type5")); - SearchDefinition union = new SearchDefinition("union"); - return new IndexFacts(new IndexModel(clusters, searchDefs, union)); + Collection<SearchDefinition> searchDefs = ImmutableList.of( + createSearchDefinitionWithFields("type1", true), + createSearchDefinitionWithFields("type2", false), + new SearchDefinition("type3"), + new SearchDefinition("type4"), + new SearchDefinition("type5")); + return new IndexFacts(new IndexModel(clusters, searchDefs)); } private SearchDefinition createSearchDefinitionWithFields(String name, boolean normalize) { diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java index 24af91cb5c0..909d641225d 100644 --- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java @@ -2,9 +2,10 @@ package com.yahoo.prelude.searcher.test; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; +import com.google.common.collect.ImmutableList; import com.yahoo.component.ComponentId; import com.yahoo.component.chain.Chain; import com.yahoo.container.QrSearchersConfig; @@ -23,6 +24,7 @@ import com.yahoo.prelude.searcher.JuniperSearcher; import com.yahoo.search.searchchain.Execution; import org.junit.Test; +import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -83,11 +85,8 @@ public class JuniperSearcherTestCase { private Execution createExecution(Chain<Searcher> chain) { Map<String, List<String>> clusters = new LinkedHashMap<>(); - Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>(); - searchDefs.put("one", createSearchDefinitionOne()); - searchDefs.put("two", createSearchDefinitionTwo()); - SearchDefinition union = new SearchDefinition("union"); - IndexModel indexModel = new IndexModel(clusters, searchDefs, union); + Collection<SearchDefinition> searchDefs = ImmutableList.of(createSearchDefinitionOne(), createSearchDefinitionTwo()); + IndexModel indexModel = new IndexModel(clusters, searchDefs); return new Execution(chain, Execution.Context.createContextStub(new IndexFacts(indexModel))); } @@ -110,8 +109,7 @@ public class JuniperSearcherTestCase { } private SearchDefinition createSearchDefinitionTwo() { - SearchDefinition two = new SearchDefinition("two"); - return two; + return new SearchDefinition("two"); } @Test @@ -140,7 +138,7 @@ public class JuniperSearcherTestCase { @Test public void testBoldingEquals() { - assertFalse(new Query("?query=12").equals(new Query("?query=12&bolding=false"))); + assertNotEquals(new Query("?query=12"), new Query("?query=12&bolding=false")); } @Test diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java index 197f1d65172..1b9ca1cd29b 100644 --- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java @@ -51,15 +51,11 @@ public class ValidatePredicateSearcherTestCase { Query query = new Query(); query.getModel().getQueryTree().setRoot(queryTree.getRoot()); - TreeMap<String, List<String>> masterClusters = new TreeMap<>(); - masterClusters.put("cluster", Arrays.asList("document")); SearchDefinition searchDefinition = new SearchDefinition("document"); Index index = new Index("predicate_field"); index.addCommand(command); searchDefinition.addIndex(index); - Map<String, SearchDefinition> searchDefinitionMap = new HashMap<>(); - searchDefinitionMap.put("document", searchDefinition); - IndexFacts indexFacts = new IndexFacts(new IndexModel(masterClusters, searchDefinitionMap, searchDefinition)); + IndexFacts indexFacts = new IndexFacts(new IndexModel(searchDefinition)); Execution.Context context = new Execution.Context(null, indexFacts, null, new RendererRegistry(MoreExecutors.directExecutor()), new SimpleLinguistics()); return new Execution(searcher, context).search(query); } diff --git a/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java b/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java index ab07baf438a..43f42685021 100644 --- a/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java @@ -20,10 +20,11 @@ import java.util.Set; import java.util.TreeMap; import static com.yahoo.search.federation.sourceref.test.SearchChainResolverTestCase.emptySourceToProviderMap; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; -import static org.junit.matchers.JUnitMatchers.hasItems; /** @@ -45,9 +46,9 @@ public class SourceRefResolverTestCase { private static SourceRefResolver createSourceRefResolver() { SearchChainResolver.Builder builder = new SearchChainResolver.Builder(); builder.addSearchChain(ComponentId.fromString(cluster1), new FederationOptions().setUseByDefault(true), - Collections.<String>emptyList()); + Collections.emptyList()); builder.addSearchChain(ComponentId.fromString(cluster2), new FederationOptions().setUseByDefault(true), - Collections.<String>emptyList()); + Collections.emptyList()); return new SourceRefResolver(builder.build()); } @@ -57,7 +58,7 @@ public class SourceRefResolverTestCase { masterClusters.put(cluster1, Arrays.asList("document1", "document2")); masterClusters.put(cluster2, Arrays.asList("document1")); masterClusters.put(cluster3, Arrays.asList("document3")); - indexFacts = new IndexFacts(new IndexModel(masterClusters, null, null)); + indexFacts = new IndexFacts(new IndexModel(masterClusters, Collections.emptyList())); } @Test @@ -69,7 +70,7 @@ public class SourceRefResolverTestCase { public void lookup_search_chain() throws Exception { Set<SearchChainInvocationSpec> searchChains = resolve(cluster1); assertThat(searchChains.size(), is(1)); - assertThat(searchChainIds(searchChains), hasItems(cluster1)); + assertThat(searchChainIds(searchChains), hasItem(cluster1)); } @Test diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java index b1abdacf88f..9ec717e5584 100644 --- a/container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java @@ -43,7 +43,7 @@ public class RawBufferTestCase { @Test public void requireThatToStringWorks() { assertToString(Arrays.asList("a".getBytes()[0], "b".getBytes()[0]), "{97,98}"); - assertToString(Arrays.asList(new Byte((byte)2), new Byte((byte)6)), "{2,6}"); + assertToString(Arrays.asList((byte)2, (byte)6), "{2,6}"); } public void assertToString(List<Byte> data, String expected) { diff --git a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java index a83a0e84bbf..c4d49c11f5e 100644 --- a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java @@ -1369,11 +1369,7 @@ public class JsonRendererTestCase { } private Execution createExecution(Chain<Searcher> chain) { - Map<String, List<String>> clusters = new LinkedHashMap<>(); - Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>(); - searchDefs.put("one", createSearchDefinitionOne()); - SearchDefinition union = new SearchDefinition("union"); - IndexModel indexModel = new IndexModel(clusters, searchDefs, union); + IndexModel indexModel = new IndexModel(createSearchDefinitionOne()); return new Execution(chain, Execution.Context.createContextStub(new IndexFacts(indexModel))); } diff --git a/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java index 184a8c1aa43..6396981f12d 100644 --- a/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java @@ -206,11 +206,7 @@ public class XMLRendererTestCase { } private Execution createExecution(Chain<Searcher> chain) { - Map<String, List<String>> clusters = new LinkedHashMap<>(); - Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>(); - searchDefs.put("one", createSearchDefinitionOne()); - SearchDefinition union = new SearchDefinition("union"); - IndexModel indexModel = new IndexModel(clusters, searchDefs, union); + IndexModel indexModel = new IndexModel(createSearchDefinitionOne()); return new Execution(chain, Execution.Context.createContextStub(new IndexFacts(indexModel))); } diff --git a/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java index 871d9285071..0cbf3a6f92c 100644 --- a/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java @@ -209,12 +209,8 @@ public class ValidateNearestNeighborTestCase { Query query = new Query(); query.getModel().getQueryTree().setRoot(queryTree.getRoot()); query.getRanking().getProperties().put("qvector", qTensor); - TreeMap<String, List<String>> masterClusters = new TreeMap<>(); - masterClusters.put("cluster", Arrays.asList("document")); SearchDefinition searchDefinition = new SearchDefinition("document"); - Map<String, SearchDefinition> searchDefinitionMap = new HashMap<>(); - searchDefinitionMap.put("document", searchDefinition); - IndexFacts indexFacts = new IndexFacts(new IndexModel(masterClusters, searchDefinitionMap, searchDefinition)); + IndexFacts indexFacts = new IndexFacts(new IndexModel(searchDefinition)); Execution.Context context = new Execution.Context(null, indexFacts, null, new RendererRegistry(MoreExecutors.directExecutor()), new SimpleLinguistics()); return new Execution(searcher, context).search(query); } |