lujiajing1126 commented on a change in pull request #30:
URL: https://github.com/apache/skywalking-banyandb/pull/30#discussion_r684577263
##########
File path: banyand/liaison/grpc/grpc.go
##########
@@ -128,3 +166,87 @@ func (s *Server) GracefulStop() {
s.log.Info().Msg("stopping")
s.ser.GracefulStop()
}
+
+func assemblyWriteData(shardID uint, writeEntity *v1.WriteRequest, seriesID
uint64) data.TraceWriteDate {
+ return data.TraceWriteDate{ShardID: shardID, SeriesID: seriesID,
WriteRequest: writeEntity}
+}
+
+func (s *Server) Write(TraceWriteServer v1.TraceService_WriteServer) error {
+ for {
+ writeEntity, err := TraceWriteServer.Recv()
+ if err == io.EOF {
+ return nil
+ }
+ if err != nil {
+ return err
+ }
+
+ //log.Println("writeEntity:", writeEntity)
+ ana := logical.DefaultAnalyzer()
+ metadata := common.Metadata{
+ KindVersion: apischema.SeriesKindVersion,
+ Spec: writeEntity.GetMetadata(),
+ }
+ schema, ruleError := ana.BuildTraceSchema(context.TODO(),
metadata)
+ if ruleError != nil {
+ return ruleError
+ }
+ if s.seriesInfo.seriesEvent == nil {
+ return errors.New("No seriesEvents")
+ }
+ seriesIDLen :=
len(s.seriesInfo.seriesEvent.FieldNamesCompositeSeriesId)
+ var str string
+ var arr []string
+ for i := 0; i < seriesIDLen; i++ {
Review comment:
I suggest optimizing this loop by,
1) first convert `FieldNamesCompositeSeriesId` to []*FieldRef (i.e.
`FieldSubscript` in your case, maybe you can make use of
`Schema.CreateRef(names ...string)` to do this),
2) then iterate over fields (`writeEntity.GetEntity().GetFields()`) to
compose the seriesID,
If we do so, only one iteration is necessary.
--
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]