(ctx context.Context, p *db.Pool, snap commits.View)
| 19 | } |
| 20 | |
| 21 | func GetPoolStats(ctx context.Context, p *db.Pool, snap commits.View) (info PoolStats, err error) { |
| 22 | // XXX this doesn't scale... it should be stored in the snapshot and is |
| 23 | // not easy to compute in the face of deletes... |
| 24 | var poolSpan *extent.Generic |
| 25 | for _, object := range snap.Select(nil, p.SortKeys.Primary().Order) { |
| 26 | info.Size += object.Size |
| 27 | if poolSpan == nil { |
| 28 | poolSpan = extent.NewGenericFromOrder(object.Min, object.Max, order.Asc) |
| 29 | } else { |
| 30 | poolSpan.Extend(object.Min) |
| 31 | poolSpan.Extend(object.Max) |
| 32 | } |
| 33 | } |
| 34 | //XXX need to change API to take return key range |
| 35 | if poolSpan != nil { |
| 36 | min := poolSpan.First() |
| 37 | if min.Type() == super.TypeTime { |
| 38 | firstTs := super.DecodeTime(min.Bytes()) |
| 39 | lastTs := super.DecodeTime(poolSpan.Last().Bytes()) |
| 40 | if lastTs < firstTs { |
| 41 | firstTs, lastTs = lastTs, firstTs |
| 42 | } |
| 43 | span := nano.NewSpanTs(firstTs, lastTs+1) |
| 44 | info.Span = &span |
| 45 | } |
| 46 | } |
| 47 | return info, err |
| 48 | } |
| 49 | |
| 50 | type BranchStats struct { |
| 51 | Size int64 `super:"size"` |
no test coverage detected