github.com/grafana/pyroscope@v1.18.0/pkg/phlaredb/schemas/v1/stacktraces.go (about) 1 package v1 2 3 import ( 4 "github.com/parquet-go/parquet-go" 5 6 phlareparquet "github.com/grafana/pyroscope/pkg/parquet" 7 ) 8 9 var stacktracesSchema = parquet.NewSchema("Stacktrace", phlareparquet.Group{ 10 phlareparquet.NewGroupField("ID", parquet.Encoded(parquet.Uint(64), &parquet.DeltaBinaryPacked)), 11 phlareparquet.NewGroupField("LocationIDs", parquet.List(parquet.Encoded(parquet.Uint(64), &parquet.DeltaBinaryPacked))), 12 }) 13 14 type Stacktrace struct { 15 LocationIDs []uint64 `parquet:",list"` 16 } 17 18 type storedStacktrace struct { 19 ID uint64 `parquet:",delta"` 20 LocationIDs []uint64 `parquet:",list"` 21 } 22 23 type StacktracePersister struct{} 24 25 func (*StacktracePersister) Name() string { 26 return "stacktraces" 27 } 28 29 func (*StacktracePersister) Schema() *parquet.Schema { 30 return stacktracesSchema 31 } 32 33 func (*StacktracePersister) Deconstruct(row parquet.Row, s *Stacktrace) parquet.Row { 34 var stored storedStacktrace 35 stored.LocationIDs = s.LocationIDs 36 row = stacktracesSchema.Deconstruct(row, &stored) 37 return row 38 } 39 40 func (*StacktracePersister) Reconstruct(row parquet.Row) (s *Stacktrace, err error) { 41 var stored storedStacktrace 42 if err := stacktracesSchema.Reconstruct(&stored, row); err != nil { 43 return nil, err 44 } 45 return &Stacktrace{LocationIDs: stored.LocationIDs}, nil 46 }