Documentation
¶
Index ¶
- func LogSegCompare(a, b LogSegment) int
- func SortLogSegments(segments []*LogSegment)
- func StoreIndex(path string, idx *Index) error
- func WithinCommitRange(a, b *LogSegment) bool
- type Index
- type LogSegment
- func (s *LogSegment) AsPending() *LogSegment
- func (s *LogSegment) FromTony(data []byte, opts ...gomap.UnmapOption) error
- func (s *LogSegment) FromTonyIR(node *ir.Node, opts ...gomap.UnmapOption) error
- func (s *LogSegment) IsPoint() bool
- func (s *LogSegment) String() string
- func (s *LogSegment) ToTony(opts ...gomap.MapOption) ([]byte, error)
- func (s *LogSegment) ToTonyIR(opts ...gomap.MapOption) (*ir.Node, error)
- func (s *LogSegment) WithCommit(commitCount int64) *LogSegment
- type Tree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogSegCompare ¶
func LogSegCompare(a, b LogSegment) int
LogSegCompare compares 2 log segments by their start commit, start-tx, end-commit, end-tx, and path.
func SortLogSegments ¶
func SortLogSegments(segments []*LogSegment)
SortLogSegments sorts a slice of LogSegment pointers by commit count, then tx.
func StoreIndex ¶
StoreIndex persists the index to the given path. It writes to a temporary file first and then atomically renames it to the target path.
func WithinCommitRange ¶ added in v0.0.9
func WithinCommitRange(a, b *LogSegment) bool
Types ¶
type Index ¶
type Index struct {
sync.RWMutex
Name string // eg "" for root
Commits *Tree[LogSegment]
Children map[string]*Index // map from subdir names to sub indices
}
func Build ¶
Build reconstructs the index from the filesystem rooted at root. extract is a closure that takes a filesystem path and returns a LogSegment if the file represents one. If extract returns nil, the file is ignored.
func (*Index) Add ¶
func (i *Index) Add(seg *LogSegment)
func (*Index) GobEncode ¶
GobEncode implements the gob.GobEncoder interface. It flattens the Index into a list of LogSegments for serialization.
func (*Index) ListRange ¶ added in v0.0.9
ListRange returns the immediate child names at this index level. Returns the keys of the Children map.
func (*Index) LookupRange ¶
func (i *Index) LookupRange(vp string, from, to *int64) []LogSegment
func (*Index) Remove ¶
func (i *Index) Remove(seg *LogSegment) bool
type LogSegment ¶
type LogSegment struct {
StartCommit int64
StartTx int64
EndCommit int64
EndTx int64
RelPath string
}
func PointLogSegment ¶
func PointLogSegment(c, tx int64, p string) *LogSegment
func (*LogSegment) AsPending ¶ added in v0.0.9
func (s *LogSegment) AsPending() *LogSegment
AsPending returns a copy of the segment with commit counts zeroed (for pending files).
func (*LogSegment) FromTony ¶ added in v0.0.9
func (s *LogSegment) FromTony(data []byte, opts ...gomap.UnmapOption) error
FromTony parses Tony format bytes and populates LogSegment.
func (*LogSegment) FromTonyIR ¶ added in v0.0.9
func (s *LogSegment) FromTonyIR(node *ir.Node, opts ...gomap.UnmapOption) error
FromTonyIR populates LogSegment from a Tony IR node.
func (*LogSegment) IsPoint ¶
func (s *LogSegment) IsPoint() bool
IsPoint returns true if and only if this log segment represents a diff from the preceding commit.
func (*LogSegment) String ¶ added in v0.0.9
func (s *LogSegment) String() string
func (*LogSegment) ToTony ¶ added in v0.0.9
func (s *LogSegment) ToTony(opts ...gomap.MapOption) ([]byte, error)
ToTony converts LogSegment to Tony format bytes.
func (*LogSegment) WithCommit ¶ added in v0.0.9
func (s *LogSegment) WithCommit(commitCount int64) *LogSegment
WithCommit returns a copy of the segment with the commit count set. For point segments: sets both Start and End to commitCount. For compacted segments: keeps StartCommit, sets EndCommit to commitCount.
type Tree ¶
func (*Tree[T]) All ¶
All applies f to all elements in T in ascending order until f returns false. All returns whether or not f returns false