diff options
author | Henrik <henrik.hoiness@online.no> | 2018-08-07 15:12:49 +0200 |
---|---|---|
committer | Henrik <henrik.hoiness@online.no> | 2018-08-07 15:12:49 +0200 |
commit | b9e3b6ec96e2dc164eba2e340d2caaec928b440e (patch) | |
tree | 8dddfeefcd2054a3f3cc7ce4bdcfade6847252bb /container-search/src | |
parent | be31b9fc952bc6ad9548d8374cd0ae32b89223b6 (diff) |
GroupingRequest.getRequests() now returning query.getSelect().getGrouping() and marked deprecated
Diffstat (limited to 'container-search/src')
4 files changed, 15 insertions, 22 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/grouping/GroupingRequest.java b/container-search/src/main/java/com/yahoo/search/grouping/GroupingRequest.java index 8ce0d90dfc5..4e6062e2c9b 100644 --- a/container-search/src/main/java/com/yahoo/search/grouping/GroupingRequest.java +++ b/container-search/src/main/java/com/yahoo/search/grouping/GroupingRequest.java @@ -151,14 +151,8 @@ public class GroupingRequest { * @return The list of grouping requests. */ @SuppressWarnings({ "unchecked" }) + @Deprecated public static List<GroupingRequest> getRequests(Query query) { - Object lst = query.properties().get(PROP_REQUEST); - if (lst == null) { - return Collections.emptyList(); - } - if (!(lst instanceof List)) { - throw new IllegalArgumentException("Expected " + GroupingRequest.class + ", got " + lst.getClass() + "."); - } - return (List<GroupingRequest>)lst; + return query.getSelect().getGrouping(); } } diff --git a/container-search/src/main/java/com/yahoo/search/grouping/vespa/GroupingExecutor.java b/container-search/src/main/java/com/yahoo/search/grouping/vespa/GroupingExecutor.java index 6c9faccad5c..c503503ad4b 100644 --- a/container-search/src/main/java/com/yahoo/search/grouping/vespa/GroupingExecutor.java +++ b/container-search/src/main/java/com/yahoo/search/grouping/vespa/GroupingExecutor.java @@ -378,7 +378,7 @@ public class GroupingExecutor extends Searcher { return (obj instanceof List); } - /**1 + /** * Sets the list of {@link Grouping} objects assigned to the given query. This method overwrites any grouping * objects already assigned to the query. * diff --git a/container-search/src/main/java/com/yahoo/search/query/Select.java b/container-search/src/main/java/com/yahoo/search/query/Select.java index 9b287fe2d10..db3ce811b63 100644 --- a/container-search/src/main/java/com/yahoo/search/query/Select.java +++ b/container-search/src/main/java/com/yahoo/search/query/Select.java @@ -70,7 +70,9 @@ public class Select implements Cloneable { } - /** Set the where-clause for the query. Must be a JSON-string, with the format described in the Select Reference doc - https://docs.vespa.ai/documentation/reference/select-reference.html. */ + /** Set the where-clause for the query. Must be a JSON-string, with the format described in the Select Reference doc: + * @see <a href="https://docs.vespa.ai/documentation/reference/select-reference.html">https://docs.vespa.ai/documentation/reference/select-reference.html</a> + */ public void setWhereString(String where) { this.where = where; model.setType(SELECT); @@ -81,12 +83,12 @@ public class Select implements Cloneable { /** Returns the where-clause in the query */ - public String getWhereString(){ - return this.where; - } + public String getWhereString(){ return where; } - /** Set the grouping-string for the query. Must be a JSON-string, with the format described in the Select Reference doc - https://docs.vespa.ai/documentation/reference/select-reference.html. */ + /** Set the grouping-string for the query. Must be a JSON-string, with the format described in the Select Reference doc: + * @see <a href="https://docs.vespa.ai/documentation/reference/select-reference.html">https://docs.vespa.ai/documentation/reference/select-reference.html</a> + * */ public void setGroupingString(String grouping){ this.grouping = grouping; SelectParser parser = (SelectParser) ParserFactory.newInstance(Query.Type.SELECT, new ParserEnvironment()); @@ -101,23 +103,20 @@ public class Select implements Cloneable { /** Returns the grouping in the query */ public String getGroupingString(){ - return this.grouping; + return grouping; } /** Returns the query's {@link GroupingRequest} objects */ - public List<GroupingRequest> getGrouping(){ return this.groupingRequests; } + public List<GroupingRequest> getGrouping(){ return groupingRequests; } /** Set the query's list of {@link GroupingRequest} objects */ - public void setGrouping(Object lst){ + public void setGrouping(List<GroupingRequest> lst){ if (lst == null) { lst = Collections.emptyList(); } - if (!(lst instanceof List)) { - throw new IllegalArgumentException("Expected " + GroupingRequest.class + ", got " + lst.getClass() + "."); - } - this.groupingRequests = (List<GroupingRequest>) lst; + this.groupingRequests = lst; } diff --git a/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java b/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java index 9523ee36568..391333be7e8 100644 --- a/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java +++ b/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java @@ -278,7 +278,7 @@ public class QueryProperties extends Properties { else if (key.equals(Query.GROUPING_SESSION_CACHE)) query.setGroupingSessionCache(asBoolean(value, false)); else if (key.equals(GroupingExecutor.GROUPING_LIST)) - query.getSelect().setGrouping(value); + query.getSelect().setGrouping((List<GroupingRequest>)value); else super.set(key,value,context); } |