lujiajing1126 commented on code in PR #10448:
URL: https://github.com/apache/skywalking/pull/10448#discussion_r1118953797
##########
oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/BanyanDBAggregationQueryDAO.java:
##########
@@ -85,24 +60,45 @@ protected void apply(MeasureQuery query) {
throw new IOException("field spec is not registered");
}
+ if (schema.getTopNSpec() == null) {
+ throw new IOException("TopN spec is registered");
+ }
+
+ TopNQueryResponse resp = null;
+ if (condition.getOrder() == Order.DES) {
+ resp = topN(schema, timestampRange, condition.getTopN(),
additionalConditions);
+ } else {
+ resp = bottomN(schema, timestampRange, condition.getTopN(),
additionalConditions);
+ }
+
+ if (resp.size() == 0) {
+ return Collections.emptyList();
+ } else if (resp.size() > 1) { // since we have done aggregation, i.e.
MEAN
Review Comment:
For a time range query, we will get a series of time windows. For example,
when we are querying for the last 30mins, we may get 30 windows provided that
the interval of the metric is 1min.
And each time window (1 min) contains a fully ordered list, the maximum
number of entries is controlled by the `countersNum` given in the
TopNAggregation schema.
So the (final) MEAN aggreation is imposed on all 30 windows, and gives the
average value of the same key (groupByTagValues). After all these operations,
we get a single result set.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]