2019-02-26 15:17:51 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2019-04-01 14:42:17 +01:00
|
|
|
package accounting
|
2019-02-26 15:17:51 +00:00
|
|
|
|
|
|
|
import (
|
2021-04-21 13:42:57 +01:00
|
|
|
"storj.io/storj/satellite/metabase"
|
2019-02-26 15:17:51 +00:00
|
|
|
)
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// BucketTally contains information about aggregate data stored in a bucket.
|
2019-04-01 14:42:17 +01:00
|
|
|
type BucketTally struct {
|
2020-08-31 11:14:20 +01:00
|
|
|
metabase.BucketLocation
|
2019-06-25 16:58:42 +01:00
|
|
|
|
2022-05-10 10:54:52 +01:00
|
|
|
ObjectCount int64
|
|
|
|
PendingObjectCount int64
|
2019-04-09 14:48:35 +01:00
|
|
|
|
2021-07-01 12:29:25 +01:00
|
|
|
TotalSegments int64
|
|
|
|
TotalBytes int64
|
2019-04-01 14:42:17 +01:00
|
|
|
|
|
|
|
MetadataSize int64
|
2019-02-26 15:17:51 +00:00
|
|
|
}
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// Combine aggregates all the tallies.
|
2019-04-01 14:42:17 +01:00
|
|
|
func (s *BucketTally) Combine(o *BucketTally) {
|
2019-10-04 20:09:52 +01:00
|
|
|
s.ObjectCount += o.ObjectCount
|
2022-05-10 10:54:52 +01:00
|
|
|
s.PendingObjectCount += o.PendingObjectCount
|
2019-10-04 20:09:52 +01:00
|
|
|
|
2021-06-30 10:58:26 +01:00
|
|
|
s.TotalSegments += o.TotalSegments
|
2019-02-26 15:17:51 +00:00
|
|
|
|
2021-06-30 10:58:26 +01:00
|
|
|
s.TotalBytes += o.TotalBytes
|
2019-02-26 15:17:51 +00:00
|
|
|
}
|
|
|
|
|
2019-10-04 20:09:52 +01:00
|
|
|
// Segments returns total number of segments.
|
|
|
|
func (s *BucketTally) Segments() int64 {
|
2021-07-01 12:29:25 +01:00
|
|
|
return s.TotalSegments
|
2019-02-26 15:17:51 +00:00
|
|
|
}
|
|
|
|
|
2019-10-04 20:09:52 +01:00
|
|
|
// Bytes returns total bytes.
|
|
|
|
func (s *BucketTally) Bytes() int64 {
|
2021-07-01 12:29:25 +01:00
|
|
|
return s.TotalBytes
|
2019-02-26 15:17:51 +00:00
|
|
|
}
|