Search in sources :

Example 6 with ThirdEyeRequestBuilder

use of com.linkedin.thirdeye.client.ThirdEyeRequest.ThirdEyeRequestBuilder in project pinot by linkedin.

the class PinotThirdEyeSummaryClient method constructTimeOnTimeBulkRequests.

/**
   * Returns the baseline and current requests for the given GroupBy dimensions.
   *
   * @param groupBy the dimensions to do GroupBy queries
   * @return Baseline and Current requests.
   */
private List<ThirdEyeRequest> constructTimeOnTimeBulkRequests(List<String> groupBy) {
    List<ThirdEyeRequest> requests = new ArrayList<>();
    ;
    // baseline requests
    ThirdEyeRequestBuilder builder = ThirdEyeRequest.newBuilder();
    builder.setCollection(collection);
    builder.setMetricFunctions(metricFunctions);
    builder.setGroupBy(groupBy);
    builder.setStartTimeInclusive(baselineStartInclusive);
    builder.setEndTimeExclusive(baselineEndExclusive);
    ThirdEyeRequest baselineRequest = builder.build("baseline");
    requests.add(baselineRequest);
    // current requests
    builder = ThirdEyeRequest.newBuilder();
    builder.setCollection(collection);
    builder.setMetricFunctions(metricFunctions);
    builder.setGroupBy(groupBy);
    builder.setStartTimeInclusive(currentStartInclusive);
    builder.setEndTimeExclusive(currentEndExclusive);
    ThirdEyeRequest currentRequest = builder.build("current");
    requests.add(currentRequest);
    return requests;
}
Also used : ThirdEyeRequestBuilder(com.linkedin.thirdeye.client.ThirdEyeRequest.ThirdEyeRequestBuilder) ArrayList(java.util.ArrayList) ThirdEyeRequest(com.linkedin.thirdeye.client.ThirdEyeRequest)

Example 7 with ThirdEyeRequestBuilder

use of com.linkedin.thirdeye.client.ThirdEyeRequest.ThirdEyeRequestBuilder in project pinot by linkedin.

the class ThirdEyeRequestGenerator method generateRequest.

public static ThirdEyeRequest generateRequest(String name, TimeOnTimeComparisonRequest comparisonRequest, DateTime start, DateTime end, String groupByDimension, TimeGranularity aggTimeGranularity) {
    ThirdEyeRequestBuilder requestBuilder = new ThirdEyeRequestBuilder();
    // COMMON to ALL REQUESTS
    requestBuilder.setCollection(comparisonRequest.getCollectionName());
    requestBuilder.setFilterSet(comparisonRequest.getFilterSet());
    requestBuilder.setFilterClause(comparisonRequest.getFilterClause());
    List<MetricFunction> metricFunctionsFromExpressions = Utils.computeMetricFunctionsFromExpressions(comparisonRequest.getMetricExpressions());
    requestBuilder.setMetricFunctions(metricFunctionsFromExpressions);
    // REQUEST to get total value with out break down.
    requestBuilder.setStartTimeInclusive(start);
    requestBuilder.setEndTimeExclusive(end);
    if (groupByDimension != null) {
        requestBuilder.setGroupBy(groupByDimension);
    }
    if (aggTimeGranularity != null) {
        requestBuilder.setGroupByTimeGranularity(aggTimeGranularity);
    }
    ThirdEyeRequest request = requestBuilder.build(name);
    return request;
}
Also used : ThirdEyeRequestBuilder(com.linkedin.thirdeye.client.ThirdEyeRequest.ThirdEyeRequestBuilder) MetricFunction(com.linkedin.thirdeye.client.MetricFunction) ThirdEyeRequest(com.linkedin.thirdeye.client.ThirdEyeRequest)

Example 8 with ThirdEyeRequestBuilder

use of com.linkedin.thirdeye.client.ThirdEyeRequest.ThirdEyeRequestBuilder in project pinot by linkedin.

