Add a scanner error check to ClusterCounter.Count.

It was silently exiting at the "recordingStart":"2022-09-23T17:06:59.680537075Z"
line, the first line whose length (66873) exceeds
bufio.MaxScanTokenSize. Now distinctcounter exits with an error status
instead of reporting partial results.

$ ./distinctcounter -from 2023-01-01T00:00:00Z -to 2023-01-10T00:00:00Z -in metrics-ip-salted.jsonl
2023/04/20 13:54:11 unable to count:bufio.Scanner: token too long
This commit is contained in:
David Fifield 2023-04-20 09:47:56 -04:00
parent f723cf52e8
commit 8e5ea82611

View file

@ -55,6 +55,10 @@ func (c ClusterCounter) Count(reader io.Reader) (*ClusterCountResult, error) {
return nil, err return nil, err
} }
} }
err = inputScanner.Err()
if err != nil {
return nil, err
}
result.Sum = counter.Count() result.Sum = counter.Count()
return &result, nil return &result, nil
} }