public class DataApiRequestImpl extends ApiRequestImpl implements DataApiRequest
asyncAfter, builder, COMMA_AFTER_BRACKET_PATTERN, format, pagination, paginationParameters, uriInfo
DATE_TIME_STRING, RATIO_METRIC_CATEGORY, REQUEST_MAPPER_NAMESPACE
ASYNCHRONOUS_ASYNC_AFTER_VALUE, SYNCHRONOUS_ASYNC_AFTER_VALUE
Modifier | Constructor and Description |
---|---|
protected |
DataApiRequestImpl(ResponseFormatType format,
Optional<PaginationParameters> paginationParameters,
javax.ws.rs.core.UriInfo uriInfo,
javax.ws.rs.core.Response.ResponseBuilder builder,
LogicalTable table,
Granularity granularity,
Set<Dimension> dimensions,
LinkedHashMap<Dimension,LinkedHashSet<DimensionField>> perDimensionFields,
Set<LogicalMetric> logicalMetrics,
Set<org.joda.time.Interval> intervals,
ApiFilters apiFilters,
Map<LogicalMetric,Set<ApiHaving>> havings,
Having having,
LinkedHashSet<OrderByColumn> sorts,
int count,
int topN,
long asyncAfter,
org.joda.time.DateTimeZone timeZone,
DruidFilterBuilder filterBuilder,
HavingGenerator havingApiGenerator,
Optional<OrderByColumn> dateTimeSort)
All argument constructor, meant to be used for rewriting apiRequest.
|
|
DataApiRequestImpl(String tableName,
String granularity,
List<javax.ws.rs.core.PathSegment> dimensions,
String logicalMetrics,
String intervals,
String apiFilters,
String havings,
String sorts,
String count,
String topN,
String format,
String timeZoneId,
String asyncAfter,
String perPage,
String page,
javax.ws.rs.core.UriInfo uriInfo,
BardConfigResources bardConfigResources)
Parses the API request URL and generates the Api Request object.
|
|
DataApiRequestImpl(String tableName,
String granularity,
List<javax.ws.rs.core.PathSegment> dimensions,
String logicalMetrics,
String intervals,
String apiFilters,
String havings,
String sorts,
String count,
String topN,
String format,
String timeZoneId,
String asyncAfter,
String perPage,
String page,
javax.ws.rs.core.UriInfo uriInfo,
DimensionDictionary dimensionDictionary,
MetricDictionary metricDictionary,
LogicalTableDictionary logicalTableDictionary,
org.joda.time.DateTimeZone systemTimeZone,
GranularityParser granularityParser,
DruidFilterBuilder druidFilterBuilder,
HavingGenerator havingGenerator)
Parses the API request URL and generates the Api Request object.
|
Modifier and Type | Method and Description |
---|---|
protected Optional<OrderByColumn> |
generateDateTimeSortColumn(LinkedHashMap<String,SortDirection> sortColumns)
Method to generate DateTime sort column from the map of columns and its direction.
|
protected LinkedHashMap<Dimension,LinkedHashSet<DimensionField>> |
generateDimensionFields(List<javax.ws.rs.core.PathSegment> apiDimensionPathSegments,
DimensionDictionary dimensionDictionary)
Extracts the list of dimensions from the url dimension path segments and "show" matrix params and generates a map
of dimension to dimension fields which needs to be annotated on the response.
|
protected int |
generateInteger(String value,
String parameterName)
Parses the requested input String by converting it to an integer, while treating null as zero.
|
protected LinkedHashSet<LogicalMetric> |
generateLogicalMetrics(String apiMetricQuery,
MetricDictionary metricDictionary,
DimensionDictionary dimensionDictionary,
LogicalTable table)
Extracts the list of metrics from the url metric query string and generates a set of LogicalMetrics.
|
protected LinkedHashSet<OrderByColumn> |
generateSortColumns(Map<String,SortDirection> sortDirectionMap,
Set<LogicalMetric> logicalMetrics,
MetricDictionary metricDictionary)
Generates a Set of OrderByColumn.
|
protected LinkedHashMap<String,SortDirection> |
generateSortColumns(String sorts)
Method to convert sort list to column and direction map.
|
ApiFilters |
getApiFilters()
The filters for this ApiRequest, grouped by dimensions.
|
OptionalInt |
getCount()
An optional limit of records returned.
|
protected org.joda.time.DateTime |
getCurrentDate(org.joda.time.DateTime dateTime,
TimeGrain timeGrain)
Generate current date based on granularity.
|
Optional<OrderByColumn> |
getDateTimeSort()
An optional sorting predicate for the time column.
|
LinkedHashMap<Dimension,LinkedHashSet<DimensionField>> |
getDimensionFields()
A map of dimension fields specified for the output schema.
|
Set<Dimension> |
getDimensions()
The set of grouping dimensions on this ApiRequest.
|
Filter |
getDruidFilter()
Builds and returns the Druid filters from this request's
ApiFilter s. |
DruidFilterBuilder |
getFilterBuilder()
A filter builder (remove).
|
Set<Dimension> |
getFilterDimensions()
Gets the filter dimensions form the given set of filter objects.
|
Granularity |
getGranularity()
The grain to group the results of this request.
|
Having |
getHaving()
The fact model having (should probably remove this).
|
Map<LogicalMetric,Set<ApiHaving>> |
getHavings()
The having constraints for this request, grouped by logical metrics.
|
Set<org.joda.time.Interval> |
getIntervals()
The intervals for this query.
|
Set<LogicalMetric> |
getLogicalMetrics()
The logical metrics requested in this query.
|
protected SortDirection |
getSortDirection(List<String> columnWithDirection)
Extract valid sort direction.
|
LinkedHashSet<OrderByColumn> |
getSorts()
A prioritized list of sort columns.
|
LogicalTable |
getTable()
The logical table for this request.
|
org.joda.time.DateTimeZone |
getTimeZone()
The date time zone to apply to the dateTime parameter and to express the response and granularity in.
|
OptionalInt |
getTopN()
The limit per time bucket for a top n query.
|
protected Boolean |
isDateTimeFirstSortField(LinkedHashMap<String,SortDirection> sortColumns)
To check whether dateTime column request is first one in the sort list or not.
|
static Predicate<ApiFilter> |
isNonAggregatableInFilter()
Validity rules for non-aggregatable dimensions that are only referenced in filters.
|
protected Map<String,SortDirection> |
removeDateTimeSortColumn(Map<String,SortDirection> sortColumns)
Method to remove the dateTime column from map of columns and its direction.
|
protected void |
validateAggregatability(Set<Dimension> apiDimensions,
Map<Dimension,Set<ApiFilter>> apiFilters)
Validate that the request references any non-aggregatable dimensions in a valid way.
|
DataApiRequestImpl |
withAsyncAfter(long asyncAfter) |
DataApiRequestImpl |
withBuilder(javax.ws.rs.core.Response.ResponseBuilder builder) |
DataApiRequestImpl |
withCount(int count) |
DataApiRequestImpl |
withDimensions(Set<Dimension> dimensions) |
DataApiRequestImpl |
withFilterBuilder(DruidFilterBuilder filterBuilder) |
DataApiRequestImpl |
withFilters(ApiFilters apiFilters) |
DataApiRequestImpl |
withFormat(ResponseFormatType format) |
DataApiRequestImpl |
withGranularity(Granularity granularity) |
DataApiRequestImpl |
withHaving(Having having) |
DataApiRequestImpl |
withHavings(Map<LogicalMetric,Set<ApiHaving>> havings) |
DataApiRequestImpl |
withIntervals(Set<org.joda.time.Interval> intervals) |
DataApiRequestImpl |
withLogicalMetrics(Set<LogicalMetric> logicalMetrics) |
DataApiRequestImpl |
withPaginationParameters(Optional<PaginationParameters> paginationParameters) |
DataApiRequestImpl |
withPerDimensionFields(LinkedHashMap<Dimension,LinkedHashSet<DimensionField>> perDimensionFields) |
DataApiRequestImpl |
withSorts(LinkedHashSet<OrderByColumn> sorts) |
DataApiRequestImpl |
withTable(LogicalTable table) |
DataApiRequestImpl |
withTimeZone(org.joda.time.DateTimeZone timeZone) |
DataApiRequestImpl |
withTopN(int topN) |
DataApiRequestImpl |
withUriInfo(javax.ws.rs.core.UriInfo uriInfo) |
addPageLink, addPageLink, generateAcceptFormat, generateAsyncAfter, generateDimensions, generateFilters, generateGranularity, generateGranularity, generateIntervals, generateIntervals, generateLogicalMetrics, generateMetricName, generatePaginationParameters, generateTable, generateTimeZone, getAllPagesPaginationFactory, getAsDateTime, getAsyncAfter, getBuilder, getDefaultPagination, getFormat, getPage, getPage, getPagination, getPaginationParameters, getUriInfo, validateMetrics, validateRequestDimensions, validateTimeAlignment
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
generateFilters
generateDateTimeFormatter, getAsyncAfter, getBuilder, getDefaultPagination, getFormat, getPage, getPage, getPagination, getPaginationParameters, getUriInfo
public DataApiRequestImpl(String tableName, String granularity, List<javax.ws.rs.core.PathSegment> dimensions, String logicalMetrics, String intervals, String apiFilters, String havings, String sorts, String count, String topN, String format, String timeZoneId, String asyncAfter, @NotNull String perPage, @NotNull String page, javax.ws.rs.core.UriInfo uriInfo, BardConfigResources bardConfigResources) throws BadApiRequestException
tableName
- logical table corresponding to the table name specified in the URLgranularity
- string time granularity in URLdimensions
- single dimension or multiple dimensions separated by '/' in URLlogicalMetrics
- URL logical metric query string in the format:
single metric or multiple logical metrics separated by ','
intervals
- URL intervals query string in the format:
single interval in ISO 8601 format, multiple values separated by ','
apiFilters
- URL filter query String in the format:
((field name and operation):((multiple values bounded by [])or(single value))))(followed by , or end of string)
havings
- URL having query String in the format:
((metric name)-(operation)((values bounded by [])))(followed by , or end of string)
sorts
- string of sort columns along with sort direction in the format:
(metricName or dimensionName)|(sortDirection) eg: pageViews|asc
count
- count of number of records to be returned in the responsetopN
- number of first records per time bucket to be returned in the responseformat
- response data format JSON or CSV. Default is JSON.timeZoneId
- a joda time zone idasyncAfter
- How long the user is willing to wait for a synchronous request in millisecondsperPage
- number of rows to display per page of results. If present in the original request,
must be a positive integer. If not present, must be the empty string.page
- desired page of results. If present in the original request, must be a positive
integer. If not present, must be the empty string.uriInfo
- The URI of the request object.bardConfigResources
- The configuration resources used to build this api requestBadApiRequestException
- in the following scenarios:
public DataApiRequestImpl(String tableName, String granularity, List<javax.ws.rs.core.PathSegment> dimensions, String logicalMetrics, String intervals, String apiFilters, String havings, String sorts, String count, String topN, String format, String timeZoneId, String asyncAfter, @NotNull String perPage, @NotNull String page, javax.ws.rs.core.UriInfo uriInfo, DimensionDictionary dimensionDictionary, MetricDictionary metricDictionary, LogicalTableDictionary logicalTableDictionary, org.joda.time.DateTimeZone systemTimeZone, GranularityParser granularityParser, DruidFilterBuilder druidFilterBuilder, HavingGenerator havingGenerator) throws BadApiRequestException
tableName
- logical table corresponding to the table name specified in the URLgranularity
- string time granularity in URLdimensions
- single dimension or multiple dimensions separated by '/' in URLlogicalMetrics
- URL logical metric query string in the format:
single metric or multiple logical metrics separated by ','
intervals
- URL intervals query string in the format:
single interval in ISO 8601 format, multiple values separated by ','
apiFilters
- URL filter query String in the format:
((field name and operation):((multiple values bounded by [])or(single value))))(followed by , or end of string)
havings
- URL having query String in the format:
((metric name)-(operation)((values bounded by [])))(followed by , or end of string)
sorts
- string of sort columns along with sort direction in the format:
(metricName or dimensionName)|(sortDirection) eg: pageViews|asc
count
- count of number of records to be returned in the responsetopN
- number of first records per time bucket to be returned in the responseformat
- response data format JSON or CSV. Default is JSON.timeZoneId
- a joda time zone idasyncAfter
- How long the user is willing to wait for a synchronous request in millisecondsperPage
- number of rows to display per page of results. If present in the original request,
must be a positive integer. If not present, must be the empty string.page
- desired page of results. If present in the original request, must be a positive
integer. If not present, must be the empty string.uriInfo
- The URI of the request object.dimensionDictionary
- The dimension dictionary for binding dimensionsmetricDictionary
- The metric dictionary for binding metricslogicalTableDictionary
- The table dictionary for binding logical tablessystemTimeZone
- The default time zone for the systemgranularityParser
- A tool to process granularitiesdruidFilterBuilder
- A function to build druid filters from Api FiltershavingGenerator
- A function to create havingsBadApiRequestException
- in the following scenarios:
protected DataApiRequestImpl(ResponseFormatType format, Optional<PaginationParameters> paginationParameters, javax.ws.rs.core.UriInfo uriInfo, javax.ws.rs.core.Response.ResponseBuilder builder, LogicalTable table, Granularity granularity, Set<Dimension> dimensions, LinkedHashMap<Dimension,LinkedHashSet<DimensionField>> perDimensionFields, Set<LogicalMetric> logicalMetrics, Set<org.joda.time.Interval> intervals, ApiFilters apiFilters, Map<LogicalMetric,Set<ApiHaving>> havings, Having having, LinkedHashSet<OrderByColumn> sorts, int count, int topN, long asyncAfter, org.joda.time.DateTimeZone timeZone, DruidFilterBuilder filterBuilder, HavingGenerator havingApiGenerator, Optional<OrderByColumn> dateTimeSort)
format
- Format for the responsepaginationParameters
- Pagination infouriInfo
- The URI infobuilder
- A response buildertable
- Logical table requestedgranularity
- Granularity of the requestdimensions
- Grouping dimensions of the requestperDimensionFields
- Fields for each of the grouped dimensionslogicalMetrics
- Metrics requestedintervals
- Intervals requestedapiFilters
- Global filtershavings
- Top-level Having caluses for the requesthaving
- Single global Druid Havingsorts
- Sorting info for the requestcount
- Global limit for the requesttopN
- Count of per-bucket limit (TopN) for the requestasyncAfter
- How long in milliseconds the user is willing to wait for a synchronous responsetimeZone
- TimeZone for the requestfilterBuilder
- A builder to use when building filters for the requesthavingApiGenerator
- A generator to generate havings map for the requestdateTimeSort
- A dateTime sort column with its directionprotected Boolean isDateTimeFirstSortField(LinkedHashMap<String,SortDirection> sortColumns)
sortColumns
- LinkedHashMap of columns and its direction. Using LinkedHashMap to preserve the orderprotected Map<String,SortDirection> removeDateTimeSortColumn(Map<String,SortDirection> sortColumns)
sortColumns
- map of columns and its directionprotected Optional<OrderByColumn> generateDateTimeSortColumn(LinkedHashMap<String,SortDirection> sortColumns)
sortColumns
- LinkedHashMap of columns and its direction. Using LinkedHashMap to preserve the orderprotected LinkedHashMap<String,SortDirection> generateSortColumns(String sorts)
sorts
- String of sort columnsprotected LinkedHashMap<Dimension,LinkedHashSet<DimensionField>> generateDimensionFields(@NotNull List<javax.ws.rs.core.PathSegment> apiDimensionPathSegments, @NotNull DimensionDictionary dimensionDictionary)
If no "show" matrix param has been set, it returns the default dimension fields configured for the dimension.
apiDimensionPathSegments
- Path segments for the dimensionsdimensionDictionary
- Dimension dictionary to look the dimensions up inprotected void validateAggregatability(Set<Dimension> apiDimensions, Map<Dimension,Set<ApiFilter>> apiFilters) throws BadApiRequestException
apiDimensions
- the set of group by dimensions.apiFilters
- the set of api filters.BadApiRequestException
- if a the request violates aggregatability constraints of dimensions.public static Predicate<ApiFilter> isNonAggregatableInFilter()
protected LinkedHashSet<LogicalMetric> generateLogicalMetrics(String apiMetricQuery, MetricDictionary metricDictionary, DimensionDictionary dimensionDictionary, LogicalTable table) throws BadApiRequestException
apiMetricQuery
- URL query string containing the metrics separated by ','.metricDictionary
- Metric dictionary contains the map of valid metric names and logical metric objects.dimensionDictionary
- Dimension dictionary to look the dimension up intable
- The logical table for the data requestBadApiRequestException
- if the metric dictionary returns a null or if the apiMetricQuery is invalid.protected org.joda.time.DateTime getCurrentDate(org.joda.time.DateTime dateTime, TimeGrain timeGrain)
dateTime
- The current moment as a DateTimetimeGrain
- The time grain used to round the date timeprotected SortDirection getSortDirection(List<String> columnWithDirection)
columnWithDirection
- Column and its sorting directionprotected LinkedHashSet<OrderByColumn> generateSortColumns(Map<String,SortDirection> sortDirectionMap, Set<LogicalMetric> logicalMetrics, MetricDictionary metricDictionary) throws BadApiRequestException
sortDirectionMap
- Map of columns and their directionlogicalMetrics
- Set of LogicalMetrics in the querymetricDictionary
- Metric dictionary contains the map of valid metric names and logical metric objects.BadApiRequestException
- if the sort clause is invalid.protected int generateInteger(String value, String parameterName) throws BadApiRequestException
value
- The requested integer value as String.parameterName
- The parameter name that corresponds to the requested integer value.value
or zero if value
is null.BadApiRequestException
- if the input String can not be parsed as an integer.public DataApiRequestImpl withFormat(ResponseFormatType format)
withFormat
in interface DataApiRequest
public DataApiRequestImpl withPaginationParameters(Optional<PaginationParameters> paginationParameters)
withPaginationParameters
in interface DataApiRequest
public DataApiRequestImpl withUriInfo(javax.ws.rs.core.UriInfo uriInfo)
withUriInfo
in interface DataApiRequest
public DataApiRequestImpl withBuilder(javax.ws.rs.core.Response.ResponseBuilder builder)
withBuilder
in interface DataApiRequest
public DataApiRequestImpl withTable(LogicalTable table)
withTable
in interface DataApiRequest
public DataApiRequestImpl withGranularity(Granularity granularity)
withGranularity
in interface DataApiRequest
public DataApiRequestImpl withDimensions(Set<Dimension> dimensions)
withDimensions
in interface DataApiRequest
public DataApiRequestImpl withPerDimensionFields(LinkedHashMap<Dimension,LinkedHashSet<DimensionField>> perDimensionFields)
withPerDimensionFields
in interface DataApiRequest
public DataApiRequestImpl withLogicalMetrics(Set<LogicalMetric> logicalMetrics)
withLogicalMetrics
in interface DataApiRequest
public DataApiRequestImpl withIntervals(Set<org.joda.time.Interval> intervals)
withIntervals
in interface DataApiRequest
public DataApiRequestImpl withFilters(ApiFilters apiFilters)
withFilters
in interface DataApiRequest
public DataApiRequestImpl withHavings(Map<LogicalMetric,Set<ApiHaving>> havings)
withHavings
in interface DataApiRequest
public DataApiRequestImpl withHaving(Having having)
withHaving
in interface DataApiRequest
public DataApiRequestImpl withSorts(LinkedHashSet<OrderByColumn> sorts)
withSorts
in interface DataApiRequest
public DataApiRequestImpl withCount(int count)
withCount
in interface DataApiRequest
public DataApiRequestImpl withTopN(int topN)
withTopN
in interface DataApiRequest
public DataApiRequestImpl withAsyncAfter(long asyncAfter)
withAsyncAfter
in interface DataApiRequest
public DataApiRequestImpl withTimeZone(org.joda.time.DateTimeZone timeZone)
withTimeZone
in interface DataApiRequest
public DataApiRequestImpl withFilterBuilder(DruidFilterBuilder filterBuilder)
withFilterBuilder
in interface DataApiRequest
public Set<Dimension> getFilterDimensions()
getFilterDimensions
in interface DataApiRequest
public LogicalTable getTable()
DataApiRequest
getTable
in interface DataApiRequest
public Granularity getGranularity()
DataApiRequest
getGranularity
in interface DataApiRequest
public Set<Dimension> getDimensions()
DataApiRequest
getDimensions
in interface DataApiRequest
public LinkedHashMap<Dimension,LinkedHashSet<DimensionField>> getDimensionFields()
DataApiRequest
getDimensionFields
in interface DataApiRequest
public Set<LogicalMetric> getLogicalMetrics()
DataApiRequest
getLogicalMetrics
in interface DataApiRequest
public Set<org.joda.time.Interval> getIntervals()
DataApiRequest
getIntervals
in interface DataApiRequest
public ApiFilters getApiFilters()
DataApiRequest
getApiFilters
in interface DataApiRequest
public Filter getDruidFilter()
ApiFilter
s.
The Druid filters are built (an expensive operation) every time this method is called. Use it judiciously.
getDruidFilter
in interface DataApiRequest
public Map<LogicalMetric,Set<ApiHaving>> getHavings()
DataApiRequest
getHavings
in interface DataApiRequest
public Having getHaving()
DataApiRequest
getHaving
in interface DataApiRequest
public LinkedHashSet<OrderByColumn> getSorts()
DataApiRequest
getSorts
in interface DataApiRequest
public OptionalInt getCount()
DataApiRequest
getCount
in interface DataApiRequest
public OptionalInt getTopN()
DataApiRequest
getTopN
in interface DataApiRequest
public org.joda.time.DateTimeZone getTimeZone()
DataApiRequest
getTimeZone
in interface DataApiRequest
public DruidFilterBuilder getFilterBuilder()
DataApiRequest
getFilterBuilder
in interface DataApiRequest
public Optional<OrderByColumn> getDateTimeSort()
DataApiRequest
getDateTimeSort
in interface DataApiRequest
Copyright © 2016–2018 Yahoo! Inc.. All rights reserved.