Skip to main content

Module follow

Module follow 

Source
Expand description

Following a file that is still being written, as tail -f does: --follow and t at the table.

The frame scans the file as any delimited or NDJSON file is scanned, with a slice right above the scan that bounds it to the rows whose records are complete (bound). A watcher thread (Follow) checks the file’s size every interval, reads only the bytes that arrived, counts the records they complete (Tail), and sends what it found as AppEvent::Followed. The app then moves the slice in every frame the view holds, so the query, filters and sort run over the new rows with no frame rebuilt, and reads the window on screen. A partial last line is never in the bound: it waits for its newline.

Standard input followed (datui -f -) is spooled to a file by a Spool that goes on copying after the first rows show; the file is followed like any other.

An Arrow IPC stream is followed the same way, its record batches counted in place of records and read by a scan of its own ([stream]).

Structs§

Follow
A file being followed: its watcher, and what the view has taken of it. Belongs to the dataset; dropping it stops the watcher.
Marks
Where rows of a followed file start, every so many rows ([MARK_ROWS], [MARK_BYTES]), and where its complete records end: a window deep in the file is read from the mark before it rather than from the file’s start. The watcher makes the marks in the pass that counts the new records, so they cost no read of their own.
News
One report from a watcher, for the follow named id.
Spool
Standard input being copied to a file while the file is read: the copy goes on after the first rows show, until the stream ends or the copy is stopped. The file is a temporary one, or the one --tee names, which the user keeps; with --tee -, a temporary one, and the stream is passed on to standard output too.
SpoolHandle
The open’s hold on a Spool: the copy stops when the last holder lets go, so a follow put down before its dataset arrived does not go on copying, and quitting finishes the file.
Tail
The complete records of a growing delimited or NDJSON file: where they end, and how many rows they hold. Extended with the bytes that arrive; a partial last record is not counted until its newline lands.
Tee
The file --tee named.

Enums§

Change
What the watcher found.
Spooled
What standard input was copied to.
Standing
Where the follow stands, as the control bar says it.

Constants§

DEFAULT_INTERVAL
How often the watcher checks the file, or where it hears of changes (Linux) the least time between two reads, unless [read] follow_interval says otherwise. A burst of appends inside one interval is one refresh.

Functions§

age
How long ago, elapsed, as the follow chip says it: in the largest whole unit, padded so the chip keeps its width as the number grows.
bound
lf reading the file at path only up to its first rows rows. A scan of it with no bound gets one right above it; one bounded already has its bound moved. The frames built on a scan carry the scan in their plans, so moving its bound moves what every one of them reads.
followable_path
Whether path’s format, as options say or its name does, is one --follow reads.
next_tick
When the age of an append made at at next reads differently.
read_through
lf reading the file at path through file, an open handle on it, rather than by its name: the file was deleted, and the handle still reads what it held.
refusal
Why format cannot be followed, or None when it can. Only text read line by line, and an Arrow IPC stream (see [followed_stream]), can: a file whose footer is written last (Parquet, an Arrow IPC file, Excel) cannot be read before it is finished, and a compressed one cannot be read from the middle.
refuse_paths
Why paths cannot be followed as options ask, before anything is read: only one local file, or standard input, can be.