hanahmily commented on code in PR #900:
URL: 
https://github.com/apache/skywalking-banyandb/pull/900#discussion_r2641656076


##########
banyand/cmd/dump/measure.go:
##########
@@ -1294,3 +1339,38 @@ func measureTagValueDecoder(valueType pbv1.ValueType, 
value []byte, valueArr [][
                return pbv1.NullTagValue
        }
 }
+
+func (ctx *measureDumpContext) parseAndDisplaySeriesMetadata(partID uint64, p 
*measurePart) error {
+       // Read all data from series metadata file
+       seqReader := p.seriesMetadata.SequentialRead()
+       defer seqReader.Close()
+
+       readMetadataBytes, err := io.ReadAll(seqReader)
+       if err != nil {
+               return fmt.Errorf("failed to read series metadata: %w", err)
+       }
+
+       if len(readMetadataBytes) == 0 {
+               return nil // Empty file, nothing to parse
+       }
+
+       // Unmarshal Documents
+       var docs index.Documents
+       if err := docs.Unmarshal(readMetadataBytes); err != nil {
+               return fmt.Errorf("failed to unmarshal series metadata: %w", 
err)
+       }
+
+       if len(docs) == 0 {
+               return nil // No documents
+       }
+
+       // Store EntityValues in partSeriesMap for use in CSV output
+       partMap := make(map[common.SeriesID]string)
+       for _, doc := range docs {
+               seriesID := common.SeriesID(convert.Hash(doc.EntityValues))
+               partMap[seriesID] = string(doc.EntityValues)
+       }
+       ctx.partSeriesMap[partID] = partMap
+
+       return nil
+}

Review Comment:
   Could you extend the same logic as Copilot suggested? 



##########
banyand/cmd/dump/measure.go:
##########


Review Comment:
   The text format also needs the ctx.partSeriesMap.



##########
banyand/cmd/dump/measure.go:
##########
@@ -589,6 +601,20 @@ func openMeasurePart(id uint64, root string, fileSystem 
fs.FileSystem) (*measure
                return nil, fmt.Errorf("cannot open fv.bin: %w", err)
        }
 
+       // Try to open series metadata file (optional, for backward 
compatibility)
+       seriesMetadataPath := filepath.Join(partPath, "smeta.bin")
+       reader, err := fileSystem.OpenFile(seriesMetadataPath)
+       if err != nil {
+               // Only ignore file not found errors; other errors should be 
reported
+               var fsErr *fs.FileSystemError
+               if !errors.As(err, &fsErr) || fsErr.Code != fs.IsNotExistError {
+                       fmt.Fprintf(os.Stderr, "Warning: Failed to open series 
metadata file %s: %v\n", seriesMetadataPath, err)
+               }
+               // File doesn't exist, it's okay - just continue without it
+       } else {
+               p.seriesMetadata = reader
+       }

Review Comment:
   To fix it.



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