@Override protected ByteArray getPrimaryId(final InternalDataStatistics<?, ?, ?> persistedObject) { return getPrimaryId(persistedObject.getType(), persistedObject.getExtendedId()); }
/** * Adds/Replaces a stats object for the given adapter <br> Supports object replacement. * * @param statsObj - data stats object to be tracked by adding or replacement * @param visibilityHandler - type of visibility required to access the stats object */ public void addStats( final InternalDataStatistics<SimpleFeature, ?, ?> statsObj, final String fieldName) { int replaceStat = 0; // Go through stats list managed by this manager and look for a match for (final InternalDataStatistics<SimpleFeature, ?, ?> currentStat : statsObjList) { if (currentStat.getType().equals(statsObj.getType()) && currentStat.getExtendedId().equals(statsObj.getExtendedId())) { // If a match was found for an existing stat object in list, // remove it now and replace it later. statsObjList.remove(replaceStat); break; } replaceStat++; // Not found, check next stat object } statsObjList.add(statsObj); statisticsIdToFieldNameMap.put( new StatisticsId(statsObj.getType(), statsObj.getExtendedId()), fieldName); }
@Override public void setStatistics(final InternalDataStatistics<?, ?, ?> statistics) { removeStatistics(statistics.getAdapterId(), statistics.getType()); addObject(statistics); }
@Override public <R> Statistics<R>[] queryStatistics(final StatisticsQuery<R> query) { try (CloseableIterator<InternalDataStatistics<?, R, ?>> it = internalQueryStatistics(query)) { return Streams.stream(it).map( s -> new StatisticsImpl<>( s.getResult(), s.getType(), s.getExtendedId(), internalAdapterStore.getTypeName(s.getAdapterId()))).toArray( size -> new Statistics[size]); } }
/** * 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 GeoWaveMetadata next() { InternalDataStatistics<?, ?, ?> currentStatistics = nextVal; nextVal = null; while (it.hasNext()) { final GeoWaveMetadata row = it.next(); final InternalDataStatistics<?, ?, ?> statEntry = entryToValue(row); if (currentStatistics == null) { currentStatistics = statEntry; } else { if (statEntry.getType().equals(currentStatistics.getType()) && statEntry.getAdapterId().equals(currentStatistics.getAdapterId()) && statEntry.getExtendedId().equals(currentStatistics.getExtendedId())) { currentStatistics.merge(statEntry); } else { nextVal = statEntry; break; } } } return statsToMetadata(currentStatistics); }
@Override @SuppressWarnings("unchecked") public Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> getDataStatistics() { final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> stats = new HashMap<>(); final GeotoolsFeatureDataAdapter adapter = components.getAdapter(); final short internalAdapterId = components.getGTstore().getInternalAdapterStore().getAdapterId(adapter.getTypeName()); try (CloseableIterator<InternalDataStatistics<?, ?, ?>> it = components.getStatsStore().getDataStatistics(internalAdapterId, composeAuthorizations())) { while (it.hasNext()) { final InternalDataStatistics<?, ?, ?> stat = it.next(); stats.put( new StatisticsId(stat.getType(), stat.getExtendedId()), (InternalDataStatistics<SimpleFeature, ?, ?>) stat); } } catch (final Exception e) { GeoWaveTransactionManagement.LOGGER.error("Failed to access statistics from data store", e); } return stats; } }
builder.append(String.format("%1$-20s", stats.getType().getString())); builder.append("] "); builder.append(stats.toString());
protected GeoWaveMetadata statsToMetadata(final InternalDataStatistics<?, ?, ?> stats) { return new GeoWaveMetadata( DataStatisticsStoreImpl.getPrimaryId(stats.getType(), stats.getExtendedId()).getBytes(), ByteArrayUtils.shortToByteArray(stats.getAdapterId()), stats.getVisibility(), PersistenceUtils.toBinary(stats)); }
final StatisticsId statisticsId) { for (final InternalDataStatistics<SimpleFeature, ?, ?> statObj : statsObjList) { if (statObj.getType().equals(statisticsId.getType()) && statObj.getExtendedId().equals(statisticsId.getExtendedId())) {