diff --git a/core/query/src/main/java/datawave/core/query/logic/composite/CompositeQueryLogicTransformer.java b/core/query/src/main/java/datawave/core/query/logic/composite/CompositeQueryLogicTransformer.java index 893388b4d02..ecb1583f7da 100644 --- a/core/query/src/main/java/datawave/core/query/logic/composite/CompositeQueryLogicTransformer.java +++ b/core/query/src/main/java/datawave/core/query/logic/composite/CompositeQueryLogicTransformer.java @@ -9,11 +9,13 @@ import datawave.core.query.cachedresults.CacheableLogic; import datawave.core.query.logic.AbstractQueryLogicTransformer; import datawave.core.query.logic.QueryLogicTransformer; +import datawave.core.query.logic.WritesQueryMetrics; +import datawave.microservice.querymetric.BaseQueryMetric; import datawave.webservice.query.cachedresults.CacheableQueryRow; import datawave.webservice.query.exception.QueryException; import datawave.webservice.result.BaseQueryResponse; -public class CompositeQueryLogicTransformer extends AbstractQueryLogicTransformer implements CacheableLogic { +public class CompositeQueryLogicTransformer extends AbstractQueryLogicTransformer implements CacheableLogic, WritesQueryMetrics { protected static final Logger log = Logger.getLogger(CompositeQueryLogicTransformer.class); @@ -82,4 +84,103 @@ public BaseQueryResponse createResponse(List resultList) { return null; } + @Override + public boolean hasMetrics() { + for (QueryLogicTransformer d : delegates) { + if (d instanceof WritesQueryMetrics) { + if (((WritesQueryMetrics) d).hasMetrics()) { + return true; + } + } + } + return false; + } + + @Override + public void writeQueryMetrics(BaseQueryMetric metric) { + // if any timing details have been returned, add metrics + if (hasMetrics()) { + metric.setSourceCount(getSourceCount()); + metric.setNextCount(getNextCount()); + metric.setSeekCount(getSeekCount()); + metric.setYieldCount(getYieldCount()); + metric.setDocRanges(getDocRanges()); + metric.setFiRanges(getFiRanges()); + } + } + + @Override + public void resetMetrics() { + for (QueryLogicTransformer d : delegates) { + if (d instanceof WritesQueryMetrics) { + ((WritesQueryMetrics) d).resetMetrics(); + } + } + } + + @Override + public long getFiRanges() { + long total = 0; + for (QueryLogicTransformer d : delegates) { + if (d instanceof WritesQueryMetrics) { + total += ((WritesQueryMetrics) d).getFiRanges(); + } + } + return total; + } + + @Override + public long getDocRanges() { + long total = 0; + for (QueryLogicTransformer d : delegates) { + if (d instanceof WritesQueryMetrics) { + total += ((WritesQueryMetrics) d).getDocRanges(); + } + } + return total; + } + + @Override + public long getSourceCount() { + long total = 0; + for (QueryLogicTransformer d : delegates) { + if (d instanceof WritesQueryMetrics) { + total += ((WritesQueryMetrics) d).getSourceCount(); + } + } + return total; + } + + @Override + public long getSeekCount() { + long total = 0; + for (QueryLogicTransformer d : delegates) { + if (d instanceof WritesQueryMetrics) { + total += ((WritesQueryMetrics) d).getSeekCount(); + } + } + return total; + } + + @Override + public long getNextCount() { + long total = 0; + for (QueryLogicTransformer d : delegates) { + if (d instanceof WritesQueryMetrics) { + total += ((WritesQueryMetrics) d).getNextCount(); + } + } + return total; + } + + @Override + public long getYieldCount() { + long total = 0; + for (QueryLogicTransformer d : delegates) { + if (d instanceof WritesQueryMetrics) { + total += ((WritesQueryMetrics) d).getYieldCount(); + } + } + return total; + } } diff --git a/pom.xml b/pom.xml index 1c56c1544ee..39ba19393bd 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 4.0.6 3.0.0 1.0.0 - 4.0.0 + 4.0.7 3.0.2 1.2 2.23.0