ButterBright commented on code in PR #1184:
URL: 
https://github.com/apache/skywalking-banyandb/pull/1184#discussion_r3475866074


##########
banyand/stream/part.go:
##########
@@ -422,6 +430,18 @@ func CreatePartFileReaderFromPath(partPath string, lfs 
fs.FileSystem) ([]queue.F
                if e.IsDir() {
                        continue
                }
+               if e.Name() == tagTypeFilename {

Review Comment:
   This is not necessary and the sibling branches don't have `continue`.



##########
banyand/stream/part_metadata.go:
##########
@@ -107,6 +112,96 @@ func (pm *partMetadata) mustWriteMetadata(fileSystem 
fs.FileSystem, partPath str
        }
 }
 
+type tagType map[string]map[string]pbv1.ValueType
+
+func (tt tagType) reset() {
+       clear(tt)
+}
+
+func (tt tagType) copyFrom(source tagType) {
+       for familyName, sourceTags := range source {
+               tags := tt[familyName]
+               if tags == nil {
+                       tags = make(map[string]pbv1.ValueType, len(sourceTags))
+                       tt[familyName] = tags
+               }
+               for tagName, valueType := range sourceTags {
+                       tags[tagName] = valueType
+               }
+       }
+}
+
+func (tt tagType) marshal() []byte {
+       var dst []byte
+       dst = encoding.VarUint64ToBytes(dst, uint64(len(tt)))
+       familyNames := make([]string, 0, len(tt))
+       for familyName := range tt {
+               familyNames = append(familyNames, familyName)
+       }
+       sort.Strings(familyNames)
+       for _, familyName := range familyNames {
+               dst = encoding.EncodeBytes(dst, 
convert.StringToBytes(familyName))
+               tags := tt[familyName]
+               dst = encoding.VarUint64ToBytes(dst, uint64(len(tags)))
+               tagNames := make([]string, 0, len(tags))
+               for tagName := range tags {
+                       tagNames = append(tagNames, tagName)
+               }
+               sort.Strings(tagNames)
+               for _, tagName := range tagNames {
+                       dst = encoding.EncodeBytes(dst, 
convert.StringToBytes(tagName))
+                       dst = append(dst, byte(tags[tagName]))
+               }
+       }
+       return dst
+}
+
+func (tt tagType) unmarshal(src []byte) error {

Review Comment:
   Perhaps we should fix it by revising `BytesToVarUint64` in a future PR.



-- 
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]

Reply via email to