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 (
|
2020-03-30 10:08:50 +01:00
|
|
|
"storj.io/common/uuid"
|
2019-02-26 15:17:51 +00:00
|
|
|
)
|
|
|
|
|
2019-04-01 14:42:17 +01:00
|
|
|
// BucketTally contains information about aggregate data stored in a bucket
|
|
|
|
type BucketTally struct {
|
2019-09-13 14:51:41 +01:00
|
|
|
ProjectID uuid.UUID
|
2019-04-09 14:48:35 +01:00
|
|
|
BucketName []byte
|
2019-06-25 16:58:42 +01:00
|
|
|
|
2019-09-13 14:51:41 +01:00
|
|
|
ObjectCount int64
|
2019-04-09 14:48:35 +01:00
|
|
|
|
2019-10-04 20:09:52 +01:00
|
|
|
InlineSegments int64
|
|
|
|
RemoteSegments int64
|
2019-02-26 15:17:51 +00:00
|
|
|
|
|
|
|
InlineBytes int64
|
|
|
|
RemoteBytes int64
|
2019-04-01 14:42:17 +01:00
|
|
|
|
|
|
|
MetadataSize int64
|
2019-02-26 15:17:51 +00:00
|
|
|
}
|
|
|
|
|
2019-04-01 14:42:17 +01:00
|
|
|
// Combine aggregates all the tallies
|
|
|
|
func (s *BucketTally) Combine(o *BucketTally) {
|
2019-10-04 20:09:52 +01:00
|
|
|
s.ObjectCount += o.ObjectCount
|
|
|
|
|
2019-02-26 15:17:51 +00:00
|
|
|
s.InlineSegments += o.InlineSegments
|
|
|
|
s.RemoteSegments += o.RemoteSegments
|
|
|
|
|
|
|
|
s.InlineBytes += o.InlineBytes
|
|
|
|
s.RemoteBytes += o.RemoteBytes
|
|
|
|
}
|
|
|
|
|
2019-10-04 20:09:52 +01:00
|
|
|
// Segments returns total number of segments.
|
|
|
|
func (s *BucketTally) Segments() int64 {
|
|
|
|
return s.InlineSegments + s.RemoteSegments
|
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 {
|
|
|
|
return s.InlineBytes + s.RemoteBytes
|
2019-02-26 15:17:51 +00:00
|
|
|
}
|