Search in sources :

Example 6 with MetricFunction

use of com.linkedin.thirdeye.client.MetricFunction in project pinot by linkedin.

the class TimeOnTimeTest method generateGroupByTimeAndDimension.

// CONTRIBUTOR
private static TimeOnTimeComparisonRequest generateGroupByTimeAndDimension() {
    TimeOnTimeComparisonRequest comparisonRequest = new TimeOnTimeComparisonRequest();
    String collection = "thirdeyeAbook";
    comparisonRequest.setCollectionName(collection);
    comparisonRequest.setBaselineStart(new DateTime(2016, 4, 1, 00, 00));
    comparisonRequest.setBaselineEnd(new DateTime(2016, 4, 2, 00, 00));
    comparisonRequest.setCurrentStart(new DateTime(2016, 4, 8, 00, 00));
    comparisonRequest.setCurrentEnd(new DateTime(2016, 4, 9, 00, 00));
    comparisonRequest.setGroupByDimensions(Lists.newArrayList("browserName", "contactsOrigin", "deviceName", "continent", "countryCode", "environment", "locale", "osName", "pageKey", "source", "sourceApp"));
    comparisonRequest.setGroupByDimensions(Lists.newArrayList("environment"));
    List<MetricFunction> metricFunctions = new ArrayList<>();
    metricFunctions.add(new MetricFunction(MetricAggFunction.SUM, "__COUNT"));
    comparisonRequest.setMetricExpressions(Utils.convertToMetricExpressions(metricFunctions));
    comparisonRequest.setAggregationTimeGranularity(new TimeGranularity(1, TimeUnit.HOURS));
    return comparisonRequest;
}
Also used : MetricFunction(com.linkedin.thirdeye.client.MetricFunction) ArrayList(java.util.ArrayList) TimeGranularity(com.linkedin.thirdeye.api.TimeGranularity) DateTime(org.joda.time.DateTime)

Example 7 with MetricFunction

use of com.linkedin.thirdeye.client.MetricFunction in project pinot by linkedin.

the class TimeOnTimeTest method generateGroupByTimeRequest.

// TABULAR
private static TimeOnTimeComparisonRequest generateGroupByTimeRequest() {
    TimeOnTimeComparisonRequest comparisonRequest = new TimeOnTimeComparisonRequest();
    String collection = "thirdeyeAbook";
    comparisonRequest.setCollectionName(collection);
    comparisonRequest.setBaselineStart(new DateTime(2016, 4, 1, 00, 00));
    comparisonRequest.setBaselineEnd(new DateTime(2016, 4, 2, 00, 00));
    comparisonRequest.setCurrentStart(new DateTime(2016, 4, 8, 00, 00));
    comparisonRequest.setCurrentEnd(new DateTime(2016, 4, 9, 00, 00));
    List<MetricFunction> metricFunctions = new ArrayList<>();
    metricFunctions.add(new MetricFunction(MetricAggFunction.SUM, "__COUNT"));
    List<MetricExpression> metricExpressions = Utils.convertToMetricExpressions(metricFunctions);
    metricExpressions.add(new MetricExpression("submit_rate", "submits/impressions"));
    comparisonRequest.setMetricExpressions(metricExpressions);
    comparisonRequest.setAggregationTimeGranularity(new TimeGranularity(1, TimeUnit.HOURS));
    return comparisonRequest;
}
Also used : MetricFunction(com.linkedin.thirdeye.client.MetricFunction) ArrayList(java.util.ArrayList) TimeGranularity(com.linkedin.thirdeye.api.TimeGranularity) MetricExpression(com.linkedin.thirdeye.client.MetricExpression) DateTime(org.joda.time.DateTime)

Example 8 with MetricFunction

use of com.linkedin.thirdeye.client.MetricFunction in project pinot by linkedin.

the class TimeOnTimeTest method generateGroupByDimensionRequest.

// HEATMAP
private static TimeOnTimeComparisonRequest generateGroupByDimensionRequest() {
    TimeOnTimeComparisonRequest comparisonRequest = new TimeOnTimeComparisonRequest();
    String collection = "thirdeyeAbook";
    comparisonRequest.setCollectionName(collection);
    comparisonRequest.setBaselineStart(new DateTime(2016, 4, 1, 00, 00));
    comparisonRequest.setBaselineEnd(new DateTime(2016, 4, 1, 01, 00));
    comparisonRequest.setCurrentStart(new DateTime(2016, 4, 8, 00, 00));
    comparisonRequest.setCurrentEnd(new DateTime(2016, 4, 8, 01, 00));
    comparisonRequest.setGroupByDimensions(Lists.newArrayList("browserName", "contactsOrigin", "deviceName", "continent", "countryCode", "environment", "locale", "osName", "pageKey", "source", "sourceApp"));
    List<MetricFunction> metricFunctions = new ArrayList<>();
    metricFunctions.add(new MetricFunction(MetricAggFunction.SUM, "__COUNT"));
    comparisonRequest.setMetricExpressions(Utils.convertToMetricExpressions(metricFunctions));
    comparisonRequest.setAggregationTimeGranularity(null);
    return comparisonRequest;
}
Also used : MetricFunction(com.linkedin.thirdeye.client.MetricFunction) ArrayList(java.util.ArrayList) DateTime(org.joda.time.DateTime)

Example 9 with MetricFunction

use of com.linkedin.thirdeye.client.MetricFunction in project pinot by linkedin.

the class TestTimeSeriesResponseUtils method createMapProviderArgs.

/**
   * return type: String testName, TimeSeriesResponse, List<String> dimensions, Map<DimensionKey,
   * MetricTimeSeries>.
   */
