return (prefixEntity == null || prefixEntity.isEmpty()) ? null : prefixEntity.get(0);
}
private void deleteTableEntries(MetricsScope scope, String contextPrefix,
String metricPrefix, String tag) throws OperationException {
TimeSeriesTable ts1Table = metricsTableCaches.get(scope).getUnchecked(1);
AggregatesTable aggTable = aggregatesTables.get().get(scope);
if (contextPrefix == null && tag == null && metricPrefix == null) {
ts1Table.clear();
aggTable.clear();
} else if (tag == null) {
ts1Table.delete(contextPrefix, metricPrefix);
aggTable.delete(contextPrefix, metricPrefix);
} else {
long now = TimeUnit.SECONDS.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
MetricsScanQuery scanQuery = new MetricsScanQueryBuilder()
.setContext(contextPrefix)
.setMetric(metricPrefix)
.allowEmptyMetric()
.setRunId("0")
.setTag(tag)
.build(now - tsRetentionSeconds, now + 10);
ts1Table.delete(scanQuery);
aggTable.delete(contextPrefix, metricPrefix, "0", tag);
}
}