@Test public void testMergingGroupByResultsWithNull() throws Exception { FeatureCollection featureCollectionA = featureCollection; FeatureCollection featureCollectionB = DataUtilities.collection( new SimpleFeature[] { SimpleFeatureBuilder.build( buildingType, new Object[] { 1, "SCHOOL_C", "SCHOOL", "NUCLEAR", 100.0, wktParser.read("POINT(-15 -15)") }, null), SimpleFeatureBuilder.build( buildingType, new Object[] { 1, "SCHOOL_C", "SCHOOL", "FUEL", 15.0, wktParser.read("POINT(-15 -15)") }, null), SimpleFeatureBuilder.build( buildingType, new Object[] { 2, "FABRIC_C", "FABRIC", "NUCLEAR", 250.0, wktParser.read("POINT(-25 -25)") }, null), SimpleFeatureBuilder.build( buildingType, new Object[] { 2, "FABRIC_C", "FABRIC", "WIND", 75.0, wktParser.read("POINT(-25 -25)") }, null), SimpleFeatureBuilder.build( buildingType, new Object[] { 2, "HOUSE_C", "HOUSE", "WIND", 10.0, wktParser.read("POINT(-35 -35)") }, null), SimpleFeatureBuilder.build( buildingType, new Object[] { 2, "HOUSE_C", "HOUSE", "DARK_MATTER", 850.0, wktParser.read("POINT(-35 -35)") }, null), SimpleFeatureBuilder.build( buildingType, new Object[] { 2, "THEATER_A", "THEATER", "WIND", 200.0, wktParser.read("POINT(-45 -45)") }, null), SimpleFeatureBuilder.build( buildingType, new Object[] { 13, "MALL_A", "MALL", "GRAVITY", null, wktParser.read("POINT(-45 -45)") }, null), SimpleFeatureBuilder.build( buildingType, new Object[] { 13, "MALL_B", "MALL", "GRAVITY", null, wktParser.read("POINT(-45 -45)") }, null) }); GroupByVisitor visitorA = executeVisitor( featureCollectionA, "energy_consumption", "Average", new String[] {"building_type"}); checkResults( visitorA.getResult(), new Object[][] { new Object[] {"SCHOOL", 30.0}, new Object[] {"FABRIC", 175.0}, new Object[] {"HOUSE", 5.0} }); GroupByVisitor visitorB = executeVisitor( featureCollectionB, "energy_consumption", "Average", new String[] {"building_type"}); checkResults( visitorB.getResult(), new Object[][] { new Object[] {"SCHOOL", 57.5}, new Object[] {"FABRIC", 162.5}, new Object[] {"HOUSE", 430.0}, new Object[] {"THEATER", 200.0}, new Object[] {"MALL", null} }); checkResults( visitorA.getResult().merge(visitorB.getResult()), new Object[][] { new Object[] {"SCHOOL", 36.875}, new Object[] {"FABRIC", 170.833}, new Object[] {"HOUSE", 217.5}, new Object[] {"THEATER", 200.0}, new Object[] {"MALL", null} }); }
@Override public CalcResult getResult() { Map<List<Object>, CalcResult> results = inMemoryGroupBy.visit(); GroupByResult result = new GroupByResult(results, aggregate, groupByAttributes); if (optimizationResult == CalcResult.NULL_RESULT) { return result; } return optimizationResult.merge(result); }
GroupByVisitor implements FeatureCalc, FeatureAttributeVisitor { @Override public CalcResult getResult() { Map<List<Object>, CalcResult> results = inMemoryGroupBy.visit(); GroupByResult result = new GroupByResult(results, aggregate, groupByAttributes); if (optimizationResult == CalcResult.NULL_RESULT) { return result; } return optimizationResult.merge(result); } }
GroupByVisitor implements FeatureCalc, FeatureAttributeVisitor { @Override public CalcResult getResult() { Map<List<Object>, CalcResult> results = inMemoryGroupBy.visit(); GroupByResult result = new GroupByResult(results, aggregate, groupByAttributes); if (optimizationResult == CalcResult.NULL_RESULT) { return result; } return optimizationResult.merge(result); } GroupByVisitor(
            Aggregate aggregateVisitor,
            Expression expression,
            List<Expression> groupByAttributes,
            ProgressListener progressListener); }
GroupByVisitor implements FeatureCalc, FeatureAttributeVisitor { @Override public CalcResult getResult() { Map<List<Object>, CalcResult> results = inMemoryGroupBy.visit(); GroupByResult result = new GroupByResult(results, aggregate, groupByAttributes); if (optimizationResult == CalcResult.NULL_RESULT) { return result; } return optimizationResult.merge(result); } GroupByVisitor(
            Aggregate aggregateVisitor,
            Expression expression,
            List<Expression> groupByAttributes,
            ProgressListener progressListener); boolean wasOptimized(); boolean wasVisited(); @Override CalcResult getResult(); @Override void visit(Feature feature); Expression getExpression(); FeatureVisitor getAggregateVisitor(); List<Expression> getGroupByAttributes(); void setValue(List<GroupByRawResult> value); @Override List<Expression> getExpressions(); @Override Optional<List<Class>> getResultType(List<Class> inputTypes); }
GroupByVisitor implements FeatureCalc, FeatureAttributeVisitor { @Override public CalcResult getResult() { Map<List<Object>, CalcResult> results = inMemoryGroupBy.visit(); GroupByResult result = new GroupByResult(results, aggregate, groupByAttributes); if (optimizationResult == CalcResult.NULL_RESULT) { return result; } return optimizationResult.merge(result); } GroupByVisitor(
            Aggregate aggregateVisitor,
            Expression expression,
            List<Expression> groupByAttributes,
            ProgressListener progressListener); boolean wasOptimized(); boolean wasVisited(); @Override CalcResult getResult(); @Override void visit(Feature feature); Expression getExpression(); FeatureVisitor getAggregateVisitor(); List<Expression> getGroupByAttributes(); void setValue(List<GroupByRawResult> value); @Override List<Expression> getExpressions(); @Override Optional<List<Class>> getResultType(List<Class> inputTypes);  }