(path string)
| 209 | } |
| 210 | |
| 211 | func parseCompressionStats(path string) (map[string]CompressionStats, error) { |
| 212 | file, err := openIfExists(path) |
| 213 | if err != nil { |
| 214 | return nil, err |
| 215 | } |
| 216 | if file == nil { |
| 217 | return map[string]CompressionStats{}, nil |
| 218 | } |
| 219 | defer file.Close() |
| 220 | |
| 221 | stats := make(map[string]CompressionStats) |
| 222 | |
| 223 | scanner := bufio.NewScanner(file) |
| 224 | scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024) |
| 225 | lineNum := 0 |
| 226 | for scanner.Scan() { |
| 227 | lineNum++ |
| 228 | line := scanner.Text() |
| 229 | if lineNum == 1 { |
| 230 | continue |
| 231 | } |
| 232 | fields := strings.Fields(line) |
| 233 | if len(fields) < 3 { |
| 234 | continue |
| 235 | } |
| 236 | algorithm := strings.TrimSuffix(fields[0], ":") |
| 237 | compressed, err := parseHumanReadableBytes(fields[1]) |
| 238 | if err != nil { |
| 239 | return nil, err |
| 240 | } |
| 241 | uncompressed, err := parseHumanReadableBytes(fields[2]) |
| 242 | if err != nil { |
| 243 | return nil, err |
| 244 | } |
| 245 | var avgExtent uint64 |
| 246 | if len(fields) >= 4 { |
| 247 | avgExtent, err = parseHumanReadableBytes(fields[3]) |
| 248 | if err != nil { |
| 249 | return nil, err |
| 250 | } |
| 251 | } |
| 252 | stats[algorithm] = CompressionStats{ |
| 253 | CompressedBytes: compressed, |
| 254 | UncompressedBytes: uncompressed, |
| 255 | AverageExtentSizeBytes: avgExtent, |
| 256 | } |
| 257 | } |
| 258 | if err := scanner.Err(); err != nil { |
| 259 | return nil, err |
| 260 | } |
| 261 | return stats, nil |
| 262 | } |
| 263 | |
| 264 | func parseErrors(path string) (map[string]ErrorStats, error) { |
| 265 | file, err := openIfExists(path) |
no test coverage detected
searching dependent graphs…