@Test public void shouldComputeMin() { AggregationResult result = new AggregationResult(Operator.MAX); aggregator.accept(getRow("toto", "5123.4"), result); aggregator.accept(getRow("tata", "-50.2"), result); aggregator.accept(getRow("toto", "786.884"), result); aggregator.accept(getRow("tata", "-0.2"), result); aggregator.accept(getRow("toto", "41843.453"), result); aggregator.accept(getRow("toto", "0"), result); aggregator.accept(getRow("tata", "20"), result); aggregator.accept(getRow("toto", "-1"), result); aggregator.accept(getRow("toto", "8.87"), result); aggregator.accept(getRow("tata", "875"), result); aggregator.accept(getRow("toto", "-0.01"), result); aggregator.accept(getRow("tutu", "sdfs"), result); Assert.assertEquals(result.get("toto").getValue(), 41843.453, 0); Assert.assertEquals(result.get("tata").getValue(), 875, 0); Assert.assertNull(result.get("sdfs")); }
@Override public void accept(DataSetRow row, AggregationResult result) { final String maxKey = row.get(groupBy); if (StringUtils.isEmpty(maxKey)) { return; } double value; try { value = Double.parseDouble(row.get(columnId)); } catch (NumberFormatException e) { return; } if (!result.contains(maxKey)) { result.put(maxKey, new NumberContext(value)); } NumberContext context = (NumberContext) result.get(maxKey); if (value > context.getValue()) { context.setValue(value); } }
Max extends AbstractAggregator implements Aggregator { @Override public void accept(DataSetRow row, AggregationResult result) { final String maxKey = row.get(groupBy); if (StringUtils.isEmpty(maxKey)) { return; } double value; try { value = Double.parseDouble(row.get(columnId)); } catch (NumberFormatException e) { return; } if (!result.contains(maxKey)) { result.put(maxKey, new NumberContext(value)); } NumberContext context = (NumberContext) result.get(maxKey); if (value > context.getValue()) { context.setValue(value); } } }
Max extends AbstractAggregator implements Aggregator { @Override public void accept(DataSetRow row, AggregationResult result) { final String maxKey = row.get(groupBy); if (StringUtils.isEmpty(maxKey)) { return; } double value; try { value = Double.parseDouble(row.get(columnId)); } catch (NumberFormatException e) { return; } if (!result.contains(maxKey)) { result.put(maxKey, new NumberContext(value)); } NumberContext context = (NumberContext) result.get(maxKey); if (value > context.getValue()) { context.setValue(value); } } Max(String groupBy, String columnId); }
Max extends AbstractAggregator implements Aggregator { @Override public void accept(DataSetRow row, AggregationResult result) { final String maxKey = row.get(groupBy); if (StringUtils.isEmpty(maxKey)) { return; } double value; try { value = Double.parseDouble(row.get(columnId)); } catch (NumberFormatException e) { return; } if (!result.contains(maxKey)) { result.put(maxKey, new NumberContext(value)); } NumberContext context = (NumberContext) result.get(maxKey); if (value > context.getValue()) { context.setValue(value); } } Max(String groupBy, String columnId); @Override void accept(DataSetRow row, AggregationResult result); @Override void normalize(AggregationResult result); }
Max extends AbstractAggregator implements Aggregator { @Override public void accept(DataSetRow row, AggregationResult result) { final String maxKey = row.get(groupBy); if (StringUtils.isEmpty(maxKey)) { return; } double value; try { value = Double.parseDouble(row.get(columnId)); } catch (NumberFormatException e) { return; } if (!result.contains(maxKey)) { result.put(maxKey, new NumberContext(value)); } NumberContext context = (NumberContext) result.get(maxKey); if (value > context.getValue()) { context.setValue(value); } } Max(String groupBy, String columnId); @Override void accept(DataSetRow row, AggregationResult result); @Override void normalize(AggregationResult result);  }