Skip to content
go-libfossil Artifact [4d9e757497]
Login

Artifact [4d9e757497]

Artifact 4d9e7574978e02507a68c9de32b47bb5dc75574bbf4e706c25a012d4dc382d84:


package content

import (
	"context"
	"maps"
	"slices"

	"github.com/danmestas/go-libfossil/db"
)

// LoadAbsencesWithin is LoadAbsencesContext under injected budgets, and
// reports what classification read. The tests that use it are an external
// package: their fixtures need the manifest writer, which imports this one.
func LoadAbsencesWithin(
	ctx context.Context, q db.Querier, refs ReferenceBudget, treePerCheckin int64,
) (*Absences, ReferenceWork, error) {
	treeMax := treePerCheckin << 10
	if treeMax > defaultReferenceLimits.treeMax {
		treeMax = defaultReferenceLimits.treeMax
	}
	a, err := loadAbsences(ctx, q, referenceLimits{
		refs: refs, treePerCheckin: treePerCheckin, treeMax: treeMax,
	})
	if a == nil {
		return nil, ReferenceWork{}, err
	}
	return a, a.work, err
}

// LoadAbsencesWork is LoadAbsencesContext, reporting what classification
// read under the default budgets.
func LoadAbsencesWork(ctx context.Context, q db.Querier) (*Absences, ReferenceWork, error) {
	limits := defaultReferenceLimits
	return LoadAbsencesWithin(ctx, q, limits.refs, limits.treePerCheckin)
}

// TreesRead names the trees v's horizon walks read from the store, and
// counts the reads.
func (v *MemoView) TreesRead() (names []string, reads int) {
	return slices.Collect(maps.Keys(v.trees)), v.treeReads
}