the class TimeOnTimeComparisonHandler method createThirdEyeRequest.

private static ThirdEyeRequest createThirdEyeRequest(String requestReference, TimeOnTimeComparisonRequest comparisonRequest, DateTime start, DateTime end) {
    ThirdEyeRequestBuilder requestBuilder = ThirdEyeRequest.newBuilder();
    requestBuilder.setCollection(comparisonRequest.getCollectionName());
    requestBuilder.setStartTimeInclusive(start);
    requestBuilder.setEndTimeExclusive(end);
    requestBuilder.setFilterSet(comparisonRequest.getFilterSet());
    requestBuilder.addGroupBy(comparisonRequest.getGroupByDimensions());
    requestBuilder.setGroupByTimeGranularity(comparisonRequest.getAggregationTimeGranularity());
    List<MetricExpression> metricExpressions = comparisonRequest.getMetricExpressions();
    List<MetricFunction> metricFunctionsFromExpressions = Utils.computeMetricFunctionsFromExpressions(metricExpressions);
    requestBuilder.setMetricFunctions(metricFunctionsFromExpressions);
    return requestBuilder.build(requestReference);
}
Also used : ThirdEyeRequestBuilder(com.linkedin.thirdeye.client.ThirdEyeRequest.ThirdEyeRequestBuilder) MetricFunction(com.linkedin.thirdeye.client.MetricFunction) MetricExpression(com.linkedin.thirdeye.client.MetricExpression)

Example 9 with ThirdEyeRequestBuilder

use of com.linkedin.thirdeye.client.ThirdEyeRequest.ThirdEyeRequestBuilder in project pinot by linkedin.

the class TimeSeriesHandler method createThirdEyeRequest.

private static ThirdEyeRequest createThirdEyeRequest(String requestReference, TimeSeriesRequest timeSeriesRequest, DateTime start, DateTime end) {
    ThirdEyeRequestBuilder requestBuilder = ThirdEyeRequest.newBuilder();
    requestBuilder.setCollection(timeSeriesRequest.getCollectionName());
    requestBuilder.setStartTimeInclusive(start);
    requestBuilder.setEndTimeExclusive(end);
    requestBuilder.setFilterSet(timeSeriesRequest.getFilterSet());
    requestBuilder.addGroupBy(timeSeriesRequest.getGroupByDimensions());
    requestBuilder.setGroupByTimeGranularity(timeSeriesRequest.getAggregationTimeGranularity());
    List<MetricExpression> metricExpressions = timeSeriesRequest.getMetricExpressions();
    List<MetricFunction> metricFunctionsFromExpressions = Utils.computeMetricFunctionsFromExpressions(metricExpressions);
    requestBuilder.setMetricFunctions(metricFunctionsFromExpressions);
    return requestBuilder.build(requestReference);
}
Also used : ThirdEyeRequestBuilder(com.linkedin.thirdeye.client.ThirdEyeRequest.ThirdEyeRequestBuilder) MetricFunction(com.linkedin.thirdeye.client.MetricFunction) MetricExpression(com.linkedin.thirdeye.client.MetricExpression)

Aggregations

ThirdEyeRequestBuilder (com.linkedin.thirdeye.client.ThirdEyeRequest.ThirdEyeRequestBuilder)9 ThirdEyeRequest (com.linkedin.thirdeye.client.ThirdEyeRequest)5 MetricFunction (com.linkedin.thirdeye.client.MetricFunction)4 ArrayList (java.util.ArrayList)4 MetricExpression (com.linkedin.thirdeye.client.MetricExpression)3 DateTime (org.joda.time.DateTime)2 Range (com.google.common.collect.Range)1 TimeGranularity (com.linkedin.thirdeye.api.TimeGranularity)1 ThirdEyeResponse (com.linkedin.thirdeye.client.ThirdEyeResponse)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Future (java.util.concurrent.Future)1