Page MenuHomePhabricator

As Harbormaster logs are processed, build a sparse map of byte offsets to line numbers
ClosedPublic

Authored by epriestley on Feb 23 2018, 7:12 PM.
Tags
None
Referenced Files
F18802933: D19139.id45845.diff
Fri, Oct 17, 8:54 PM
F18779282: D19139.diff
Sat, Oct 11, 1:14 PM
F18770993: D19139.diff
Wed, Oct 8, 4:45 PM
F18637334: D19139.id.diff
Sep 17 2025, 7:02 AM
F18631276: D19139.diff
Sep 16 2025, 2:53 PM
F18566649: D19139.id.diff
Sep 9 2025, 2:48 PM
F18502228: D19139.diff
Sep 4 2025, 10:17 PM
F18208192: D19139.id45860.diff
Aug 18 2025, 8:15 PM
Subscribers
Restricted Owners Package

Details

Summary

Depends on D19138. Ref T13088. When we want to read the last part of a logfile and show accurate line numbers, we need to be able to get from byte offsets to line numbers somehow.

Our fundamental unit must remain byte offsets, because a test can emit an arbitrarily long line, and we should accommodate it cleanly if a test emits 2GB of the letter "A".

To support going from byte offsets to line numbers, compute a map with periodic line markers throughout the offsets of the file. From here, we can figure out the line numbers for arbitrary positions in the file with only a constant amount of work.

Test Plan

Added unit tests; ran unit tests.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Owners added a subscriber: Restricted Owners Package.Feb 23 2018, 7:12 PM
This revision was not accepted when it landed; it landed in state Needs Review.Feb 27 2018, 1:57 AM
This revision was automatically updated to reflect the committed changes.