public interface MetricsFilterSetBuilder
Modifier and Type | Method and Description |
---|---|
Set<Dimension> |
gatherFilterDimensions(Filter filter)
Helper method that calls
gatherFilterDimensions(Filter, Set) by passing in filter and an empty HashSet. |
Set<Dimension> |
gatherFilterDimensions(Filter filter,
Set<Dimension> dimensions)
Method to get dimensions from a Filter object.
|
String |
generateMetricName(String filterString)
Method to prepare filter string.
|
Set<FilteredAggregation> |
getFilteredAggregation(com.fasterxml.jackson.databind.JsonNode filter,
Aggregation aggregation,
DimensionDictionary dimensionDictionary,
LogicalTable table,
DataApiRequest apiRequest)
For a given aggregator, this method applies the filter and returns a set of filtered aggregations.
|
LogicalMetric |
getFilteredLogicalMetric(LogicalMetric logicalMetric,
com.fasterxml.jackson.databind.JsonNode metricFilterObject,
DimensionDictionary dimensionDictionary,
LogicalTable table,
DataApiRequest apiRequest)
Provides filter wrapped logical metric for the given logical metric.
|
PostAggregation |
replacePostAggregation(SketchSetOperationPostAggFunction func,
PostAggregation postAggregation,
Map<String,List<FilteredAggregation>> filteredAggDictionary)
A method to replace postAggs with new postAggs that access the intersection or union of filteredAggregators.
|
PostAggregation |
replacePostAggWithPostAggFromMap(PostAggregation postAggregation,
Map<String,Aggregation> oldNameToNewAggregationMapping)
Takes a post aggregation and updates its FieldAccessor if its fieldName is present in the map changed.
|
Collection<PostAggregation> |
updateNestedQueryPostAggs(Collection<PostAggregation> nestedQueryPostAggs,
Map<String,String> oldFieldNameToNewFieldNameMap,
String filterSuffix)
Update the nested query post agg names if they are not of the type CONSTANT.
|
TemplateDruidQuery |
updateOuterQuery(TemplateDruidQuery outerQuery,
Map<String,String> oldFieldNameToNewFieldNameMap)
A method to update outer query aggregations and postAggregations.
|
Set<Aggregation> |
updateQueryAggs(Set<Aggregation> outerAggregations,
Map<String,String> oldFieldNameToNewFieldNameMap,
Map<String,Aggregation> oldNameToNewAggregationMapping)
Update the outer query aggs if their respective inner post agg names are updated.
|
TemplateDruidQuery |
updateTemplateDruidQuery(TemplateDruidQuery query,
com.fasterxml.jackson.databind.JsonNode metricFilterObject,
DimensionDictionary dimensionDictionary,
LogicalTable table,
DataApiRequest apiRequest)
Method to update a given query by changing aggregators to filteredAggregators and updating postAggs to reference
the filteredAggregators.
|
void |
validateDuplicateMetrics(com.fasterxml.jackson.databind.node.ArrayNode metricsJsonArray)
This method checks if the metric query contains duplicate metrics and throws a BadApiRequestException in case
it does find duplicate metrics.
|
void validateDuplicateMetrics(com.fasterxml.jackson.databind.node.ArrayNode metricsJsonArray) throws BadApiRequestException
metricsJsonArray
- A JSONArray containing JSONObjects with name and filter. For Example :
[{"filter":{"AND":{"dim2|id-in":["abc","xyz"],"dim3|id-in":["mobile","tablet"]}},"name":"metric1"},
{"filter":{},"name":"metric2"}]
BadApiRequestException
- Invalid metric query if the metric query has
duplicate metricsLogicalMetric getFilteredLogicalMetric(LogicalMetric logicalMetric, com.fasterxml.jackson.databind.JsonNode metricFilterObject, DimensionDictionary dimensionDictionary, LogicalTable table, DataApiRequest apiRequest) throws DimensionRowNotFoundException
logicalMetric
- The LogicalMetric that needs to be transformed into a filtered Logical MetricmetricFilterObject
- A JSON object containing the filter for a given metric. For example:
{"AND":{"dim2|id-in":["abc","xyz"],"dim3|id-in":["mobile","tablet"]}},"name":"metric"
dimensionDictionary
- Dimension dictionary to look the dimension up intable
- The logical table for the data requestapiRequest
- The data api request that will be used to generate the filtersDimensionRowNotFoundException
- if the dimension mentioned in the
metric filter is not foundTemplateDruidQuery updateOuterQuery(TemplateDruidQuery outerQuery, Map<String,String> oldFieldNameToNewFieldNameMap)
outerQuery
- Outer query of a Logical MetricoldFieldNameToNewFieldNameMap
- Map which contains mapping old name --> new name of the post aggs from
the nested query. Eg: foo --> foo-dim1334dim2445Set<Aggregation> updateQueryAggs(Set<Aggregation> outerAggregations, Map<String,String> oldFieldNameToNewFieldNameMap, Map<String,Aggregation> oldNameToNewAggregationMapping)
outerAggregations
- Outer query aggregationsoldFieldNameToNewFieldNameMap
- Map which contains mapping old name --> new name of the post aggs from
the nested query. Eg: foo --> foo-dim1334dim2445oldNameToNewAggregationMapping
- Empty Map to keep old name as key and new aggregation as valueCollection<PostAggregation> updateNestedQueryPostAggs(Collection<PostAggregation> nestedQueryPostAggs, Map<String,String> oldFieldNameToNewFieldNameMap, String filterSuffix)
nestedQueryPostAggs
- A set of all the nested query post aggregationsoldFieldNameToNewFieldNameMap
- Empty Map to store the mapping old name --> new name of the post aggs.
Eg: foo --> foo-dim1334dim2445filterSuffix
- Suffix which is appended to the postAgg name to generate new postAgg nameTemplateDruidQuery updateTemplateDruidQuery(TemplateDruidQuery query, com.fasterxml.jackson.databind.JsonNode metricFilterObject, DimensionDictionary dimensionDictionary, LogicalTable table, DataApiRequest apiRequest) throws DimensionRowNotFoundException
query
- Template druid query of a given Logical Metric. Can also be the nested query but can only contain
Sketch aggregations.metricFilterObject
- Metric filter associated with the metricdimensionDictionary
- Dimension dictionary to look the dimension up intable
- The logical table for the data requestapiRequest
- The data api request that will be used to generate the filtersDimensionRowNotFoundException
- if the dimension row in the metric
filter is not found.PostAggregation replacePostAggregation(SketchSetOperationPostAggFunction func, PostAggregation postAggregation, Map<String,List<FilteredAggregation>> filteredAggDictionary)
func
- Sketch operation function Ex: INTERSECT, UNIONpostAggregation
- Post aggregation which needs to be replacedfilteredAggDictionary
- Dictionary which holds aggregator name as key and list of FilteredAggregation as
valuePostAggregation replacePostAggWithPostAggFromMap(PostAggregation postAggregation, Map<String,Aggregation> oldNameToNewAggregationMapping)
postAggregation
- Outer query post aggregation that needs to be updatedoldNameToNewAggregationMapping
- Map with old aggname as key and new aggregation as valueSet<FilteredAggregation> getFilteredAggregation(com.fasterxml.jackson.databind.JsonNode filter, Aggregation aggregation, DimensionDictionary dimensionDictionary, LogicalTable table, DataApiRequest apiRequest) throws DimensionRowNotFoundException
filter
- Filter to be used in generating FilteredAggregationaggregation
- Aggregation that needs to be wrapped with Filter in order to generate the
FilteredAggregationdimensionDictionary
- Dimension dictionary to look the dimension up intable
- The logical table for the data requestapiRequest
- The data api request that will be used to generate the filtersDimensionRowNotFoundException
- if the dimension row in the metric
filter is not found.String generateMetricName(String filterString)
filterString
- Single dimension filter stringSet<Dimension> gatherFilterDimensions(Filter filter)
gatherFilterDimensions(Filter, Set)
by passing in filter and an empty HashSet.filter
- Filter object whose dimensions are to be collectedSet<Dimension> gatherFilterDimensions(Filter filter, Set<Dimension> dimensions)
filter
- filter whose dimensions need to be collecteddimensions
- Set of dimensions belonging to a filter. Empty when the method is first called.Copyright © 2016–2018 Yahoo! Inc.. All rights reserved.