@Override public void entryIngested(final T entry, final GeoWaveRow... kvs) { if (!isSet()) { count = 0; } count += 1; }
@Override public int getCount() { if (query.getFilter().equals(Filter.INCLUDE)) { // GEOWAVE-60 optimization final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap = reader.getTransaction().getDataStatistics(); StatisticsId id = CountDataStatistics.STATS_TYPE.newBuilder().build().getId(); if (statsMap.containsKey(id)) { final CountDataStatistics stats = (CountDataStatistics) statsMap.get(id); if ((stats != null) && stats.isSet()) { return (int) stats.getCount(); } } } else if (query.getFilter().equals(Filter.EXCLUDE)) { return 0; } QueryConstraints constraints; try { constraints = getQueryConstraints(); return (int) reader.getCountInternal( constraints.jtsBounds, constraints.timeBounds, getFilter(query), constraints.limit); } catch (TransformException | FactoryException e) { LOGGER.warn("Unable to transform geometry, can't get count", e); } // fallback return 0; }
return new CountDataStatistics<>(); + statisticsId.getExtendedId() + "', using count statistic."); return new CountDataStatistics<>();
@SuppressWarnings("rawtypes") @Override protected int getCountInternal(final Query query) throws IOException { final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> stats = new GeoWaveEmptyTransaction(components).getDataStatistics(); final InternalDataStatistics<SimpleFeature, ?, ?> countStats = stats.get(VectorStatisticsQueryBuilder.newBuilder().factory().count().build().getId()); if ((countStats != null) && query.getFilter().equals(Filter.INCLUDE)) { return (int) ((CountDataStatistics) countStats).getCount(); } else { try (GeoWaveFeatureReader reader = new GeoWaveFeatureReader(query, new GeoWaveEmptyTransaction(components), components)) { return (int) reader.getCount(); } } }
@Override public InternalDataStatistics<GridCoverage, ?, ?> createDataStatistics( final StatisticsId statisticsId) { InternalDataStatistics<GridCoverage, ?, ?> retVal = null; if (OverviewStatistics.STATS_TYPE.equals(statisticsId.getType())) { retVal = new OverviewStatistics(); } else if (BoundingBoxDataStatistics.STATS_TYPE.equals(statisticsId.getType())) { retVal = new RasterBoundingBoxStatistics(); } else if (RasterFootprintStatistics.STATS_TYPE.equals(statisticsId.getType())) { retVal = new RasterFootprintStatistics(); } else if (HistogramStatistics.STATS_TYPE.equals(statisticsId.getType()) && (histogramConfig != null)) { retVal = new HistogramStatistics(histogramConfig); } else { // HP Fortify "Log Forging" false positive // What Fortify considers "user input" comes only // from users with OS-level access anyway LOGGER.warn( "Unrecognized statistics type " + statisticsId.getType().getString() + " using count statistic"); retVal = new CountDataStatistics<>(); } return retVal; }
@Override public void merge(final Mergeable statistics) { if (!isSet()) { count = 0; } if ((statistics != null) && (statistics instanceof CountDataStatistics)) { @SuppressWarnings("unchecked") final CountDataStatistics<T> cStats = (CountDataStatistics<T>) statistics; if (cStats.isSet()) { count = count + cStats.count; } } }
@Override public void entryDeleted(final T entry, final GeoWaveRow... kv) { if (kv.length > 0) { if (ids.add(new ByteArray(kv[0].getDataId()))) { if (!isSet()) { count = 0; } count -= 1; } } }