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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations