@Test public void testCountVisitorDelegation() throws SchemaException, IOException { FeatureVisitor visitor = new CountVisitor(); assertOptimalVisit(visitor); }
/** * Calculate count (using FeatureCalc) - only one parameter is used. * * @param collection collection to calculate the count * @return An object containing the count value of the attributes * @throws IllegalFilterException * @throws IOException */ static CalcResult calculateCount(SimpleFeatureCollection collection) throws IllegalFilterException, IOException { CountVisitor countVisitor = new CountVisitor(); collection.accepts(countVisitor, null); return countVisitor.getResult(); }
/** Returns the count of the features for a particular feature type / table. */ protected int getCount(SimpleFeatureType featureType, Query query, Connection cx) throws IOException { CountVisitor v = new CountVisitor(); getAggregateValue(v, featureType, query, cx); return v.getCount(); }
public void testBadMerge() throws IllegalFilterException, IOException { // count + max = boom! CountVisitor countVisitor = new CountVisitor(); countVisitor.setValue(8); CalcResult countResult = countVisitor.getResult(); MaxVisitor maxVisitor = new MaxVisitor((Expression) null); maxVisitor.setValue(new Double(99)); CalcResult maxResult = maxVisitor.getResult(); try { CalcResult boomResult = maxResult.merge(countResult); fail(); // merge should throw an exception } catch (Exception e) { assertEquals("Parameter is not a compatible type", e.getMessage()); } }
public void testCount() throws IllegalFilterException, IOException { CountVisitor countVisitor = new CountVisitor(); fc.accepts(countVisitor, null); CountVisitor countVisitor2 = new CountVisitor(); fc2.accepts(countVisitor2, null); int value1 = countVisitor.getResult().toInt(); assertEquals(3, value1); int value2 = countVisitor2.getResult().toInt(); assertEquals(2, value2); CalcResult countResult1 = countVisitor.getResult(); CalcResult countResult2 = countVisitor2.getResult(); CalcResult countResult3 = countResult1.merge(countResult2); assertEquals(5, countResult3.toInt()); countVisitor.setValue(20); CalcResult countResult4 = countVisitor.getResult(); assertEquals(20, countResult4.toInt()); assertEquals(25, countResult5.toInt()); countVisitor.reset(); empty.accepts(countVisitor, null); assertEquals(CalcResult.NULL_RESULT, countVisitor.getResult()); assertSame(countResult2, countVisitor.getResult().merge(countResult2)); assertSame(countResult2, countResult2.merge(countVisitor.getResult()));
public int method(){ CountVisitor counter; Tree t; t.accept(counter); return counter.getCount(); }
countCalc.setValue(((Number)count).intValue()); // use the optimized result isOptimized = true; progress.complete();
@Override public FeatureCalc create(Expression aggregateAttribute) { return new CountVisitor(); }
public void testCountSumMerge() throws IllegalFilterException, IOException { CountVisitor countVisitor = new CountVisitor(); fc2.accepts(countVisitor, null); // count = 2 SumVisitor sumVisitor = new SumVisitor(3, ft2); fc2.accepts(sumVisitor, null); // sum = 7.5 CalcResult countResult = countVisitor.getResult(); CalcResult sumResult = sumVisitor.getResult(); CalcResult averageResult1 = countResult.merge(sumResult); CalcResult averageResult2 = sumResult.merge(countResult); // both average results were correct? assertEquals((double) 3.75, averageResult1.toDouble(), 0); assertEquals((double) 3.75, averageResult2.toDouble(), 0); // neither sum nor count was destroyed? assertEquals(2, countResult.toInt()); assertEquals((double) 7.5, sumResult.toDouble(), 0); }
/** * Returns the count of the features for a particular feature type / table. */ protected int getCount(SimpleFeatureType featureType, Query query, Connection cx) throws IOException { CountVisitor v = new CountVisitor(); getAggregateValue(v,featureType,query,cx); return v.getCount(); }
public void testCountVisitorDelegation() throws Exception { FeatureVisitor visitor = new CountVisitor(); assertOptimalVisit(visitor); }
/** * Calculate count (using FeatureCalc) - only one parameter is used. * * @param collection * collection to calculate the count * * @return An object containing the count value of the attributes * * @throws IllegalFilterException * @throws IOException */ static CalcResult calculateCount(SimpleFeatureCollection collection) throws IllegalFilterException, IOException { CountVisitor countVisitor = new CountVisitor(); collection.accepts(countVisitor, null); return countVisitor.getResult(); }
public void testCountVisitorDelegation() throws SchemaException, IOException { FeatureVisitor visitor = new CountVisitor(); assertOptimalVisit(visitor); }
/** * Calculate count (using FeatureCalc) - only one parameter is used. * * @param collection * collection to calculate the count * * @return An object containing the count value of the attributes * * @throws IllegalFilterException * @throws IOException */ public static CalcResult calculateCount(FeatureCollection collection) throws IllegalFilterException, IOException { CountVisitor countVisitor = new CountVisitor(); collection.accepts(countVisitor, null); return countVisitor.getResult(); }
@Test public void testCountVisitorDelegation() throws SchemaException, IOException { FeatureVisitor visitor = new CountVisitor(); assertOptimalVisit(visitor); }
calc = new AverageVisitor(attIndex, features.getSchema()); } else if (function == AggregationFunction.Count) { calc = new CountVisitor(); } else if (function == AggregationFunction.Max) { calc = new MaxVisitor(attIndex, features.getSchema());
@Test public void testCountVisitorDelegation() { FeatureVisitor visitor = new CountVisitor(); assertOptimalVisit(visitor, countVisitorCollections); }
@Test public void testCountVisitorDelegation() throws SchemaException, IOException { FeatureVisitor visitor = new CountVisitor(); WrapperPolicy policy = WrapperPolicy.hide( new VectorAccessLimits(CatalogMode.HIDE, null, null, null, null)); assertOptimalVisit(visitor, policy); }
calc = new AverageVisitor(attIndex, features.getSchema()); } else if (function == AggregationFunction.Count) { calc = new CountVisitor(); } else if (function == AggregationFunction.Max) { calc = new MaxVisitor(attIndex, features.getSchema());