package trace
import (
)
type timestamp uint64
type batch struct {
m threadID
time timestamp
data []byte
}
type threadID int64
func ( []byte) (batch, uint64, uint64, error) {
if len() == 0 {
return batch{}, 0, 0, fmt.Errorf("batch is empty")
}
:= make([]byte, len())
if := copy(, ); != len() {
return batch{}, 0, 0, fmt.Errorf("unexpected error copying batch")
}
if := tracev2.EventType([0]); != tracev2.EvEventBatch && != tracev2.EvExperimentalBatch {
return batch{}, 0, 1, fmt.Errorf("expected batch event, got event %d", )
}
:= 1
= [1:]
, , := readUvarint()
if != nil {
return batch{}, , uint64( + ), fmt.Errorf("error reading batch gen: %w", )
}
+=
= [:]
, , := readUvarint()
if != nil {
return batch{}, , uint64( + ), fmt.Errorf("error reading batch M ID: %w", )
}
+=
= [:]
, , := readUvarint()
if != nil {
return batch{}, , uint64( + ), fmt.Errorf("error reading batch timestamp: %w", )
}
+=
= [:]
, , := readUvarint()
if != nil {
return batch{}, , uint64( + ), fmt.Errorf("error reading batch size: %w", )
}
if > tracev2.MaxBatchSize {
return batch{}, , uint64( + ), fmt.Errorf("invalid batch size %d, maximum is %d", , tracev2.MaxBatchSize)
}
+=
+= int()
= [:]
return batch{
m: threadID(),
time: timestamp(),
data: ,
}, , uint64(), nil
}