hanahmily commented on code in PR #322:
URL:
https://github.com/apache/skywalking-banyandb/pull/322#discussion_r1325329798
##########
api/proto/banyandb/measure/v1/write.proto:
##########
@@ -43,10 +44,18 @@ message WriteRequest {
common.v1.Metadata metadata = 1 [(validate.rules).message.required = true];
// the data_point is required.
DataPointValue data_point = 2 [(validate.rules).message.required = true];
+ // the message_id is required.
+ uint64 message_id = 3 [(validate.rules).uint64.gt = 0];
}
// WriteResponse is the response contract for write
-message WriteResponse {}
+message WriteResponse {
+ common.v1.Metadata last_metadata = 1 [(validate.rules).message.required =
true];
Review Comment:
```suggestion
common.v1.Metadata lastest_metadata = 3 [(validate.rules).message.required
= true];
```
##########
api/proto/banyandb/measure/v1/write.proto:
##########
@@ -43,10 +44,18 @@ message WriteRequest {
common.v1.Metadata metadata = 1 [(validate.rules).message.required = true];
// the data_point is required.
DataPointValue data_point = 2 [(validate.rules).message.required = true];
+ // the message_id is required.
+ uint64 message_id = 3 [(validate.rules).uint64.gt = 0];
}
// WriteResponse is the response contract for write
-message WriteResponse {}
+message WriteResponse {
+ common.v1.Metadata last_metadata = 1 [(validate.rules).message.required =
true];
+ // status indicates the request processing result
+ model.v1.Status status = 2 [(validate.rules).enum.defined_only = true];
+ // the message_id from request.
+ uint64 message_id = 3 [(validate.rules).uint64.gt = 0];
Review Comment:
```suggestion
uint64 message_id = 1 [(validate.rules).uint64.gt = 0];
```
##########
api/proto/banyandb/model/v1/write.proto:
##########
@@ -0,0 +1,34 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+syntax = "proto3";
+
+package banyandb.model.v1;
+
+option go_package =
"github.com/apache/skywalking-banyandb/api/proto/banyandb/model/v1";
+option java_package = "org.apache.skywalking.banyandb.model.v1";
+
+// Status is the response status for write
+enum Status {
+ STATUS_UNSPECIFIED = 0;
+ STATUS_SUCCEED = 1;
+ STATUS_RECEIVE_ERROR = 2;
+ STATUS_INVALID_TIMESTAMP = 3;
+ STATUS_INVALID_METADATA = 4;
Review Comment:
```suggestion
STATUS_NOT_FOUND = 4;
```
This status indicates the resource referred to by the metadata doesn't exist.
##########
banyand/liaison/grpc/stream.go:
##########
@@ -76,18 +78,29 @@ func (s *streamService) Write(stream
streamv1.StreamService_WriteServer) error {
}
if err != nil {
s.sampled.Error().Stringer("written",
writeEntity).Err(err).Msg("failed to receive message")
- reply(stream, s.sampled)
+ reply(nil, modelv1.Status_STATUS_RECEIVE_ERROR, 0,
stream, s.sampled)
Review Comment:
Here is a bug introduced by me. When a non-EOF error comes, we should
"return" instead of "continue". The underlying issue causing the error is not
addressed, and this could lead to further issues down the line.
Once you fixed this bug, "STATUS_RECEIVE_ERROR" is redundant as well.
##########
pkg/query/logical/common.go:
##########
@@ -60,25 +59,30 @@ func ProjectItem(ec executor.ExecutionContext, item
tsdb.Item, projectionFieldRe
if len(refs) == 0 {
continue
}
- tags := make([]*modelv1.Tag, len(refs))
familyName := refs[0].Tag.getFamilyName()
parsedTagFamily, err := ec.ParseTagFamily(familyName, item)
if err != nil {
return nil, errors.WithMessage(err, "parse projection")
}
+
+ var tags []*modelv1.Tag
if len(refs) > len(parsedTagFamily.Tags) {
- return nil, errors.Wrapf(errInvalidData,
- "the number of tags %d in %s is less then
expected %d",
- len(parsedTagFamily.Tags), familyName,
len(refs))
- }
- for j, ref := range refs {
- if len(parsedTagFamily.GetTags()) > ref.Spec.TagIdx {
- tags[j] =
parsedTagFamily.GetTags()[ref.Spec.TagIdx]
- } else {
- tags[j] = &modelv1.Tag{Key: ref.Tag.name,
Value: nullTag}
+ tags = make([]*modelv1.Tag,
len(parsedTagFamily.GetTags()))
+ for j, ref := range refs {
+ if len(parsedTagFamily.GetTags()) >
ref.Spec.TagIdx {
+ tags[j] =
parsedTagFamily.GetTags()[ref.Spec.TagIdx]
+ }
+ }
+ } else {
+ tags = make([]*modelv1.Tag, len(refs))
+ for j, ref := range refs {
+ if len(parsedTagFamily.GetTags()) >
ref.Spec.TagIdx {
+ tags[j] =
parsedTagFamily.GetTags()[ref.Spec.TagIdx]
+ } else {
+ tags[j] = &modelv1.Tag{Key:
ref.Tag.name, Value: nullTag}
+ }
}
}
Review Comment:
There is a lot of repeated code and we can clean it up by simplifying the
condition and the loop body.
```go
var tags []*modelv1.Tag
parsedTags := parsedTagFamily.GetTags()
// Determine the size of the tags slice
size := len(parsedTags)
if len(refs) > size {
size = len(refs)
}
tags = make([]*modelv1.Tag, size)
// Populate the tags slice
for j, ref := range refs {
if ref.Spec.TagIdx < len(parsedTags) {
tags[j] = parsedTags[ref.Spec.TagIdx]
} else {
tags[j] = &modelv1.Tag{Key: ref.Tag.name, Value: nullTag}
}
}
```
##########
api/proto/banyandb/model/v1/write.proto:
##########
@@ -0,0 +1,34 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+syntax = "proto3";
+
+package banyandb.model.v1;
+
+option go_package =
"github.com/apache/skywalking-banyandb/api/proto/banyandb/model/v1";
+option java_package = "org.apache.skywalking.banyandb.model.v1";
+
+// Status is the response status for write
+enum Status {
+ STATUS_UNSPECIFIED = 0;
+ STATUS_SUCCEED = 1;
+ STATUS_RECEIVE_ERROR = 2;
+ STATUS_INVALID_TIMESTAMP = 3;
+ STATUS_INVALID_METADATA = 4;
+ STATUS_EXPIRED_REVISION = 5;
Review Comment:
```suggestion
STATUS_EXPIRED_SCHEMA = 5;
```
--
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]