(ctx context.Context, b *db.Branch, snap commits.View)
| 54 | } |
| 55 | |
| 56 | func 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 | } |
nothing calls this directly
no test coverage detected