(ctx context.Context, rep repo.DirectRepository, sizeBuckets []uint32)
| 110 | } |
| 111 | |
| 112 | func (c *commandContentStats) calculateStats(ctx context.Context, rep repo.DirectRepository, sizeBuckets []uint32) ( |
| 113 | grandTotal contentStatsTotals, |
| 114 | byCompressionTotal map[compression.HeaderID]*contentStatsTotals, |
| 115 | countMap map[uint32]int, |
| 116 | totalSizeOfContentsUnder map[uint32]int64, |
| 117 | err error, |
| 118 | ) { |
| 119 | byCompressionTotal = make(map[compression.HeaderID]*contentStatsTotals) |
| 120 | totalSizeOfContentsUnder = make(map[uint32]int64) |
| 121 | countMap = make(map[uint32]int) |
| 122 | |
| 123 | for _, s := range sizeBuckets { |
| 124 | countMap[s] = 0 |
| 125 | } |
| 126 | |
| 127 | err = rep.ContentReader().IterateContents( |
| 128 | ctx, |
| 129 | content.IterateOptions{ |
| 130 | Range: c.contentRange.contentIDRange(), |
| 131 | }, |
| 132 | func(b content.Info) error { |
| 133 | grandTotal.packedSize += int64(b.PackedLength) |
| 134 | grandTotal.originalSize += int64(b.OriginalLength) |
| 135 | grandTotal.count++ |
| 136 | |
| 137 | bct := byCompressionTotal[b.CompressionHeaderID] |
| 138 | if bct == nil { |
| 139 | bct = &contentStatsTotals{} |
| 140 | byCompressionTotal[b.CompressionHeaderID] = bct |
| 141 | } |
| 142 | |
| 143 | bct.packedSize += int64(b.PackedLength) |
| 144 | bct.originalSize += int64(b.OriginalLength) |
| 145 | bct.count++ |
| 146 | |
| 147 | for s := range countMap { |
| 148 | if b.PackedLength < s { |
| 149 | countMap[s]++ |
| 150 | totalSizeOfContentsUnder[s] += int64(b.PackedLength) |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | return nil |
| 155 | }) |
| 156 | |
| 157 | //nolint:wrapcheck |
| 158 | return grandTotal, byCompressionTotal, countMap, totalSizeOfContentsUnder, err |
| 159 | } |
no test coverage detected