From 77ab955c266375ec90551857e5fbd8af894f50c6 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 24 Sep 2019 19:35:35 +0200 Subject: Nonfunctional changes only --- .../prelude/fastsearch/SortDataHitSorter.java | 2 + .../com/yahoo/search/grouping/result/Group.java | 2 +- .../com/yahoo/search/grouping/result/HitList.java | 9 ++-- .../yahoo/search/grouping/result/HitRenderer.java | 3 +- .../yahoo/search/grouping/vespa/HitConverter.java | 4 +- .../yahoo/search/grouping/vespa/ResultBuilder.java | 13 +++--- .../java/com/yahoo/search/result/HitOrderer.java | 4 +- .../main/java/com/yahoo/search/yql/YqlParser.java | 2 +- .../search/grouping/result/GroupListTestCase.java | 1 + .../searchlib/aggregation/AggregationResult.java | 14 +++--- .../com/yahoo/searchlib/aggregation/FS4Hit.java | 5 ++- .../com/yahoo/searchlib/aggregation/Group.java | 52 +++++++++------------- .../java/com/yahoo/searchlib/aggregation/Hit.java | 3 +- .../aggregation/HitsAggregationResult.java | 10 ++--- .../searchlib/aggregation/GroupingTestCase.java | 1 + .../java/com/yahoo/vespa/objects/Identifiable.java | 2 +- .../java/com/yahoo/vespa/objects/Selectable.java | 11 ++--- 17 files changed, 70 insertions(+), 68 deletions(-) diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/SortDataHitSorter.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/SortDataHitSorter.java index ee64632d40a..93a21476f35 100644 --- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/SortDataHitSorter.java +++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/SortDataHitSorter.java @@ -10,6 +10,7 @@ import java.util.Comparator; import java.util.List; public class SortDataHitSorter { + public static void sort(HitGroup hitGroup, List hits) { var sorting = hitGroup.getQuery().getRanking().getSorting(); var fallbackOrderer = hitGroup.getOrderer(); @@ -61,4 +62,5 @@ public class SortDataHitSorter { return fallback.compare(left, right); } } + } diff --git a/container-search/src/main/java/com/yahoo/search/grouping/result/Group.java b/container-search/src/main/java/com/yahoo/search/grouping/result/Group.java index 2a1e3199d7d..30bf0ff4bb0 100644 --- a/container-search/src/main/java/com/yahoo/search/grouping/result/Group.java +++ b/container-search/src/main/java/com/yahoo/search/grouping/result/Group.java @@ -14,7 +14,6 @@ import com.yahoo.search.result.Relevance; */ public class Group extends HitGroup { - private static final long serialVersionUID = 2122928012157537800L; private final GroupId groupId; /** @@ -80,4 +79,5 @@ public class Group extends HitGroup { } return null; } + } diff --git a/container-search/src/main/java/com/yahoo/search/grouping/result/HitList.java b/container-search/src/main/java/com/yahoo/search/grouping/result/HitList.java index 03e0f7e6d59..653fc4cb978 100644 --- a/container-search/src/main/java/com/yahoo/search/grouping/result/HitList.java +++ b/container-search/src/main/java/com/yahoo/search/grouping/result/HitList.java @@ -6,20 +6,21 @@ import com.yahoo.search.grouping.GroupingRequest; import com.yahoo.search.result.Hit; /** - *

This class represents a labeled hit list in the grouping result model. It is contained in {@link Group}, and + * This class represents a labeled hit list in the grouping result model. It is contained in {@link Group}, and * contains one or more {@link Hit hits} itself, making this the parent of leaf nodes in the hierarchy of grouping - * results. Use the {@link GroupingRequest#getResultGroup(Result)} to retrieve grouping results.

+ * results. Use the {@link GroupingRequest#getResultGroup(Result)} to retrieve grouping results. * * @author Simon Thoresen Hult */ public class HitList extends AbstractList { /** - *

Constructs a new instance of this class.

+ * Constructs a new instance of this class. * - * @param label The label to assign to this. + * @param label the label to assign to this */ public HitList(String label) { super("hitlist", label); } + } diff --git a/container-search/src/main/java/com/yahoo/search/grouping/result/HitRenderer.java b/container-search/src/main/java/com/yahoo/search/grouping/result/HitRenderer.java index 3907f87a276..da115807fc2 100644 --- a/container-search/src/main/java/com/yahoo/search/grouping/result/HitRenderer.java +++ b/container-search/src/main/java/com/yahoo/search/grouping/result/HitRenderer.java @@ -11,7 +11,7 @@ import java.util.Arrays; import java.util.Map; /** - * This is a helper class for rendering grouping results. + * A helper for rendering grouping results. * * @author Simon Thoresen Hult */ @@ -94,4 +94,5 @@ public abstract class HitRenderer { private static void renderContinuation(String id, Continuation continuation, XMLWriter writer) { writer.openTag(TAG_CONTINUATION).attribute(TAG_CONTINUATION_ID, id).content(continuation, false).closeTag(); } + } diff --git a/container-search/src/main/java/com/yahoo/search/grouping/vespa/HitConverter.java b/container-search/src/main/java/com/yahoo/search/grouping/vespa/HitConverter.java index e8f4d566028..5ea0e3a0838 100644 --- a/container-search/src/main/java/com/yahoo/search/grouping/vespa/HitConverter.java +++ b/container-search/src/main/java/com/yahoo/search/grouping/vespa/HitConverter.java @@ -44,7 +44,8 @@ class HitConverter implements ResultBuilder.HitConverter { } private Hit convertFs4Hit(String summaryClass, FS4Hit groupHit) { - FastHit hit = new FastHit(groupHit.getGlobalId().getRawId(), new Relevance(groupHit.getRank()), + FastHit hit = new FastHit(groupHit.getGlobalId().getRawId(), + new Relevance(groupHit.getRank()), groupHit.getPath(), groupHit.getDistributionKey()); hit.setFillable(); hit.setSearcherSpecificMetaData(searcher, summaryClass); @@ -72,4 +73,5 @@ class HitConverter implements ResultBuilder.HitConverter { } return ret; } + } diff --git a/container-search/src/main/java/com/yahoo/search/grouping/vespa/ResultBuilder.java b/container-search/src/main/java/com/yahoo/search/grouping/vespa/ResultBuilder.java index 2402be27b9c..f45617d1cd7 100644 --- a/container-search/src/main/java/com/yahoo/search/grouping/vespa/ResultBuilder.java +++ b/container-search/src/main/java/com/yahoo/search/grouping/vespa/ResultBuilder.java @@ -285,6 +285,7 @@ class ResultBuilder { page.putContinuations(hitList.continuations()); return hitList; } + } private class GroupListBuilder { @@ -341,6 +342,7 @@ class ResultBuilder { } return ret; } + } private class PageInfo { @@ -381,16 +383,17 @@ class ResultBuilder { } } } + } /** - * Defines a helper interface to convert Vespa style grouping hits into corresponding instances of {@link Hit}. It - * is an interface to simplify testing. - * - * @author Simon Thoresen Hult + * Defines a helper interface to convert Vespa style grouping hits into corresponding instances of {@link Hit}. + * It is an interface to simplify testing. */ public interface HitConverter { - public com.yahoo.search.result.Hit toSearchHit(String summaryClass, com.yahoo.searchlib.aggregation.Hit hit); + com.yahoo.search.result.Hit toSearchHit(String summaryClass, com.yahoo.searchlib.aggregation.Hit hit); + } + } diff --git a/container-search/src/main/java/com/yahoo/search/result/HitOrderer.java b/container-search/src/main/java/com/yahoo/search/result/HitOrderer.java index 331a9ab5852..848666d628b 100644 --- a/container-search/src/main/java/com/yahoo/search/result/HitOrderer.java +++ b/container-search/src/main/java/com/yahoo/search/result/HitOrderer.java @@ -9,15 +9,13 @@ import java.util.List; * * @author bratseth */ - public abstract class HitOrderer { /** Orders the given list of hits */ public abstract void order(List hits); /** - * Returns the Comparator that this HitOrderer uses internally to - * sort hits. Returns null if no Comparator is used. + * Returns the Comparator that this HitOrderer uses internally to sort hits. Returns null if no Comparator is used. *

* This default implementation returns null. * diff --git a/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java b/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java index b660d90072b..dfc603846fd 100644 --- a/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java +++ b/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java @@ -1039,7 +1039,7 @@ public class YqlParser implements Parser { assertHasOperator(ast, ExpressionOperator.CONTAINS); String field = getIndex(ast.getArgument(0)); if (userQuery != null && indexFactsSession.getIndex(field).isAttribute()) { - userQuery.trace("Field '" + field + "' is an attribute, 'contains' will only match exactly", 1); + userQuery.trace("Field '" + field + "' is an attribute, 'contains' will only match exactly", 2); } return instantiateLeafItem(field, ast.> getArgument(1)); } diff --git a/container-search/src/test/java/com/yahoo/search/grouping/result/GroupListTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/result/GroupListTestCase.java index b8cc25930e2..78694bdd1e7 100644 --- a/container-search/src/test/java/com/yahoo/search/grouping/result/GroupListTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/grouping/result/GroupListTestCase.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.search.grouping.result; +import com.yahoo.search.Query; import com.yahoo.search.grouping.Continuation; import org.junit.Test; diff --git a/searchlib/src/main/java/com/yahoo/searchlib/aggregation/AggregationResult.java b/searchlib/src/main/java/com/yahoo/searchlib/aggregation/AggregationResult.java index 264a9d4d4e9..c3ad7cbe879 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/aggregation/AggregationResult.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/aggregation/AggregationResult.java @@ -8,7 +8,7 @@ import com.yahoo.vespa.objects.ObjectVisitor; import com.yahoo.vespa.objects.Serializer; /** - *

This is the aggregation super-class from which all types of aggregation inherits.

+ * The result of some aggregation * * @author baldersheim * @author Simon Thoresen Hult @@ -20,7 +20,7 @@ public abstract class AggregationResult extends ExpressionNode { private int tag = -1; /** - *

Returns the tag of this aggregation result. This is useful for uniquely identifying a result.

+ * Returns the tag of this aggregation result. This is useful for uniquely identifying a result. * * @return The numerical tag. */ @@ -50,8 +50,8 @@ public abstract class AggregationResult extends ExpressionNode { } /** - *

This method is called when all aggregation results have been merged. This method can be overloaded by - * subclasses that need special behaviour to occur after merge.

+ * This method is called when all aggregation results have been merged. This method can be overloaded by + * subclasses that need special behaviour to occur after merge. */ public void postMerge() { // empty @@ -85,10 +85,10 @@ public abstract class AggregationResult extends ExpressionNode { } /** - *

This method must be implemented by subclasses to support merge. It is called as the {@link - * #merge(AggregationResult)} method is invoked.

+ * This method must be implemented by subclasses to support merge. It is called as the {@link + * #merge(AggregationResult)} method is invoked. * - * @param result The result to merge with. + * @param result the result to merge with */ protected abstract void onMerge(AggregationResult result); diff --git a/searchlib/src/main/java/com/yahoo/searchlib/aggregation/FS4Hit.java b/searchlib/src/main/java/com/yahoo/searchlib/aggregation/FS4Hit.java index 399ffd3128f..07de8bbdc55 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/aggregation/FS4Hit.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/aggregation/FS4Hit.java @@ -7,7 +7,7 @@ import com.yahoo.vespa.objects.ObjectVisitor; import com.yahoo.vespa.objects.Serializer; /** - * This class represents a single hit from the fastserver4 backend + * A single hit from a Vespa content cluster * * @author havardpe */ @@ -103,7 +103,7 @@ public class FS4Hit extends Hit { return super.hashCode() + path + globalId.hashCode() + distributionKey; } - @SuppressWarnings({ "EqualsWhichDoesntCheckParameterClass", "RedundantIfStatement" }) + @SuppressWarnings("RedundantIfStatement") @Override public boolean equals(Object obj) { if (!super.equals(obj)) { @@ -129,4 +129,5 @@ public class FS4Hit extends Hit { visitor.visit("globalId", globalId.toString()); visitor.visit("distributionKey", distributionKey); } + } diff --git a/searchlib/src/main/java/com/yahoo/searchlib/aggregation/Group.java b/searchlib/src/main/java/com/yahoo/searchlib/aggregation/Group.java index 73171f4dd00..126bdd474a9 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/aggregation/Group.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/aggregation/Group.java @@ -12,28 +12,28 @@ public class Group extends Identifiable { public static final int classId = registerClass(0x4000 + 90, Group.class); private static final ObjectPredicate REF_LOCATOR = new RefLocator(); - private List orderByIdx = new ArrayList(); - private List orderByExp = new ArrayList(); - private List aggregationResults = new ArrayList(); - private List children = new ArrayList(); + private List orderByIdx = new ArrayList<>(); + private List orderByExp = new ArrayList<>(); + private List aggregationResults = new ArrayList<>(); + private List children = new ArrayList<>(); private ResultNode id = null; private double rank; private int tag = -1; private SortType sortType = SortType.UNSORTED; /** - *

This tells you if the children are ranked by the pure relevance or by a more complex expression. That - * indicates if the rank score from the child can be used for ordering.

+ * This tells you if the children are ranked by the pure relevance or by a more complex expression. + * That indicates if the rank score from the child can be used for ordering. * - * @return True if it ranked by pure relevance. + * @return true if it ranked by pure relevance. */ public boolean isRankedByRelevance() { return orderByIdx.isEmpty(); } /** - *

Merges the content of the given group into this. When this function returns, make sure to call {@link - * #postMerge(java.util.List, int, int)}.

+ * Merges the content of the given group into this. When this function returns, make sure to call + * {@link #postMerge(java.util.List, int, int)}. * * @param firstLevel The first level to merge. * @param currentLevel The current level. @@ -49,7 +49,7 @@ public class Group extends Identifiable { } } - ArrayList merged = new ArrayList(); + ArrayList merged = new ArrayList<>(); Iterator lhsChild = children.iterator(), rhsChild = rhs.children.iterator(); if (lhsChild.hasNext() && rhsChild.hasNext()) { Group lhsGroup = lhsChild.next(); @@ -93,8 +93,8 @@ public class Group extends Identifiable { } /** - *

After merging, this method will prune all levels so that they do not exceed the configured maximum number of - * groups per level.

+ * After merging, this method will prune all levels so that they do not exceed the configured maximum number of + * groups per level. * * @param levels The specs of all grouping levels. * @param firstLevel The first level to merge. @@ -127,9 +127,7 @@ public class Group extends Identifiable { } - /** - *

Will sort the children by their id, if they are not sorted already.

- */ + /** Sorts the children by their id, if they are not sorted already. */ public void sortChildrenById() { if (sortType == SortType.BYID) { return; @@ -142,9 +140,7 @@ public class Group extends Identifiable { sortType = SortType.BYID; } - /** - *

Will sort the children by their rank, if they are not sorted already.

- */ + /** Sorts the children by their rank, if they are not sorted already. */ public void sortChildrenByRank() { if (sortType == SortType.BYRANK) { return; @@ -158,18 +154,16 @@ public class Group extends Identifiable { } /** - *

Returns the label to use for this group. See comment on {@link #setId(com.yahoo.searchlib.expression.ResultNode)} - * on the rationale of this being a {@link ResultNode}.

- * - * @return The label. + * Returns the label to use for this group. See comment on {@link #setId(com.yahoo.searchlib.expression.ResultNode)} + * on the rationale of this being a {@link ResultNode}. */ public ResultNode getId() { return id; } /** - *

Sets the label to use for this group. This is a {@link ResultNode} so that a group can be labeled with - * whatever value the classifier expression returns.

+ * Sets the label to use for this group. This is a {@link ResultNode} so that a group can be labeled with + * whatever value the classifier expression returns. * * @param id The label to set. * @return This, to allow chaining. @@ -180,7 +174,7 @@ public class Group extends Identifiable { } /** - *

Sets the relevancy to use for this group.

+ * Sets the relevancy to use for this group. * * @param rank The rank to set. * @return This, to allow chaining. @@ -190,17 +184,13 @@ public class Group extends Identifiable { return this; } - /** - *

Return the relevancy of this group.

- * - * @return Relevance. - */ + /** Return the rank score of this group. */ public double getRank() { return rank; } /** - *

Adds a child group to this.

+ * Adds a child group to this. * * @param child The group to add. * @return This, to allow chaining. diff --git a/searchlib/src/main/java/com/yahoo/searchlib/aggregation/Hit.java b/searchlib/src/main/java/com/yahoo/searchlib/aggregation/Hit.java index 6b2ce5c3b72..cbbecbdfa22 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/aggregation/Hit.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/aggregation/Hit.java @@ -79,7 +79,7 @@ public abstract class Hit extends Identifiable { return super.hashCode() + (int)rank; } - @SuppressWarnings({ "RedundantIfStatement", "EqualsWhichDoesntCheckParameterClass" }) + @SuppressWarnings({ "RedundantIfStatement" }) @Override public boolean equals(Object obj) { if (!super.equals(obj)) { @@ -101,4 +101,5 @@ public abstract class Hit extends Identifiable { visitor.visit("rank", rank); visitor.visit("context", context); } + } diff --git a/searchlib/src/main/java/com/yahoo/searchlib/aggregation/HitsAggregationResult.java b/searchlib/src/main/java/com/yahoo/searchlib/aggregation/HitsAggregationResult.java index 275f38f7350..c7ecdbd798d 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/aggregation/HitsAggregationResult.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/aggregation/HitsAggregationResult.java @@ -73,8 +73,8 @@ public class HitsAggregationResult extends AggregationResult { /** * Sets the summary class of hits to collect. * - * @param summaryClass The summary class to collect. - * @return This, to allow chaining. + * @param summaryClass the summary class to collect. + * @return this, to allow chaining. */ public HitsAggregationResult setSummaryClass(String summaryClass) { this.summaryClass = summaryClass; @@ -84,8 +84,8 @@ public class HitsAggregationResult extends AggregationResult { /** * Sets the maximum number of hits to collect. * - * @param maxHits The number of hits to collect. - * @return This, to allow chaining. + * @param maxHits the number of hits to collect. + * @return this, to allow chaining. */ public HitsAggregationResult setMaxHits(int maxHits) { this.maxHits = maxHits; @@ -102,7 +102,7 @@ public class HitsAggregationResult extends AggregationResult { } /** - * Add a hit to this aggregation result + * Adds a hit to this aggregation result * * @param h the hit * @return this object diff --git a/searchlib/src/test/java/com/yahoo/searchlib/aggregation/GroupingTestCase.java b/searchlib/src/test/java/com/yahoo/searchlib/aggregation/GroupingTestCase.java index fe5405ecb6a..ec379e5f8af 100644 --- a/searchlib/src/test/java/com/yahoo/searchlib/aggregation/GroupingTestCase.java +++ b/searchlib/src/test/java/com/yahoo/searchlib/aggregation/GroupingTestCase.java @@ -223,5 +223,6 @@ public class GroupingTestCase { Grouping other = (Grouping)Grouping.create(buf); assertEquals(grouping, other); } + } diff --git a/vespajlib/src/main/java/com/yahoo/vespa/objects/Identifiable.java b/vespajlib/src/main/java/com/yahoo/vespa/objects/Identifiable.java index 3e392448ce2..78fad5f5867 100644 --- a/vespajlib/src/main/java/com/yahoo/vespa/objects/Identifiable.java +++ b/vespajlib/src/main/java/com/yahoo/vespa/objects/Identifiable.java @@ -9,7 +9,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.HashMap; /** - * This is the base class to do cross-language serialization and deserialization of complete object structures without + * The base class to do cross-language serialization and deserialization of complete object structures without * the need for a separate protocol. Each subclass needs to register itself using the {@link #registerClass(int, Class)} * method, and override {@link #onGetClassId()} to return the same classId as the one registered. Creating an instance * of an identifiable object is done through the {@link #create(Deserializer)} or {@link #createFromId(int)} factory diff --git a/vespajlib/src/main/java/com/yahoo/vespa/objects/Selectable.java b/vespajlib/src/main/java/com/yahoo/vespa/objects/Selectable.java index f1b7d6dc841..e60bb664d7d 100644 --- a/vespajlib/src/main/java/com/yahoo/vespa/objects/Selectable.java +++ b/vespajlib/src/main/java/com/yahoo/vespa/objects/Selectable.java @@ -2,17 +2,17 @@ package com.yahoo.vespa.objects; /** - * @author baldersheim - * - * This class acts as an interface for traversing a tree, or a graph. + * A node in a traversable tree. * Every non leaf Object implements {@link #selectMembers(ObjectPredicate, ObjectOperation)} implementing * the actual traversal. You can then implement an {@link ObjectPredicate} to select which nodes you want to look at with * your {@link ObjectOperation} + * + * @author baldersheim */ public class Selectable { /** - * Apply the predicate to this object. If the predicate returns true, pass this object to the operation, otherwise + * Applies the predicate to this object. If the predicate returns true, pass this object to the operation, otherwise * invoke the {@link #selectMembers(ObjectPredicate, ObjectOperation)} method to locate sub-elements that might * trigger the predicate. * @@ -28,7 +28,7 @@ public class Selectable { } /** - * Invoke {@link #select(ObjectPredicate, ObjectOperation)} on any member objects this object wants to expose + * Invokes {@link #select(ObjectPredicate, ObjectOperation)} on any member objects this object wants to expose * through the selection mechanism. Overriding this method is optional, and which objects to expose is determined by * the application logic of the object itself. * @@ -44,4 +44,5 @@ public class Selectable { selectable.select(predicate, operation); } } + } -- cgit v1.2.3