diff options
author | Henrik <henrik.hoiness@online.no> | 2018-08-07 14:43:00 +0200 |
---|---|---|
committer | Henrik <henrik.hoiness@online.no> | 2018-08-07 14:43:00 +0200 |
commit | be31b9fc952bc6ad9548d8374cd0ae32b89223b6 (patch) | |
tree | 247499248ef2e52b28724697de02b23b82afda6d /container-search/src/main/java/com/yahoo/search/query/Select.java | |
parent | d0cf8f54872dd5483e1d319c9fdde3987bdcf9b1 (diff) |
Added a object structure for GroupingRequest objects, accessable from query.getSelect().getGrouping()
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query/Select.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/query/Select.java | 25 |
1 files changed, 22 insertions, 3 deletions
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 3ffc6bddb24..9b287fe2d10 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 @@ -10,6 +10,9 @@ import com.yahoo.search.query.profile.types.FieldDescription; import com.yahoo.search.query.profile.types.QueryProfileType; import com.yahoo.search.yql.VespaGroupingStep; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; /** @@ -27,11 +30,11 @@ public class Select implements Cloneable { public static final String WHERE = "where"; public static final String GROUPING = "grouping"; - private static Model model; private Query parent; private String where = ""; private String grouping = ""; + private List<GroupingRequest> groupingRequests = new ArrayList<>(); static { argumentType = new QueryProfileType(SELECT); @@ -68,7 +71,7 @@ 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. */ - public void setWhere(String where) { + public void setWhereString(String where) { this.where = where; model.setType(SELECT); @@ -84,7 +87,7 @@ public class Select implements Cloneable { /** 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. */ - public void setGrouping(String grouping){ + public void setGroupingString(String grouping){ this.grouping = grouping; SelectParser parser = (SelectParser) ParserFactory.newInstance(Query.Type.SELECT, new ParserEnvironment()); @@ -102,6 +105,22 @@ public class Select implements Cloneable { } + /** Returns the query's {@link GroupingRequest} objects */ + public List<GroupingRequest> getGrouping(){ return this.groupingRequests; } + + + /** Set the query's list of {@link GroupingRequest} objects */ + public void setGrouping(Object 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; + } + + @Override public String toString() { return "where: [" + where + "], grouping: [" + grouping+ "]"; |