@Override public Object combine(Object lhs, Object rhs) { return delegate.combine(lhs, rhs); }
@Override public Object combine(Object lhs, Object rhs) { return delegate.combine(lhs, rhs); }
for (AggregatorFactory factory : aggregations) { final String metricName = factory.getName(); retVal.put(metricName, factory.combine(arg1Val.getMetric(metricName), arg2Val.getMetric(metricName)));
@Override public Row apply(final Row arg1, final Row arg2) { if (arg1 == null) { return arg2; } else if (arg2 == null) { return arg1; } final Map<String, Object> newMap = Maps.newHashMapWithExpectedSize( query.getDimensions().size() + query.getAggregatorSpecs().size() ); // Add dimensions for (DimensionSpec dimension : query.getDimensions()) { newMap.put(dimension.getOutputName(), arg1.getRaw(dimension.getOutputName())); } // Add aggregations for (AggregatorFactory aggregatorFactory : query.getAggregatorSpecs()) { newMap.put( aggregatorFactory.getName(), aggregatorFactory.combine( arg1.getRaw(aggregatorFactory.getName()), arg2.getRaw(aggregatorFactory.getName()) ) ); } return new MapBasedRow(adjustTimestamp(arg1), newMap); }
@Test public void testCombine() { SerializablePairLongString pair1 = new SerializablePairLongString(1467225000L, "AAAA"); SerializablePairLongString pair2 = new SerializablePairLongString(1467240000L, "BBBB"); Assert.assertEquals(pair2, stringLastAggFactory.combine(pair1, pair2)); }
@Test public void testCombine() { SerializablePairLongString pair1 = new SerializablePairLongString(1467225000L, "AAAA"); SerializablePairLongString pair2 = new SerializablePairLongString(1467240000L, "BBBB"); Assert.assertEquals(pair2, stringLastAggFactory.combine(pair1, pair2)); }
grandTotals[i] = value; } else { grandTotals[i] = aggregatorFactory.combine(grandTotals[i], value);
@Override public Result<TimeseriesResultValue> apply(Result<TimeseriesResultValue> arg1, Result<TimeseriesResultValue> arg2) { if (arg1 == null) { return arg2; } if (arg2 == null) { return arg1; } TimeseriesResultValue arg1Val = arg1.getValue(); TimeseriesResultValue arg2Val = arg2.getValue(); Map<String, Object> retVal = new LinkedHashMap<String, Object>(); for (AggregatorFactory factory : aggregations) { final String metricName = factory.getName(); retVal.put(metricName, factory.combine(arg1Val.getMetric(metricName), arg2Val.getMetric(metricName))); } return (gran instanceof AllGranularity) ? new Result<TimeseriesResultValue>( arg1.getTimestamp(), new TimeseriesResultValue(retVal) ) : new Result<TimeseriesResultValue>( gran.bucketStart(arg1.getTimestamp()), new TimeseriesResultValue(retVal) ); }
@Override public Object combine(Object lhs, Object rhs) { return delegate.combine(lhs, rhs); }
@Override public Object combine(Object lhs, Object rhs) { return delegate.combine(lhs, rhs); }
for (AggregatorFactory factory : aggregations) { final String metricName = factory.getName(); retVal.put(metricName, factory.combine(arg1Val.getMetric(metricName), arg2Val.getMetric(metricName)));
@Override public Row apply(final Row arg1, final Row arg2) { if (arg1 == null) { return arg2; } else if (arg2 == null) { return arg1; } final Map<String, Object> newMap = Maps.newHashMapWithExpectedSize( query.getDimensions().size() + query.getAggregatorSpecs().size() ); // Add dimensions for (DimensionSpec dimension : query.getDimensions()) { newMap.put(dimension.getOutputName(), arg1.getRaw(dimension.getOutputName())); } // Add aggregations for (AggregatorFactory aggregatorFactory : query.getAggregatorSpecs()) { newMap.put( aggregatorFactory.getName(), aggregatorFactory.combine( arg1.getRaw(aggregatorFactory.getName()), arg2.getRaw(aggregatorFactory.getName()) ) ); } return new MapBasedRow(adjustTimestamp(arg1), newMap); }
grandTotals[i] = value; } else { grandTotals[i] = aggregatorFactory.combine(grandTotals[i], value);
@Override public Result<TimeseriesResultValue> apply(Result<TimeseriesResultValue> arg1, Result<TimeseriesResultValue> arg2) { if (arg1 == null) { return arg2; } if (arg2 == null) { return arg1; } TimeseriesResultValue arg1Val = arg1.getValue(); TimeseriesResultValue arg2Val = arg2.getValue(); Map<String, Object> retVal = new LinkedHashMap<String, Object>(); for (AggregatorFactory factory : aggregations) { final String metricName = factory.getName(); retVal.put(metricName, factory.combine(arg1Val.getMetric(metricName), arg2Val.getMetric(metricName))); } return (gran instanceof AllGranularity) ? new Result<TimeseriesResultValue>( arg1.getTimestamp(), new TimeseriesResultValue(retVal) ) : new Result<TimeseriesResultValue>( gran.bucketStart(arg1.getTimestamp()), new TimeseriesResultValue(retVal) ); }