You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2024/10/21 00:54:46 UTC

(skywalking-banyandb) branch main updated: [ospp] Implements MeasureAggregateFunctionService.Support API (#545)

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

hanahmily pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git


The following commit(s) were added to refs/heads/main by this push:
     new c64724a1 [ospp] Implements MeasureAggregateFunctionService.Support API (#545)
c64724a1 is described below

commit c64724a19cbaf4fee86d042929cd5a4a7ef8b0c6
Author: Leo Xie <st...@qq.com>
AuthorDate: Mon Oct 21 08:54:41 2024 +0800

    [ospp] Implements MeasureAggregateFunctionService.Support API (#545)
    
    * implements measureAggregateFunctionServer.Support
    
    * fix lint
    
    ---------
    
    Co-authored-by: Gao Hongtao <ha...@gmail.com>
---
 banyand/liaison/grpc/registry.go | 65 ++++++++++++++++++++++++++++++++++++++++
 banyand/liaison/grpc/server.go   |  2 ++
 2 files changed, 67 insertions(+)

diff --git a/banyand/liaison/grpc/registry.go b/banyand/liaison/grpc/registry.go
index ef3a59e7..5e2983a8 100644
--- a/banyand/liaison/grpc/registry.go
+++ b/banyand/liaison/grpc/registry.go
@@ -27,6 +27,7 @@ import (
 
 	commonv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/common/v1"
 	databasev1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1"
+	modelv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/model/v1"
 	"github.com/apache/skywalking-banyandb/banyand/metadata"
 	"github.com/apache/skywalking-banyandb/banyand/metadata/schema"
 )
@@ -824,3 +825,67 @@ func (ts *topNAggregationRegistryServer) Exist(ctx context.Context, req *databas
 	}
 	return &databasev1.TopNAggregationRegistryServiceExistResponse{HasGroup: exist, HasTopNAggregation: false}, nil
 }
+
+type measureAggregateFunctionServer struct {
+	databasev1.UnimplementedMeasureAggregateFunctionServiceServer
+	supports []*databasev1.MeasureAggregateFunction
+}
+
+func newMeasureAggregateFunctionServer() *measureAggregateFunctionServer {
+	functions := []*databasev1.MeasureAggregateFunction{
+		{
+			Type:              databasev1.FieldType_FIELD_TYPE_INT,
+			AggregateFunction: modelv1.MeasureAggregate_MEASURE_AGGREGATE_MIN,
+		},
+		{
+			Type:              databasev1.FieldType_FIELD_TYPE_FLOAT,
+			AggregateFunction: modelv1.MeasureAggregate_MEASURE_AGGREGATE_MIN,
+		},
+		{
+			Type:              databasev1.FieldType_FIELD_TYPE_INT,
+			AggregateFunction: modelv1.MeasureAggregate_MEASURE_AGGREGATE_MAX,
+		},
+		{
+			Type:              databasev1.FieldType_FIELD_TYPE_FLOAT,
+			AggregateFunction: modelv1.MeasureAggregate_MEASURE_AGGREGATE_MAX,
+		},
+		{
+			Type:              databasev1.FieldType_FIELD_TYPE_INT,
+			AggregateFunction: modelv1.MeasureAggregate_MEASURE_AGGREGATE_COUNT,
+		},
+		{
+			Type:              databasev1.FieldType_FIELD_TYPE_INT,
+			AggregateFunction: modelv1.MeasureAggregate_MEASURE_AGGREGATE_SUM,
+		},
+		{
+			Type:              databasev1.FieldType_FIELD_TYPE_FLOAT,
+			AggregateFunction: modelv1.MeasureAggregate_MEASURE_AGGREGATE_SUM,
+		},
+		{
+			Type:              databasev1.FieldType_FIELD_TYPE_INT,
+			AggregateFunction: modelv1.MeasureAggregate_MEASURE_AGGREGATE_AVG,
+		},
+		{
+			Type:              databasev1.FieldType_FIELD_TYPE_FLOAT,
+			AggregateFunction: modelv1.MeasureAggregate_MEASURE_AGGREGATE_AVG,
+		},
+		{
+			Type:              databasev1.FieldType_FIELD_TYPE_INT,
+			AggregateFunction: modelv1.MeasureAggregate_MEASURE_AGGREGATE_PERCENT,
+		},
+		{
+			Type:              databasev1.FieldType_FIELD_TYPE_INT,
+			AggregateFunction: modelv1.MeasureAggregate_MEASURE_AGGREGATE_RATE,
+		},
+	}
+
+	return &measureAggregateFunctionServer{supports: functions}
+}
+
+func (ms *measureAggregateFunctionServer) Support(_ context.Context, _ *databasev1.MeasureAggregateFunctionServiceSupportRequest) (
+	*databasev1.MeasureAggregateFunctionServiceSupportResponse, error,
+) {
+	return &databasev1.MeasureAggregateFunctionServiceSupportResponse{
+		MeasureAggregateFunction: ms.supports,
+	}, nil
+}
diff --git a/banyand/liaison/grpc/server.go b/banyand/liaison/grpc/server.go
index af89eb96..0250dfab 100644
--- a/banyand/liaison/grpc/server.go
+++ b/banyand/liaison/grpc/server.go
@@ -73,6 +73,7 @@ type server struct {
 	log        *logger.Logger
 	*propertyServer
 	*topNAggregationRegistryServer
+	*measureAggregateFunctionServer
 	*groupRegistryServer
 	stopCh chan struct{}
 	*indexRuleRegistryServer
@@ -127,6 +128,7 @@ func NewServer(_ context.Context, pipeline, broadcaster queue.Client, schemaRegi
 		topNAggregationRegistryServer: &topNAggregationRegistryServer{
 			schemaRegistry: schemaRegistry,
 		},
+		measureAggregateFunctionServer: newMeasureAggregateFunctionServer(),
 		propertyServer: &propertyServer{
 			schemaRegistry: schemaRegistry,
 		},