public Object[] createMapProviderArgs(String testName, boolean groupByDimension, boolean groupTimeSeriesMetricsIntoRow) {
    List<String> dimensions = Arrays.asList("dim1", "dim2", "dim3", "all");
    // appended to each
    List<String> dimensionValueSuffixes = Arrays.asList("_a", "_b", "_c");
    // dimension
    List<MetricFunction> metricFunctions = createSumFunctions("m1", "m2", "m3");
    ConversionDataGenerator dataGenerator = new ConversionDataGenerator(dimensions, metricFunctions);
    for (long hoursSinceEpoch = 0; hoursSinceEpoch < 50; hoursSinceEpoch++) {
        DateTime start = new DateTime(hoursSinceEpoch);
        DateTime end = start.plusHours(1);
        for (String dimension : (groupByDimension ? dimensions : Collections.<String>singleton("all"))) {
            for (String dimensionValueSuffix : (groupByDimension ? dimensionValueSuffixes : Collections.<String>singleton("all"))) {
                String dimensionValue;
                if (groupByDimension) {
                    dimensionValue = dimension + dimensionValueSuffix;
                } else {
                    dimensionValue = "all";
                }
                List<TimeSeriesMetric> timeSeriesMetrics = new ArrayList<>();
                for (MetricFunction metricFunction : metricFunctions) {
                    Double value = (double) (Objects.hash(start, end, dimension, dimensionValue, metricFunction.toString()) % // doesn't matter, the test is that values are
                    1000);
                    // consistent between data
                    // structures.
                    TimeSeriesMetric timeSeriesMetric = new TimeSeriesMetric(metricFunction.getMetricName(), value);
                    timeSeriesMetrics.add(timeSeriesMetric);
                }
                if (groupTimeSeriesMetricsIntoRow) {
                    // add them all at once
                    dataGenerator.addEntry(Arrays.asList(dimension), Arrays.asList(dimensionValue), start, end, timeSeriesMetrics.toArray(new TimeSeriesMetric[timeSeriesMetrics.size()]));
                } else {
                    // add them individually (one metric per row)
                    for (TimeSeriesMetric timeSeriesMetric : timeSeriesMetrics) {
                        dataGenerator.addEntry(Arrays.asList(dimension), Arrays.asList(dimensionValue), start, end, timeSeriesMetric);
                    }
                }
            }
        }
    }
    Object[] dimensionGroupByArgs = new Object[] { testName, dataGenerator.getResponse(), dimensions, dataGenerator.getMap() };
    return dimensionGroupByArgs;
}
Also used : ArrayList(java.util.ArrayList) DateTime(org.joda.time.DateTime) MetricFunction(com.linkedin.thirdeye.client.MetricFunction) TimeSeriesMetric(com.linkedin.thirdeye.client.timeseries.TimeSeriesRow.TimeSeriesMetric)

Example 10 with MetricFunction

use of com.linkedin.thirdeye.client.MetricFunction in project pinot by linkedin.

the class TimeSeriesTest method generateGroupByTimeAndDimension.

private static TimeSeriesRequest generateGroupByTimeAndDimension() {
    TimeSeriesRequest timeSeriesRequest = new TimeSeriesRequest();
    timeSeriesRequest.setCollectionName(THIRDEYE_ABOOK);
    timeSeriesRequest.setStart(START);
    timeSeriesRequest.setEnd(START.plusHours(3));
    timeSeriesRequest.setGroupByDimensions(ABOOK_DIMENSIONS);
    List<MetricFunction> metricFunctions = new ArrayList<>();
    metricFunctions.add(DEFAULT_METRIC_FUNCTION);
    List<MetricExpression> metricExpressions = Utils.convertToMetricExpressions(metricFunctions);
    timeSeriesRequest.setMetricExpressions(metricExpressions);
    timeSeriesRequest.setAggregationTimeGranularity(new TimeGranularity(1, TimeUnit.HOURS));
    return timeSeriesRequest;
}
Also used : MetricFunction(com.linkedin.thirdeye.client.MetricFunction) ArrayList(java.util.ArrayList) TimeGranularity(com.linkedin.thirdeye.api.TimeGranularity) MetricExpression(com.linkedin.thirdeye.client.MetricExpression)

Aggregations

MetricFunction (com.linkedin.thirdeye.client.MetricFunction)20 ArrayList (java.util.ArrayList)13 MetricExpression (com.linkedin.thirdeye.client.MetricExpression)8 HashMap (java.util.HashMap)5 TimeGranularity (com.linkedin.thirdeye.api.TimeGranularity)4 ThirdEyeRequestBuilder (com.linkedin.thirdeye.client.ThirdEyeRequest.ThirdEyeRequestBuilder)4 DateTime (org.joda.time.DateTime)4 ThirdEyeRequest (com.linkedin.thirdeye.client.ThirdEyeRequest)3 MetricConfigDTO (com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO)3 HashSet (java.util.HashSet)3 Metric (com.linkedin.thirdeye.client.comparison.Row.Metric)2 TimeSeriesMetric (com.linkedin.thirdeye.client.timeseries.TimeSeriesRow.TimeSeriesMetric)2 Map (java.util.Map)2 Future (java.util.concurrent.Future)2 ResultSet (com.linkedin.pinot.client.ResultSet)1 ResultSetGroup (com.linkedin.pinot.client.ResultSetGroup)1 TimeSpec (com.linkedin.thirdeye.api.TimeSpec)1 ThirdEyeResponse (com.linkedin.thirdeye.client.ThirdEyeResponse)1 MetricDataset (com.linkedin.thirdeye.client.cache.MetricDataset)1 Row (com.linkedin.thirdeye.client.comparison.Row)1