Documentation
¶
Overview ¶
Package paged reads linked sources in place: Parquet files and SQLite tables or queries too big for any grid, linked as tables on tabs of their own (the engine's source.go). Its Host answers what a workbook's formulas and pivot tables ask of them (sheet.SourceHost) by streaming the sources in the background, keeping the answers until a source's file changes; its Pages are the rows a source's tab shows, read a page at a time as it scrolls.
The Host and Pages belong to the goroutine that owns the workbook (the UI's). What reads files runs as Jobs on other goroutines, over what the Job took with it, and hands its result back to be stored, so the owner never waits on a file.
Index ¶
- Constants
- func Apply(w *sheet.Workbook, d Done)
- func ShapeOf(h fileio.Source) sheet.SourceShape
- type Done
- type Host
- func (h *Host) Answer(q sheet.SourceQuestion) (sheet.SourceAnswer, bool)
- func (h *Host) Close()
- func (h *Host) Jobs() []*Job
- func (h *Host) Link(list []Linked) bool
- func (h *Host) Pending() bool
- func (h *Host) Poll() bool
- func (h *Host) Reload(name string)
- func (h *Host) Settle(ctx context.Context, w *sheet.Workbook, links []Linked)
- func (h *Host) Shape(name string) (sheet.SourceShape, string, bool)
- func (h *Host) Source(name string) (fileio.Source, int, bool)
- func (h *Host) Store(j *Job) Done
- type Job
- type Linked
- type Opener
- type PageJob
- type Pages
- func (p *Pages) Building() bool
- func (p *Pages) Close()
- func (p *Pages) Err() string
- func (p *Pages) Jobs() []*PageJob
- func (p *Pages) Of(h fileio.Source, gen int) bool
- func (p *Pages) Row(i int64) (int64, []sheet.LiveCell, bool)
- func (p *Pages) Rows() (int64, bool)
- func (p *Pages) Same(h fileio.Source, gen int, o *sheet.SourceOrder) bool
- func (p *Pages) Store(j *PageJob) bool
- func (p *Pages) Want(from, to int64)
Constants ¶
const (
PageRows = 128
)
PageRows is how many rows a page holds; keepPages is how many are kept.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Done ¶
type Done struct {
// Keys are the questions answered.
Keys []string
// Opened names a source opened, or failing to, with its shape.
Opened string
Shape sheet.SourceShape
Err string
}
Done is what storing a job's result tells the workbook.
type Host ¶
type Host struct {
// Budget is how many cells a function that holds what it reads may
// read of a source, and a range read whole may have: max-cells.
Budget int
// Open opens a source; fileio.OpenSource unless replaced.
Open Opener
// Debounce is how long a changed file must hold still before it's
// read again.
Debounce time.Duration
// Now is the clock; tests replace it.
Now func() time.Time
// contains filtered or unexported fields
}
Host answers a workbook's questions about its linked sources.
func (*Host) Answer ¶
func (h *Host) Answer(q sheet.SourceQuestion) (sheet.SourceAnswer, bool)
Answer returns the answer to q, or false while it isn't known, queuing q to be worked out (sheet.SourceHost).
func (*Host) Jobs ¶
Jobs hands out the jobs queued since the last call, to run in the background, each once.
func (*Host) Link ¶
Link makes the host's sources the workbook's: new ones and those reading something else are opened, those gone are closed. It returns whether anything changed.
func (*Host) Poll ¶
Poll looks at each source's file, once they're open, and queues the ones that changed and have held still for Debounce to be read again, reporting whether it queued any. A file that goes away is noticed the same way.
func (*Host) Reload ¶
Reload reads the source named name again, as when its file changed: what was worked out of it is worked out again.
func (*Host) Settle ¶
Settle links the sources links names (Links), unless links is nil, and runs every job the host queues, one after another, applying each, until none is left: for what has no screen to keep live while they run (012 get, tests).
func (*Host) Shape ¶
Shape is what the host found of the source named name: its shape, or why it can't be read, and whether it has been opened.
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
A Job is work the host queued: opening a source, or answering a question by reading the sources it names. Run it on any goroutine, once, then give it back to Host.Store on the owner's.
type Linked ¶
type Linked struct {
Name string
Spec fileio.SourceSpec
}
Linked is a source as the workbook links it, its file resolved.
type PageJob ¶
type PageJob struct {
// contains filtered or unexported fields
}
PageJob builds a view or reads a page of it, on any goroutine.
type Pages ¶
type Pages struct {
// contains filtered or unexported fields
}
Pages are the rows a source's tab shows, in its view's order (a sort and a filter, pushed down to SQL or streamed: fileio.SourceView), read a page at a time as the tab scrolls, and at most keepPages of them kept, so memory stays bounded whatever the source's size. Building a sorted or filtered view reads the whole source once; until it's built, and while a page is on its way, the rows it would show aren't known.
func NewPages ¶
NewPages are the pages of the view of h, the gen'th opening of its source, ordered as o says.
func (*Pages) Building ¶
Building reports whether the view is being built; Err says why it couldn't be.
func (*Pages) Jobs ¶
Jobs hands out the reads asked for since the last call, to run in the background.
func (*Pages) Row ¶
Row is the view's row i: its number in the source and its values, with false while its page isn't read, which Want asks for.