@Override public BaseStatisticsQueryBuilder<Long> count() { return CountDataStatistics.STATS_TYPE.newBuilder(); }
private Histogram getHistogram(final String coverageName, final double resX, final double resY) throws IOException { final Map<Resolution, Histogram> histograms = geowaveDataStore.aggregateStatistics( HistogramStatistics.STATS_TYPE.newBuilder().setAuthorizations( authorizationSPI.getAuthorizations()).dataType(coverageName).build()); if (histograms != null) { return histograms.get(new Resolution(new double[] {resX, resY})); } else { LOGGER.warn("Cannot find histogram for coverage '" + coverageName + "'"); } return null; }
private void init() { int supportedStatsLength = 2; if (histogramConfig != null) { supportedStatsLength++; } supportedStats = new StatisticsId[supportedStatsLength]; supportedStats[0] = OverviewStatistics.STATS_TYPE.newBuilder().build().getId(); supportedStats[1] = BoundingBoxDataStatistics.STATS_TYPE.newBuilder().build().getId(); if (histogramConfig != null) { supportedStats[2] = HistogramStatistics.STATS_TYPE.newBuilder().build().getId(); } visibilityHandler = new DefaultFieldStatisticVisibility<>(); }
/** * Get an array of stats object IDs for the Stats Manager * * @return Array of stats object IDs as 'ByteArrayId' */ public StatisticsId[] getSupportedStatistics() { // Why are we adding a CountDataStatistics?? final StatisticsId[] statObjIds = new StatisticsId[statsObjList.size() + 1]; int i = 0; for (final InternalDataStatistics<SimpleFeature, ?, ?> statObj : statsObjList) { statObjIds[i++] = new StatisticsId(statObj.getType(), statObj.getExtendedId()); } statObjIds[i] = CountDataStatistics.STATS_TYPE.newBuilder().build().getId(); return statObjIds; } }
@Override public double[][] getResolutionLevels(final String coverageName) throws IOException { final Resolution[] resolutions = geowaveDataStore.aggregateStatistics( OverviewStatistics.STATS_TYPE.newBuilder().setAuthorizations( authorizationSPI.getAuthorizations()).dataType(coverageName).build()); if (resolutions == null) { LOGGER.warn("Cannot find resolutions for coverage '" + coverageName + "'"); return null; } final double[][] retVal = new double[resolutions.length][]; int i = 0; for (final Resolution res : resolutions) { retVal[i++] = res.getResolutionPerDimension(); } return retVal; }
@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; }