Skip to content

Commit

Permalink
[ospp] Implements MeasureAggregateFunctionService.Support API (#545)
Browse files Browse the repository at this point in the history
* implements measureAggregateFunctionServer.Support

* fix lint

---------

Co-authored-by: Gao Hongtao <hanahmily@gmail.com>
  • Loading branch information
StLeoX and hanahmily authored Oct 21, 2024
1 parent 25c1969 commit c64724a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
65 changes: 65 additions & 0 deletions banyand/liaison/grpc/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions banyand/liaison/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type server struct {
log *logger.Logger
*propertyServer
*topNAggregationRegistryServer
*measureAggregateFunctionServer
*groupRegistryServer
stopCh chan struct{}
*indexRuleRegistryServer
Expand Down Expand Up @@ -127,6 +128,7 @@ func NewServer(_ context.Context, pipeline, broadcaster queue.Client, schemaRegi
topNAggregationRegistryServer: &topNAggregationRegistryServer{
schemaRegistry: schemaRegistry,
},
measureAggregateFunctionServer: newMeasureAggregateFunctionServer(),
propertyServer: &propertyServer{
schemaRegistry: schemaRegistry,
},
Expand Down

0 comments on commit c64724a

Please sign in to comment.