This is an automated email from the ASF dual-hosted git repository.

wankai pushed a commit to branch topn-config
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/topn-config by this push:
     new 2826338bc0 use direct query when attribute condition `isEquals != 
true`.
2826338bc0 is described below

commit 2826338bc0dd299fcbc127b6b76a0e3fa5604a2a
Author: wankai123 <wankai...@foxmail.com>
AuthorDate: Tue Jun 17 11:53:00 2025 +0800

    use direct query when attribute condition `isEquals != true`.
---
 .../plugin/banyandb/BanyanDBAggregationQueryDAO.java   | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git 
a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/BanyanDBAggregationQueryDAO.java
 
b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/BanyanDBAggregationQueryDAO.java
index 9447fbac9b..3781e5c667 100644
--- 
a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/BanyanDBAggregationQueryDAO.java
+++ 
b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/BanyanDBAggregationQueryDAO.java
@@ -29,6 +29,7 @@ import 
org.apache.skywalking.banyandb.v1.client.TimestampRange;
 import org.apache.skywalking.banyandb.v1.client.TopNQueryResponse;
 import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
 import org.apache.skywalking.oap.server.core.query.enumeration.Order;
+import org.apache.skywalking.oap.server.core.query.input.AttrCondition;
 import org.apache.skywalking.oap.server.core.query.input.Duration;
 import org.apache.skywalking.oap.server.core.query.input.TopNCondition;
 import org.apache.skywalking.oap.server.core.query.type.KeyValue;
@@ -69,13 +70,24 @@ public class BanyanDBAggregationQueryDAO extends 
AbstractBanyanDBDAO implements
         // The query tags are the additional conditions and attributes defined 
in the TopN condition.
         // The query tags is the key to find the TopN aggregation in the 
schema.
         // If the TopN aggregation is defined in the schema, it will be used 
to perform the query.
+        // The server-side TopN only support when attribute condition 
`isEquals == true`.
         ImmutableSet.Builder<String> queryTags = ImmutableSet.builder();
+        boolean equalsQuery = true;
+        if (condition.getAttributes() != null) {
+            for (AttrCondition attr : condition.getAttributes()) {
+                if (!attr.isEquals()) {
+                    equalsQuery = false;
+                    break;
+                }
+                queryTags.add(attr.getKey());
+            }
+        }
+        if (!equalsQuery) {
+            return directMetricsTopN(isColdStage, condition, schema, 
valueColumnName, spec, getTimestampRange(duration), additionalConditions);
+        }
         if (additionalConditions != null) {
             additionalConditions.forEach(additionalCondition -> 
queryTags.add(additionalCondition.getKey()));
         }
-        if (condition.getAttributes() != null) {
-            condition.getAttributes().forEach(attr -> 
queryTags.add(attr.getKey()));
-        }
         if (schema.getTopNSpecs() != null) {
             BanyandbDatabase.TopNAggregation topNAggregation = 
schema.getTopNSpecs().get(queryTags.build());
             if (topNAggregation != null) {

Reply via email to