MCPcopy Create free account
hub / github.com/brimdata/super / GetBranchStats

Function GetBranchStats

runtime/exec/stats.go:56–83  ·  view source on GitHub ↗
(ctx context.Context, b *db.Branch, snap commits.View)

Source from the content-addressed store, hash-verified

54}
55
56func GetBranchStats(ctx context.Context, b *db.Branch, snap commits.View) (info BranchStats, err error) {
57 // XXX this doesn't scale... it should be stored in the snapshot and is
58 // not easy to compute in the face of deletes...
59 var poolSpan *extent.Generic
60 for _, object := range snap.Select(nil, b.Pool().SortKeys.Primary().Order) {
61 info.Size += object.Size
62 if poolSpan == nil {
63 poolSpan = extent.NewGenericFromOrder(object.Min, object.Max, order.Asc)
64 } else {
65 poolSpan.Extend(object.Min)
66 poolSpan.Extend(object.Max)
67 }
68 }
69 //XXX need to change API to take return key range
70 if poolSpan != nil {
71 min := poolSpan.First()
72 if min.Type() == super.TypeTime {
73 firstTs := super.DecodeTime(min.Bytes())
74 lastTs := super.DecodeTime(poolSpan.Last().Bytes())
75 if lastTs < firstTs {
76 firstTs, lastTs = lastTs, firstTs
77 }
78 span := nano.NewSpanTs(firstTs, lastTs+1)
79 info.Span = &span
80 }
81 }
82 return info, err
83}

Callers

nothing calls this directly

Calls 11

ExtendMethod · 0.95
FirstMethod · 0.95
LastMethod · 0.95
NewGenericFromOrderFunction · 0.92
DecodeTimeFunction · 0.92
NewSpanTsFunction · 0.92
PrimaryMethod · 0.80
PoolMethod · 0.80
SelectMethod · 0.65
TypeMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected