fsutil

package
v0.0.0-...-5477640 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2024 License: Apache-2.0, MIT Imports: 19 Imported by: 7

Documentation

Overview

Package fsutil provides utilities for implementing vfs.FileDescriptionImpl and vfs.FilesystemImpl.

Index

Constants

View Source
const (
	// minDegree is the minimum degree of an internal node in a Set B-tree.
	//
	//	- Any non-root node has at least minDegree-1 segments.
	//
	//	- Any non-root internal (non-leaf) node has at least minDegree children.
	//
	//	- The root node may have fewer than minDegree-1 segments, but it may
	// only have 0 segments if the tree is empty.
	//
	// Our implementation requires minDegree >= 3. Higher values of minDegree
	// usually improve performance, but increase memory usage for small sets.
	DirtyminDegree = 3

	DirtymaxDegree = 2 * DirtyminDegree
)
View Source
const (
	// minDegree is the minimum degree of an internal node in a Set B-tree.
	//
	//	- Any non-root node has at least minDegree-1 segments.
	//
	//	- Any non-root internal (non-leaf) node has at least minDegree children.
	//
	//	- The root node may have fewer than minDegree-1 segments, but it may
	// only have 0 segments if the tree is empty.
	//
	// Our implementation requires minDegree >= 3. Higher values of minDegree
	// usually improve performance, but increase memory usage for small sets.
	FileRangeminDegree = 3

	FileRangemaxDegree = 2 * FileRangeminDegree
)
View Source
const (
	// minDegree is the minimum degree of an internal node in a Set B-tree.
	//
	//	- Any non-root node has at least minDegree-1 segments.
	//
	//	- Any non-root internal (non-leaf) node has at least minDegree children.
	//
	//	- The root node may have fewer than minDegree-1 segments, but it may
	// only have 0 segments if the tree is empty.
	//
	// Our implementation requires minDegree >= 3. Higher values of minDegree
	// usually improve performance, but increase memory usage for small sets.
	FrameRefminDegree = 3

	FrameRefmaxDegree = 2 * FrameRefminDegree
)
View Source
const DirtytrackGaps = 0

trackGaps is an optional parameter.

If trackGaps is 1, the Set will track maximum gap size recursively, enabling the GapIterator.{Prev,Next}LargeEnoughGap functions. In this case, Key must be an unsigned integer.

trackGaps must be 0 or 1.

View Source
const FileRangetrackGaps = 0

trackGaps is an optional parameter.

If trackGaps is 1, the Set will track maximum gap size recursively, enabling the GapIterator.{Prev,Next}LargeEnoughGap functions. In this case, Key must be an unsigned integer.

trackGaps must be 0 or 1.

View Source
const FrameReftrackGaps = 0

trackGaps is an optional parameter.

If trackGaps is 1, the Set will track maximum gap size recursively, enabling the GapIterator.{Prev,Next}LargeEnoughGap functions. In this case, Key must be an unsigned integer.

trackGaps must be 0 or 1.

Variables

This section is empty.

Functions

func DirtyzeroNodeSlice

func DirtyzeroNodeSlice(slice []*Dirtynode)

func DirtyzeroValueSlice

func DirtyzeroValueSlice(slice []DirtyInfo)

func FileRangezeroNodeSlice

func FileRangezeroNodeSlice(slice []*FileRangenode)

func FileRangezeroValueSlice

func FileRangezeroValueSlice(slice []uint64)

func FrameRefzeroNodeSlice

func FrameRefzeroNodeSlice(slice []*FrameRefnode)

func FrameRefzeroValueSlice

func FrameRefzeroValueSlice(slice []FrameRefSegInfo)

func SyncDirty

func SyncDirty(ctx context.Context, mr memmap.MappableRange, cache *FileRangeSet, dirty *DirtySet, max uint64, mem memmap.File, writeAt func(ctx context.Context, srcs safemem.BlockSeq, offset uint64) (uint64, error)) error

SyncDirty passes pages in the range mr that are stored in cache and identified as dirty to writeAt, updating dirty to reflect successful writes. If writeAt returns a successful partial write, SyncDirty will call it repeatedly until all bytes have been written. max is the true size of the cached object; offsets beyond max will not be passed to writeAt, even if they are marked dirty.

func SyncDirtyAll

func SyncDirtyAll(ctx context.Context, cache *FileRangeSet, dirty *DirtySet, max uint64, mem memmap.File, writeAt func(ctx context.Context, srcs safemem.BlockSeq, offset uint64) (uint64, error)) error

SyncDirtyAll passes all pages stored in cache identified as dirty to writeAt, updating dirty to reflect successful writes. If writeAt returns a successful partial write, SyncDirtyAll will call it repeatedly until all bytes have been written. max is the true size of the cached object; offsets beyond max will not be passed to writeAt, even if they are marked dirty.

Types

type DirtyFlatSegment

type DirtyFlatSegment struct {
	Start uint64
	End   uint64
	Value DirtyInfo
}

FlatSegment represents a segment as a single object. FlatSegment is used as an intermediate representation for save/restore and tests.

+stateify savable

func (*DirtyFlatSegment) StateFields

func (d *DirtyFlatSegment) StateFields() []string

func (*DirtyFlatSegment) StateLoad

func (d *DirtyFlatSegment) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*DirtyFlatSegment) StateSave

func (d *DirtyFlatSegment) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*DirtyFlatSegment) StateTypeName

func (d *DirtyFlatSegment) StateTypeName() string

type DirtyGapIterator

type DirtyGapIterator struct {
	// contains filtered or unexported fields
}

A GapIterator is conceptually one of:

  • A pointer to a position between two segments, before the first segment, or after the last segment in a set, called a *gap*; or

  • A terminal iterator, which is a sentinel indicating that the end of iteration has been reached.

Note that the gap between two adjacent segments exists (iterators to it are non-terminal), but has a length of zero. GapIterator.IsEmpty returns true for such gaps. An empty set contains a single gap, spanning the entire range of the set's keys.

GapIterators are copyable values and are meaningfully equality-comparable. The zero value of GapIterator is a terminal iterator.

Unless otherwise specified, any mutation of a set invalidates all existing iterators into the set.

func (DirtyGapIterator) End

func (gap DirtyGapIterator) End() uint64

End is equivalent to Range().End, but should be preferred if only the end of the range is needed.

func (DirtyGapIterator) IsEmpty

func (gap DirtyGapIterator) IsEmpty() bool

IsEmpty returns true if the iterated gap is empty (that is, the "gap" is between two adjacent segments.)

func (DirtyGapIterator) NextGap

func (gap DirtyGapIterator) NextGap() DirtyGapIterator

NextGap returns the iterated gap's successor. If no such gap exists, NextGap returns a terminal iterator.

func (DirtyGapIterator) NextLargeEnoughGap

func (gap DirtyGapIterator) NextLargeEnoughGap(minSize uint64) DirtyGapIterator

NextLargeEnoughGap returns the iterated gap's first next gap with larger length than minSize. If not found, return a terminal gap iterator (does NOT include this gap itself).

Precondition: trackGaps must be 1.

func (DirtyGapIterator) NextSegment

func (gap DirtyGapIterator) NextSegment() DirtyIterator

NextSegment returns the segment immediately after the iterated gap. If no such segment exists, NextSegment returns a terminal iterator.

func (DirtyGapIterator) Ok

func (gap DirtyGapIterator) Ok() bool

Ok returns true if the iterator is not terminal. All other methods are only valid for non-terminal iterators.

func (DirtyGapIterator) PrevGap

func (gap DirtyGapIterator) PrevGap() DirtyGapIterator

PrevGap returns the iterated gap's predecessor. If no such gap exists, PrevGap returns a terminal iterator.

func (DirtyGapIterator) PrevLargeEnoughGap

func (gap DirtyGapIterator) PrevLargeEnoughGap(minSize uint64) DirtyGapIterator

PrevLargeEnoughGap returns the iterated gap's first prev gap with larger or equal length than minSize. If not found, return a terminal gap iterator (does NOT include this gap itself).

Precondition: trackGaps must be 1.

func (DirtyGapIterator) PrevSegment

func (gap DirtyGapIterator) PrevSegment() DirtyIterator

PrevSegment returns the segment immediately before the iterated gap. If no such segment exists, PrevSegment returns a terminal iterator.

func (DirtyGapIterator) Range

Range returns the range spanned by the iterated gap.

func (DirtyGapIterator) Start

func (gap DirtyGapIterator) Start() uint64

Start is equivalent to Range().Start, but should be preferred if only the start of the range is needed.

type DirtyInfo

type DirtyInfo struct {
	// Keep is true if the represented offset is concurrently writable, such
	// that writing the data for that offset back to the source does not
	// guarantee that the offset is clean (since it may be concurrently
	// rewritten after the writeback).
	Keep bool
}

DirtyInfo is the value type of DirtySet, and represents information about a Mappable offset that is dirty (the cached data for that offset is newer than its source).

+stateify savable

func (*DirtyInfo) StateFields

func (d *DirtyInfo) StateFields() []string

func (*DirtyInfo) StateLoad

func (d *DirtyInfo) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*DirtyInfo) StateSave

func (d *DirtyInfo) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*DirtyInfo) StateTypeName

func (d *DirtyInfo) StateTypeName() string

type DirtyIterator

type DirtyIterator struct {
	// contains filtered or unexported fields
}

A Iterator is conceptually one of:

  • A pointer to a segment in a set; or

  • A terminal iterator, which is a sentinel indicating that the end of iteration has been reached.

Iterators are copyable values and are meaningfully equality-comparable. The zero value of Iterator is a terminal iterator.

Unless otherwise specified, any mutation of a set invalidates all existing iterators into the set.

func DirtysegmentAfterPosition

func DirtysegmentAfterPosition(n *Dirtynode, i int) DirtyIterator

segmentAfterPosition returns the successor segment of the position given by n.children[i], which may or may not contain a child. If no such segment exists, segmentAfterPosition returns a terminal iterator.

func DirtysegmentBeforePosition

func DirtysegmentBeforePosition(n *Dirtynode, i int) DirtyIterator

segmentBeforePosition returns the predecessor segment of the position given by n.children[i], which may or may not contain a child. If no such segment exists, segmentBeforePosition returns a terminal iterator.

func (DirtyIterator) End

func (seg DirtyIterator) End() uint64

End is equivalent to Range().End, but should be preferred if only the end of the range is needed.

func (DirtyIterator) NextGap

func (seg DirtyIterator) NextGap() DirtyGapIterator

NextGap returns the gap immediately after the iterated segment.

func (DirtyIterator) NextNonEmpty

func (seg DirtyIterator) NextNonEmpty() (DirtyIterator, DirtyGapIterator)

NextNonEmpty returns the iterated segment's successor if it is adjacent, or the gap after the iterated segment otherwise. If seg.End() == Functions.MaxKey(), NextNonEmpty will return two terminal iterators. Otherwise, exactly one of the iterators returned by NextNonEmpty will be non-terminal.

func (DirtyIterator) NextSegment

func (seg DirtyIterator) NextSegment() DirtyIterator

NextSegment returns the iterated segment's successor. If there is no succeeding segment, NextSegment returns a terminal iterator.

func (DirtyIterator) Ok

func (seg DirtyIterator) Ok() bool

Ok returns true if the iterator is not terminal. All other methods are only valid for non-terminal iterators.

func (DirtyIterator) PrevGap

func (seg DirtyIterator) PrevGap() DirtyGapIterator

PrevGap returns the gap immediately before the iterated segment.

func (DirtyIterator) PrevNonEmpty

func (seg DirtyIterator) PrevNonEmpty() (DirtyIterator, DirtyGapIterator)

PrevNonEmpty returns the iterated segment's predecessor if it is adjacent, or the gap before the iterated segment otherwise. If seg.Start() == Functions.MinKey(), PrevNonEmpty will return two terminal iterators. Otherwise, exactly one of the iterators returned by PrevNonEmpty will be non-terminal.

func (DirtyIterator) PrevSegment

func (seg DirtyIterator) PrevSegment() DirtyIterator

PrevSegment returns the iterated segment's predecessor. If there is no preceding segment, PrevSegment returns a terminal iterator.

func (DirtyIterator) Range

Range returns the iterated segment's range key.

func (DirtyIterator) SetEnd

func (seg DirtyIterator) SetEnd(end uint64)

SetEnd mutates the iterated segment's end. If the new end value would cause the iterated segment to overlap another segment, or would result in an invalid range, SetEnd panics. This operation does not invalidate any iterators.

func (DirtyIterator) SetEndUnchecked

func (seg DirtyIterator) SetEndUnchecked(end uint64)

SetEndUnchecked mutates the iterated segment's end. This operation does not invalidate any iterators.

Preconditions: The new end must be valid:

  • end > seg.Start().
  • If seg.NextSegment().Ok(), then end <= seg.NextSegment().Start().

func (DirtyIterator) SetRange

SetRange mutates the iterated segment's range key. If the new range would cause the iterated segment to overlap another segment, or if the new range is invalid, SetRange panics. This operation does not invalidate any iterators.

func (DirtyIterator) SetRangeUnchecked

func (seg DirtyIterator) SetRangeUnchecked(r __generics_imported0.MappableRange)

SetRangeUnchecked mutates the iterated segment's range key. This operation does not invalidate any iterators.

Preconditions: - r.Length() > 0. - The new range must not overlap an existing one:

  • If seg.NextSegment().Ok(), then r.end <= seg.NextSegment().Start().
  • If seg.PrevSegment().Ok(), then r.start >= seg.PrevSegment().End().

func (DirtyIterator) SetStart

func (seg DirtyIterator) SetStart(start uint64)

SetStart mutates the iterated segment's start. If the new start value would cause the iterated segment to overlap another segment, or would result in an invalid range, SetStart panics. This operation does not invalidate any iterators.

func (DirtyIterator) SetStartUnchecked

func (seg DirtyIterator) SetStartUnchecked(start uint64)

SetStartUnchecked mutates the iterated segment's start. This operation does not invalidate any iterators.

Preconditions: The new start must be valid:

  • start < seg.End()
  • If seg.PrevSegment().Ok(), then start >= seg.PrevSegment().End().

func (DirtyIterator) SetValue

func (seg DirtyIterator) SetValue(val DirtyInfo)

SetValue mutates the iterated segment's value. This operation does not invalidate any iterators.

func (DirtyIterator) Start

func (seg DirtyIterator) Start() uint64

Start is equivalent to Range().Start, but should be preferred if only the start of the range is needed.

func (DirtyIterator) Value

func (seg DirtyIterator) Value() DirtyInfo

Value returns a copy of the iterated segment's value.

func (DirtyIterator) ValuePtr

func (seg DirtyIterator) ValuePtr() *DirtyInfo

ValuePtr returns a pointer to the iterated segment's value. The pointer is invalidated if the iterator is invalidated. This operation does not invalidate any iterators.

type DirtySet

type DirtySet struct {
	// contains filtered or unexported fields
}

A Set is a mapping of segments with non-overlapping Range keys. The zero value for a Set is an empty set. Set values are not safely movable nor copyable. Set is thread-compatible.

+stateify savable

func (*DirtySet) AllowClean

func (s *DirtySet) AllowClean(mr memmap.MappableRange)

AllowClean allows MarkClean to mark offsets in mr as not dirty, ending the effect of a previous call to KeepDirty. (It does not itself mark those offsets as not dirty.)

func (*DirtySet) ExportSlice

func (s *DirtySet) ExportSlice() []DirtyFlatSegment

ExportSlice returns a copy of all segments in the given set, in ascending key order.

func (*DirtySet) Find

Find returns the segment or gap whose range contains the given key. If a segment is found, the returned Iterator is non-terminal and the returned GapIterator is terminal. Otherwise, the returned Iterator is terminal and the returned GapIterator is non-terminal.

func (*DirtySet) FindGap

func (s *DirtySet) FindGap(key uint64) DirtyGapIterator

FindGap returns the gap containing the given key. If no such gap exists (i.e. the set contains a segment containing that key), FindGap returns a terminal iterator.

func (*DirtySet) FindSegment

func (s *DirtySet) FindSegment(key uint64) DirtyIterator

FindSegment returns the segment whose range contains the given key. If no such segment exists, FindSegment returns a terminal iterator.

func (*DirtySet) FirstGap

func (s *DirtySet) FirstGap() DirtyGapIterator

FirstGap returns the first gap in the set.

func (*DirtySet) FirstLargeEnoughGap

func (s *DirtySet) FirstLargeEnoughGap(minSize uint64) DirtyGapIterator

FirstLargeEnoughGap returns the first gap in the set with at least the given length. If no such gap exists, FirstLargeEnoughGap returns a terminal iterator.

Precondition: trackGaps must be 1.

func (*DirtySet) FirstSegment

func (s *DirtySet) FirstSegment() DirtyIterator

FirstSegment returns the first segment in the set. If the set is empty, FirstSegment returns a terminal iterator.

func (*DirtySet) ImportSlice

func (s *DirtySet) ImportSlice(fs []DirtyFlatSegment) error

ImportSlice initializes the given set from the given slice.

Preconditions:

  • s must be empty.
  • fs must represent a valid set (the segments in fs must have valid lengths that do not overlap).
  • The segments in fs must be sorted in ascending key order.

func (*DirtySet) Insert

Insert inserts the given segment into the given gap. If the new segment can be merged with adjacent segments, Insert will do so. Insert returns an iterator to the segment containing the inserted value (which may have been merged with other values). All existing iterators (including gap, but not including the returned iterator) are invalidated.

If the gap cannot accommodate the segment, or if r is invalid, Insert panics.

Insert is semantically equivalent to a InsertWithoutMerging followed by a Merge, but may be more efficient. Note that there is no unchecked variant of Insert since Insert must retrieve and inspect gap's predecessor and successor segments regardless.

func (*DirtySet) InsertRange

InsertRange inserts the given segment into the set. If the new segment can be merged with adjacent segments, InsertRange will do so. InsertRange returns an iterator to the segment containing the inserted value (which may have been merged with other values). All existing iterators (excluding the returned iterator) are invalidated.

If the new segment would overlap an existing segment, or if r is invalid, InsertRange panics.

InsertRange searches the set to find the gap to insert into. If the caller already has the appropriate GapIterator, or if the caller needs to do additional work between finding the gap and insertion, use Insert instead.

func (*DirtySet) InsertWithoutMerging

InsertWithoutMerging inserts the given segment into the given gap and returns an iterator to the inserted segment. All existing iterators (including gap, but not including the returned iterator) are invalidated.

If the gap cannot accommodate the segment, or if r is invalid, InsertWithoutMerging panics.

func (*DirtySet) InsertWithoutMergingRange

func (s *DirtySet) InsertWithoutMergingRange(r __generics_imported0.MappableRange, val DirtyInfo) DirtyIterator

InsertWithoutMergingRange inserts the given segment into the set and returns an iterator to the inserted segment. All existing iterators (excluding the returned iterator) are invalidated.

If the new segment would overlap an existing segment, or if r is invalid, InsertWithoutMergingRange panics.

InsertWithoutMergingRange searches the set to find the gap to insert into. If the caller already has the appropriate GapIterator, or if the caller needs to do additional work between finding the gap and insertion, use InsertWithoutMerging instead.

func (*DirtySet) InsertWithoutMergingUnchecked

func (s *DirtySet) InsertWithoutMergingUnchecked(gap DirtyGapIterator, r __generics_imported0.MappableRange, val DirtyInfo) DirtyIterator

InsertWithoutMergingUnchecked inserts the given segment into the given gap and returns an iterator to the inserted segment. All existing iterators (including gap, but not including the returned iterator) are invalidated.

Preconditions:

  • r.Start >= gap.Start().
  • r.End <= gap.End().

func (*DirtySet) IsEmpty

func (s *DirtySet) IsEmpty() bool

IsEmpty returns true if the set contains no segments.

func (*DirtySet) IsEmptyRange

func (s *DirtySet) IsEmptyRange(r __generics_imported0.MappableRange) bool

IsEmptyRange returns true iff no segments in the set overlap the given range. This is semantically equivalent to s.SpanRange(r) == 0, but may be more efficient.

func (*DirtySet) Isolate

Isolate ensures that the given segment's range is a subset of r by splitting at r.Start and r.End if necessary, and returns an updated iterator to the bounded segment. All existing iterators (including seg, but not including the returned iterators) are invalidated.

Isolate is usually used when mutating part of a single segment, or when mutating segments in a range where the first segment is not necessarily split, making use of SplitBefore/SplitAfter complex.

Preconditions: seg.Range().Overlaps(r).

func (*DirtySet) KeepClean

func (s *DirtySet) KeepClean(mr memmap.MappableRange)

KeepClean marks all offsets in mr as not dirty, even those that were previously kept dirty by KeepDirty.

func (*DirtySet) KeepDirty

func (s *DirtySet) KeepDirty(mr memmap.MappableRange)

KeepDirty marks all offsets in mr as dirty and prevents them from being marked as clean by MarkClean.

func (*DirtySet) LastGap

func (s *DirtySet) LastGap() DirtyGapIterator

LastGap returns the last gap in the set.

func (*DirtySet) LastLargeEnoughGap

func (s *DirtySet) LastLargeEnoughGap(minSize uint64) DirtyGapIterator

LastLargeEnoughGap returns the last gap in the set with at least the given length. If no such gap exists, LastLargeEnoughGap returns a terminal iterator.

Precondition: trackGaps must be 1.

func (*DirtySet) LastSegment

func (s *DirtySet) LastSegment() DirtyIterator

LastSegment returns the last segment in the set. If the set is empty, LastSegment returns a terminal iterator.

func (*DirtySet) LowerBoundGap

func (s *DirtySet) LowerBoundGap(min uint64) DirtyGapIterator

LowerBoundGap returns the gap with the lowest range that is greater than or equal to min.

func (*DirtySet) LowerBoundLargeEnoughGap

func (s *DirtySet) LowerBoundLargeEnoughGap(min, minSize uint64) DirtyGapIterator

LowerBoundLargeEnoughGap returns the first gap in the set with at least the given length and whose range contains a key greater than or equal to min. If no such gap exists, LowerBoundLargeEnoughGap returns a terminal iterator.

Precondition: trackGaps must be 1.

func (*DirtySet) LowerBoundSegment

func (s *DirtySet) LowerBoundSegment(min uint64) DirtyIterator

LowerBoundSegment returns the segment with the lowest range that contains a key greater than or equal to min. If no such segment exists, LowerBoundSegment returns a terminal iterator.

func (*DirtySet) LowerBoundSegmentSplitBefore

func (s *DirtySet) LowerBoundSegmentSplitBefore(min uint64) DirtyIterator

LowerBoundSegmentSplitBefore combines LowerBoundSegment and SplitBefore.

LowerBoundSegmentSplitBefore is usually used when mutating segments in a range while iterating them in order of increasing keys. In such cases, LowerBoundSegmentSplitBefore provides an iterator to the first segment to be mutated, suitable as the initial value for a loop variable.

func (*DirtySet) MarkClean

func (s *DirtySet) MarkClean(mr memmap.MappableRange)

MarkClean marks all offsets in mr as not dirty, except for those to which KeepDirty has been applied.

func (*DirtySet) MarkDirty

func (s *DirtySet) MarkDirty(mr memmap.MappableRange)

MarkDirty marks all offsets in mr as dirty.

func (*DirtySet) Merge

func (s *DirtySet) Merge(first, second DirtyIterator) DirtyIterator

Merge attempts to merge two neighboring segments. If successful, Merge returns an iterator to the merged segment, and all existing iterators are invalidated. Otherwise, Merge returns a terminal iterator.

If first is not the predecessor of second, Merge panics.

func (*DirtySet) MergeAll

func (s *DirtySet) MergeAll()

MergeAll merges all mergeable adjacent segments in the set. All existing iterators are invalidated.

func (*DirtySet) MergeInsideRange

func (s *DirtySet) MergeInsideRange(r __generics_imported0.MappableRange)

MergeInsideRange attempts to merge all adjacent segments that contain a key in the specific range. All existing iterators are invalidated.

MergeInsideRange only makes sense after mutating the set in a way that may change the mergeability of modified segments; callers should prefer to use MergePrev or MergeNext during the mutating loop instead (depending on the direction of iteration), in order to avoid a redundant search.

func (*DirtySet) MergeNext

func (s *DirtySet) MergeNext(seg DirtyIterator) DirtyIterator

MergeNext attempts to merge the given segment with its successor if possible, and returns an updated iterator to the extended segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

MergeNext is usually used when mutating segments while iterating them in order of decreasing keys, to attempt merging of each mutated segment with its previously-mutated successor. In such cases, merging a mutated segment with its unmutated predecessor would incorrectly cause the latter to be skipped.

func (*DirtySet) MergeOutsideRange

func (s *DirtySet) MergeOutsideRange(r __generics_imported0.MappableRange)

MergeOutsideRange attempts to merge the segment containing r.Start with its predecessor, and the segment containing r.End-1 with its successor.

MergeOutsideRange only makes sense after mutating the set in a way that may change the mergeability of modified segments; callers should prefer to use MergePrev or MergeNext during the mutating loop instead (depending on the direction of iteration), in order to avoid two redundant searches.

func (*DirtySet) MergePrev

func (s *DirtySet) MergePrev(seg DirtyIterator) DirtyIterator

MergePrev attempts to merge the given segment with its predecessor if possible, and returns an updated iterator to the extended segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

MergePrev is usually used when mutating segments while iterating them in order of increasing keys, to attempt merging of each mutated segment with its previously-mutated predecessor. In such cases, merging a mutated segment with its unmutated successor would incorrectly cause the latter to be skipped.

func (*DirtySet) MergeUnchecked

func (s *DirtySet) MergeUnchecked(first, second DirtyIterator) DirtyIterator

MergeUnchecked attempts to merge two neighboring segments. If successful, MergeUnchecked returns an iterator to the merged segment, and all existing iterators are invalidated. Otherwise, MergeUnchecked returns a terminal iterator.

Precondition: first is the predecessor of second: first.NextSegment() == second, first == second.PrevSegment().

func (*DirtySet) MutateFullRange

func (s *DirtySet) MutateFullRange(r __generics_imported0.MappableRange, f func(seg DirtyIterator) bool)

MutateFullRange is equivalent to MutateRange, except that if any key in r that is visited before f returns false does not correspond to a segment, MutateFullRange panics.

func (*DirtySet) MutateRange

func (s *DirtySet) MutateRange(r __generics_imported0.MappableRange, f func(seg DirtyIterator) bool)

MutateRange applies the function f to all segments intersecting the range r, in order of ascending keys. Segments that lie partially outside r are split before f is called, such that f only observes segments entirely within r. Iterated segments are merged again after f is called. Non-empty gaps between segments are skipped. If a call to f returns false, MutateRange stops iteration immediately.

MutateRange invalidates all existing iterators.

N.B. f must not invalidate iterators into s.

func (*DirtySet) Remove

func (s *DirtySet) Remove(seg DirtyIterator) DirtyGapIterator

Remove removes the given segment and returns an iterator to the vacated gap. All existing iterators (including seg, but not including the returned iterator) are invalidated.

func (*DirtySet) RemoveAll

func (s *DirtySet) RemoveAll()

RemoveAll removes all segments from the set. All existing iterators are invalidated.

func (*DirtySet) RemoveFullRange

RemoveFullRange is equivalent to RemoveRange, except that if any key in the given range does not correspond to a segment, RemoveFullRange panics.

func (*DirtySet) RemoveFullRangeWith

func (s *DirtySet) RemoveFullRangeWith(r __generics_imported0.MappableRange, f func(seg DirtyIterator)) DirtyGapIterator

RemoveFullRangeWith is equivalent to RemoveRangeWith, except that if any key in the given range does not correspond to a segment, RemoveFullRangeWith panics.

func (*DirtySet) RemoveRange

RemoveRange removes all segments in the given range. An iterator to the newly formed gap is returned, and all existing iterators are invalidated.

RemoveRange searches the set to find segments to remove. If the caller already has an iterator to either end of the range of segments to remove, or if the caller needs to do additional work before removing each segment, iterate segments and call Remove in a loop instead.

func (*DirtySet) RemoveRangeWith

func (s *DirtySet) RemoveRangeWith(r __generics_imported0.MappableRange, f func(seg DirtyIterator)) DirtyGapIterator

RemoveRangeWith removes all segments in the given range. An iterator to the newly formed gap is returned, and all existing iterators are invalidated.

The function f is applied to each segment immediately before it is removed, in order of ascending keys. Segments that lie partially outside r are split before f is called, such that f only observes segments entirely within r. Non-empty gaps between segments are skipped.

RemoveRangeWith searches the set to find segments to remove. If the caller already has an iterator to either end of the range of segments to remove, or if the caller needs to do additional work before removing each segment, iterate segments and call Remove in a loop instead.

N.B. f must not invalidate iterators into s.

func (*DirtySet) Span

func (s *DirtySet) Span() uint64

Span returns the total size of all segments in the set.

func (*DirtySet) SpanRange

SpanRange returns the total size of the intersection of segments in the set with the given range.

func (*DirtySet) Split

func (s *DirtySet) Split(seg DirtyIterator, split uint64) (DirtyIterator, DirtyIterator)

Split splits the given segment at the given key and returns iterators to the two resulting segments. All existing iterators (including seg, but not including the returned iterators) are invalidated.

If the segment cannot be split at split (because split is at the start or end of the segment's range, so splitting would produce a segment with zero length, or because split falls outside the segment's range altogether), Split panics.

func (*DirtySet) SplitAfter

func (s *DirtySet) SplitAfter(seg DirtyIterator, end uint64) DirtyIterator

SplitAfter ensures that the given segment's end is at most end by splitting at end if necessary, and returns an updated iterator to the bounded segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

SplitAfter is usually used when mutating segments in a range. In such cases, when iterating segments in order of increasing keys, each iterated segment may extend beyond the end of the range to be mutated, and needs to be SplitAfter to ensure that only the part of the segment within the range is mutated. When iterating segments in order of decreasing keys, SplitBefore and SplitAfter exchange roles; i.e. SplitBefore needs to be invoked on each segment, while SplitAfter only needs to be invoked on the first.

Preconditions: seg.Start() < end.

func (*DirtySet) SplitBefore

func (s *DirtySet) SplitBefore(seg DirtyIterator, start uint64) DirtyIterator

SplitBefore ensures that the given segment's start is at least start by splitting at start if necessary, and returns an updated iterator to the bounded segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

SplitBefore is usually when mutating segments in a range. In such cases, when iterating segments in order of increasing keys, the first segment may extend beyond the start of the range to be mutated, and needs to be SplitBefore to ensure that only the part of the segment within the range is mutated. When iterating segments in order of decreasing keys, SplitBefore and SplitAfter; i.e. SplitBefore needs to be invoked on each segment, while SplitAfter only needs to be invoked on the first.

Preconditions: start < seg.End().

func (*DirtySet) SplitUnchecked

func (s *DirtySet) SplitUnchecked(seg DirtyIterator, split uint64) (DirtyIterator, DirtyIterator)

SplitUnchecked splits the given segment at the given key and returns iterators to the two resulting segments. All existing iterators (including seg, but not including the returned iterators) are invalidated.

Preconditions: seg.Start() < key < seg.End().

func (*DirtySet) StateFields

func (s *DirtySet) StateFields() []string

func (*DirtySet) StateLoad

func (s *DirtySet) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*DirtySet) StateSave

func (s *DirtySet) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*DirtySet) StateTypeName

func (s *DirtySet) StateTypeName() string

func (*DirtySet) String

func (s *DirtySet) String() string

String stringifies a Set for debugging.

func (*DirtySet) TryInsertRange

TryInsertRange attempts to insert the given segment into the set. If the new segment can be merged with adjacent segments, TryInsertRange will do so. TryInsertRange returns an iterator to the segment containing the inserted value (which may have been merged with other values). All existing iterators (excluding the returned iterator) are invalidated.

If the new segment would overlap an existing segment, TryInsertRange does nothing and returns a terminal iterator.

TryInsertRange searches the set to find the gap to insert into. If the caller already has the appropriate GapIterator, or if the caller needs to do additional work between finding the gap and insertion, use Insert instead.

func (*DirtySet) TryInsertWithoutMergingRange

func (s *DirtySet) TryInsertWithoutMergingRange(r __generics_imported0.MappableRange, val DirtyInfo) DirtyIterator

TryInsertWithoutMergingRange attempts to insert the given segment into the set. If successful, it returns an iterator to the inserted segment; all existing iterators (excluding the returned iterator) are invalidated. If the new segment would overlap an existing segment, TryInsertWithoutMergingRange does nothing and returns a terminal iterator.

TryInsertWithoutMergingRange searches the set to find the gap to insert into. If the caller already has the appropriate GapIterator, or if the caller needs to do additional work between finding the gap and insertion, use InsertWithoutMerging instead.

func (*DirtySet) Unisolate

func (s *DirtySet) Unisolate(seg DirtyIterator) DirtyIterator

Unisolate attempts to merge the given segment with its predecessor and successor if possible, and returns an updated iterator to the extended segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

Unisolate is usually used in conjunction with Isolate when mutating part of a single segment in a way that may affect its mergeability. For the reasons described by MergePrev and MergeNext, it is usually incorrect to use the return value of Unisolate in a loop variable.

func (*DirtySet) UpperBoundGap

func (s *DirtySet) UpperBoundGap(max uint64) DirtyGapIterator

UpperBoundGap returns the gap with the highest range that is less than or equal to max.

func (*DirtySet) UpperBoundLargeEnoughGap

func (s *DirtySet) UpperBoundLargeEnoughGap(max, minSize uint64) DirtyGapIterator

UpperBoundLargeEnoughGap returns the last gap in the set with at least the given length and whose range contains a key less than or equal to max. If no such gap exists, UpperBoundLargeEnoughGap returns a terminal iterator.

Precondition: trackGaps must be 1.

func (*DirtySet) UpperBoundSegment

func (s *DirtySet) UpperBoundSegment(max uint64) DirtyIterator

UpperBoundSegment returns the segment with the highest range that contains a key less than or equal to max. If no such segment exists, UpperBoundSegment returns a terminal iterator.

func (*DirtySet) UpperBoundSegmentSplitAfter

func (s *DirtySet) UpperBoundSegmentSplitAfter(max uint64) DirtyIterator

UpperBoundSegmentSplitAfter combines UpperBoundSegment and SplitAfter.

UpperBoundSegmentSplitAfter is usually used when mutating segments in a range while iterating them in order of decreasing keys. In such cases, UpperBoundSegmentSplitAfter provides an iterator to the first segment to be mutated, suitable as the initial value for a loop variable.

func (*DirtySet) VisitFullRange

func (s *DirtySet) VisitFullRange(r __generics_imported0.MappableRange, f func(seg DirtyIterator) bool)

VisitFullRange is equivalent to VisitRange, except that if any key in r that is visited before f returns false does not correspond to a segment, VisitFullRange panics.

func (*DirtySet) VisitRange

func (s *DirtySet) VisitRange(r __generics_imported0.MappableRange, f func(seg DirtyIterator) bool)

VisitRange applies the function f to all segments intersecting the range r, in order of ascending keys. Segments will not be split, so f may be called on segments lying partially outside r. Non-empty gaps between segments are skipped. If a call to f returns false, VisitRange stops iteration immediately.

N.B. f must not invalidate iterators into s.

type DirtydynamicGap

type DirtydynamicGap [DirtytrackGaps]uint64

dynamicGap is a type that disappears if trackGaps is 0.

func (*DirtydynamicGap) Get

func (d *DirtydynamicGap) Get() uint64

Get returns the value of the gap.

Precondition: trackGaps must be non-zero.

func (*DirtydynamicGap) Set

func (d *DirtydynamicGap) Set(v uint64)

Set sets the value of the gap.

Precondition: trackGaps must be non-zero.

type Dirtynode

type Dirtynode struct {
	// contains filtered or unexported fields
}

+stateify savable

func (*Dirtynode) StateFields

func (n *Dirtynode) StateFields() []string

func (*Dirtynode) StateLoad

func (n *Dirtynode) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*Dirtynode) StateSave

func (n *Dirtynode) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*Dirtynode) StateTypeName

func (n *Dirtynode) StateTypeName() string

func (*Dirtynode) String

func (n *Dirtynode) String() string

String stringifies a node (and all of its children) for debugging.

type FileRangeFlatSegment

type FileRangeFlatSegment struct {
	Start uint64
	End   uint64
	Value uint64
}

FlatSegment represents a segment as a single object. FlatSegment is used as an intermediate representation for save/restore and tests.

+stateify savable

func (*FileRangeFlatSegment) StateFields

func (f *FileRangeFlatSegment) StateFields() []string

func (*FileRangeFlatSegment) StateLoad

func (f *FileRangeFlatSegment) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*FileRangeFlatSegment) StateSave

func (f *FileRangeFlatSegment) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*FileRangeFlatSegment) StateTypeName

func (f *FileRangeFlatSegment) StateTypeName() string

type FileRangeGapIterator

type FileRangeGapIterator struct {
	// contains filtered or unexported fields
}

A GapIterator is conceptually one of:

  • A pointer to a position between two segments, before the first segment, or after the last segment in a set, called a *gap*; or

  • A terminal iterator, which is a sentinel indicating that the end of iteration has been reached.

Note that the gap between two adjacent segments exists (iterators to it are non-terminal), but has a length of zero. GapIterator.IsEmpty returns true for such gaps. An empty set contains a single gap, spanning the entire range of the set's keys.

GapIterators are copyable values and are meaningfully equality-comparable. The zero value of GapIterator is a terminal iterator.

Unless otherwise specified, any mutation of a set invalidates all existing iterators into the set.

func (FileRangeGapIterator) End

func (gap FileRangeGapIterator) End() uint64

End is equivalent to Range().End, but should be preferred if only the end of the range is needed.

func (FileRangeGapIterator) IsEmpty

func (gap FileRangeGapIterator) IsEmpty() bool

IsEmpty returns true if the iterated gap is empty (that is, the "gap" is between two adjacent segments.)

func (FileRangeGapIterator) NextGap

NextGap returns the iterated gap's successor. If no such gap exists, NextGap returns a terminal iterator.

func (FileRangeGapIterator) NextLargeEnoughGap

func (gap FileRangeGapIterator) NextLargeEnoughGap(minSize uint64) FileRangeGapIterator

NextLargeEnoughGap returns the iterated gap's first next gap with larger length than minSize. If not found, return a terminal gap iterator (does NOT include this gap itself).

Precondition: trackGaps must be 1.

func (FileRangeGapIterator) NextSegment

func (gap FileRangeGapIterator) NextSegment() FileRangeIterator

NextSegment returns the segment immediately after the iterated gap. If no such segment exists, NextSegment returns a terminal iterator.

func (FileRangeGapIterator) Ok

func (gap FileRangeGapIterator) Ok() bool

Ok returns true if the iterator is not terminal. All other methods are only valid for non-terminal iterators.

func (FileRangeGapIterator) PrevGap

PrevGap returns the iterated gap's predecessor. If no such gap exists, PrevGap returns a terminal iterator.

func (FileRangeGapIterator) PrevLargeEnoughGap

func (gap FileRangeGapIterator) PrevLargeEnoughGap(minSize uint64) FileRangeGapIterator

PrevLargeEnoughGap returns the iterated gap's first prev gap with larger or equal length than minSize. If not found, return a terminal gap iterator (does NOT include this gap itself).

Precondition: trackGaps must be 1.

func (FileRangeGapIterator) PrevSegment

func (gap FileRangeGapIterator) PrevSegment() FileRangeIterator

PrevSegment returns the segment immediately before the iterated gap. If no such segment exists, PrevSegment returns a terminal iterator.

func (FileRangeGapIterator) Range

Range returns the range spanned by the iterated gap.

func (FileRangeGapIterator) Start

func (gap FileRangeGapIterator) Start() uint64

Start is equivalent to Range().Start, but should be preferred if only the start of the range is needed.

type FileRangeIterator

type FileRangeIterator struct {
	// contains filtered or unexported fields
}

A Iterator is conceptually one of:

  • A pointer to a segment in a set; or

  • A terminal iterator, which is a sentinel indicating that the end of iteration has been reached.

Iterators are copyable values and are meaningfully equality-comparable. The zero value of Iterator is a terminal iterator.

Unless otherwise specified, any mutation of a set invalidates all existing iterators into the set.

func FileRangesegmentAfterPosition

func FileRangesegmentAfterPosition(n *FileRangenode, i int) FileRangeIterator

segmentAfterPosition returns the successor segment of the position given by n.children[i], which may or may not contain a child. If no such segment exists, segmentAfterPosition returns a terminal iterator.

func FileRangesegmentBeforePosition

func FileRangesegmentBeforePosition(n *FileRangenode, i int) FileRangeIterator

segmentBeforePosition returns the predecessor segment of the position given by n.children[i], which may or may not contain a child. If no such segment exists, segmentBeforePosition returns a terminal iterator.

func (FileRangeIterator) End

func (seg FileRangeIterator) End() uint64

End is equivalent to Range().End, but should be preferred if only the end of the range is needed.

func (FileRangeIterator) FileRange

func (seg FileRangeIterator) FileRange() memmap.FileRange

FileRange returns the FileRange mapped by seg.

func (FileRangeIterator) FileRangeOf

FileRangeOf returns the FileRange mapped by mr.

Preconditions:

  • seg.Range().IsSupersetOf(mr).
  • mr.Length() != 0.

func (FileRangeIterator) NextGap

NextGap returns the gap immediately after the iterated segment.

func (FileRangeIterator) NextNonEmpty

NextNonEmpty returns the iterated segment's successor if it is adjacent, or the gap after the iterated segment otherwise. If seg.End() == Functions.MaxKey(), NextNonEmpty will return two terminal iterators. Otherwise, exactly one of the iterators returned by NextNonEmpty will be non-terminal.

func (FileRangeIterator) NextSegment

func (seg FileRangeIterator) NextSegment() FileRangeIterator

NextSegment returns the iterated segment's successor. If there is no succeeding segment, NextSegment returns a terminal iterator.

func (FileRangeIterator) Ok

func (seg FileRangeIterator) Ok() bool

Ok returns true if the iterator is not terminal. All other methods are only valid for non-terminal iterators.

func (FileRangeIterator) PrevGap

PrevGap returns the gap immediately before the iterated segment.

func (FileRangeIterator) PrevNonEmpty

PrevNonEmpty returns the iterated segment's predecessor if it is adjacent, or the gap before the iterated segment otherwise. If seg.Start() == Functions.MinKey(), PrevNonEmpty will return two terminal iterators. Otherwise, exactly one of the iterators returned by PrevNonEmpty will be non-terminal.

func (FileRangeIterator) PrevSegment

func (seg FileRangeIterator) PrevSegment() FileRangeIterator

PrevSegment returns the iterated segment's predecessor. If there is no preceding segment, PrevSegment returns a terminal iterator.

func (FileRangeIterator) Range

Range returns the iterated segment's range key.

func (FileRangeIterator) SetEnd

func (seg FileRangeIterator) SetEnd(end uint64)

SetEnd mutates the iterated segment's end. If the new end value would cause the iterated segment to overlap another segment, or would result in an invalid range, SetEnd panics. This operation does not invalidate any iterators.

func (FileRangeIterator) SetEndUnchecked

func (seg FileRangeIterator) SetEndUnchecked(end uint64)

SetEndUnchecked mutates the iterated segment's end. This operation does not invalidate any iterators.

Preconditions: The new end must be valid:

  • end > seg.Start().
  • If seg.NextSegment().Ok(), then end <= seg.NextSegment().Start().

func (FileRangeIterator) SetRange

SetRange mutates the iterated segment's range key. If the new range would cause the iterated segment to overlap another segment, or if the new range is invalid, SetRange panics. This operation does not invalidate any iterators.

func (FileRangeIterator) SetRangeUnchecked

func (seg FileRangeIterator) SetRangeUnchecked(r __generics_imported0.MappableRange)

SetRangeUnchecked mutates the iterated segment's range key. This operation does not invalidate any iterators.

Preconditions: - r.Length() > 0. - The new range must not overlap an existing one:

  • If seg.NextSegment().Ok(), then r.end <= seg.NextSegment().Start().
  • If seg.PrevSegment().Ok(), then r.start >= seg.PrevSegment().End().

func (FileRangeIterator) SetStart

func (seg FileRangeIterator) SetStart(start uint64)

SetStart mutates the iterated segment's start. If the new start value would cause the iterated segment to overlap another segment, or would result in an invalid range, SetStart panics. This operation does not invalidate any iterators.

func (FileRangeIterator) SetStartUnchecked

func (seg FileRangeIterator) SetStartUnchecked(start uint64)

SetStartUnchecked mutates the iterated segment's start. This operation does not invalidate any iterators.

Preconditions: The new start must be valid:

  • start < seg.End()
  • If seg.PrevSegment().Ok(), then start >= seg.PrevSegment().End().

func (FileRangeIterator) SetValue

func (seg FileRangeIterator) SetValue(val uint64)

SetValue mutates the iterated segment's value. This operation does not invalidate any iterators.

func (FileRangeIterator) Start

func (seg FileRangeIterator) Start() uint64

Start is equivalent to Range().Start, but should be preferred if only the start of the range is needed.

func (FileRangeIterator) Value

func (seg FileRangeIterator) Value() uint64

Value returns a copy of the iterated segment's value.

func (FileRangeIterator) ValuePtr

func (seg FileRangeIterator) ValuePtr() *uint64

ValuePtr returns a pointer to the iterated segment's value. The pointer is invalidated if the iterator is invalidated. This operation does not invalidate any iterators.

type FileRangeSet

type FileRangeSet struct {
	// contains filtered or unexported fields
}

A Set is a mapping of segments with non-overlapping Range keys. The zero value for a Set is an empty set. Set values are not safely movable nor copyable. Set is thread-compatible.

+stateify savable

func (*FileRangeSet) Drop

Drop removes segments for memmap.Mappable offsets in mr, freeing the corresponding memmap.FileRanges.

Preconditions: mr must be page-aligned.

func (*FileRangeSet) DropAll

func (s *FileRangeSet) DropAll(mf *pgalloc.MemoryFile) uint64

DropAll removes all segments in mr, freeing the corresponding memmap.FileRanges. It returns the number of pages freed.

func (*FileRangeSet) ExportSlice

func (s *FileRangeSet) ExportSlice() []FileRangeFlatSegment

ExportSlice returns a copy of all segments in the given set, in ascending key order.

func (*FileRangeSet) Fill

func (s *FileRangeSet) Fill(ctx context.Context, required, optional memmap.MappableRange, fileSize uint64, mf *pgalloc.MemoryFile, opts pgalloc.AllocOpts, readAt func(ctx context.Context, dsts safemem.BlockSeq, offset uint64) (uint64, error)) (uint64, error)

Fill attempts to ensure that all memmap.Mappable offsets in required are mapped to a memmap.File offset, by allocating from mf with the given options and invoking readAt to store data into memory. (If readAt is not nil, opts.ReaderFunc will be overridden. If readAt returns a successful partial read, Fill will call it repeatedly until all bytes have been read.) EOF is handled consistently with the requirements of mmap(2): bytes after EOF on the same page are zeroed; pages after EOF are invalid. fileSize is an upper bound on the file's size; bytes after fileSize will be zeroed without calling readAt.

Fill may read offsets outside of required, but will never read offsets outside of optional. It returns a non-nil error if any error occurs, even if the error only affects offsets in optional, but not in required.

Fill returns the number of pages that were allocated.

Preconditions:

  • required.Length() > 0.
  • optional.IsSupersetOf(required).
  • required and optional must be page-aligned.

func (*FileRangeSet) Find

Find returns the segment or gap whose range contains the given key. If a segment is found, the returned Iterator is non-terminal and the returned GapIterator is terminal. Otherwise, the returned Iterator is terminal and the returned GapIterator is non-terminal.

func (*FileRangeSet) FindGap

func (s *FileRangeSet) FindGap(key uint64) FileRangeGapIterator

FindGap returns the gap containing the given key. If no such gap exists (i.e. the set contains a segment containing that key), FindGap returns a terminal iterator.

func (*FileRangeSet) FindSegment

func (s *FileRangeSet) FindSegment(key uint64) FileRangeIterator

FindSegment returns the segment whose range contains the given key. If no such segment exists, FindSegment returns a terminal iterator.

func (*FileRangeSet) FirstGap

func (s *FileRangeSet) FirstGap() FileRangeGapIterator

FirstGap returns the first gap in the set.

func (*FileRangeSet) FirstLargeEnoughGap

func (s *FileRangeSet) FirstLargeEnoughGap(minSize uint64) FileRangeGapIterator

FirstLargeEnoughGap returns the first gap in the set with at least the given length. If no such gap exists, FirstLargeEnoughGap returns a terminal iterator.

Precondition: trackGaps must be 1.

func (*FileRangeSet) FirstSegment

func (s *FileRangeSet) FirstSegment() FileRangeIterator

FirstSegment returns the first segment in the set. If the set is empty, FirstSegment returns a terminal iterator.

func (*FileRangeSet) ImportSlice

func (s *FileRangeSet) ImportSlice(fs []FileRangeFlatSegment) error

ImportSlice initializes the given set from the given slice.

Preconditions:

  • s must be empty.
  • fs must represent a valid set (the segments in fs must have valid lengths that do not overlap).
  • The segments in fs must be sorted in ascending key order.

func (*FileRangeSet) Insert

Insert inserts the given segment into the given gap. If the new segment can be merged with adjacent segments, Insert will do so. Insert returns an iterator to the segment containing the inserted value (which may have been merged with other values). All existing iterators (including gap, but not including the returned iterator) are invalidated.

If the gap cannot accommodate the segment, or if r is invalid, Insert panics.

Insert is semantically equivalent to a InsertWithoutMerging followed by a Merge, but may be more efficient. Note that there is no unchecked variant of Insert since Insert must retrieve and inspect gap's predecessor and successor segments regardless.

func (*FileRangeSet) InsertRange

InsertRange inserts the given segment into the set. If the new segment can be merged with adjacent segments, InsertRange will do so. InsertRange returns an iterator to the segment containing the inserted value (which may have been merged with other values). All existing iterators (excluding the returned iterator) are invalidated.

If the new segment would overlap an existing segment, or if r is invalid, InsertRange panics.

InsertRange searches the set to find the gap to insert into. If the caller already has the appropriate GapIterator, or if the caller needs to do additional work between finding the gap and insertion, use Insert instead.

func (*FileRangeSet) InsertWithoutMerging

InsertWithoutMerging inserts the given segment into the given gap and returns an iterator to the inserted segment. All existing iterators (including gap, but not including the returned iterator) are invalidated.

If the gap cannot accommodate the segment, or if r is invalid, InsertWithoutMerging panics.

func (*FileRangeSet) InsertWithoutMergingRange

func (s *FileRangeSet) InsertWithoutMergingRange(r __generics_imported0.MappableRange, val uint64) FileRangeIterator

InsertWithoutMergingRange inserts the given segment into the set and returns an iterator to the inserted segment. All existing iterators (excluding the returned iterator) are invalidated.

If the new segment would overlap an existing segment, or if r is invalid, InsertWithoutMergingRange panics.

InsertWithoutMergingRange searches the set to find the gap to insert into. If the caller already has the appropriate GapIterator, or if the caller needs to do additional work between finding the gap and insertion, use InsertWithoutMerging instead.

func (*FileRangeSet) InsertWithoutMergingUnchecked

func (s *FileRangeSet) InsertWithoutMergingUnchecked(gap FileRangeGapIterator, r __generics_imported0.MappableRange, val uint64) FileRangeIterator

InsertWithoutMergingUnchecked inserts the given segment into the given gap and returns an iterator to the inserted segment. All existing iterators (including gap, but not including the returned iterator) are invalidated.

Preconditions:

  • r.Start >= gap.Start().
  • r.End <= gap.End().

func (*FileRangeSet) IsEmpty

func (s *FileRangeSet) IsEmpty() bool

IsEmpty returns true if the set contains no segments.

func (*FileRangeSet) IsEmptyRange

IsEmptyRange returns true iff no segments in the set overlap the given range. This is semantically equivalent to s.SpanRange(r) == 0, but may be more efficient.

func (*FileRangeSet) Isolate

Isolate ensures that the given segment's range is a subset of r by splitting at r.Start and r.End if necessary, and returns an updated iterator to the bounded segment. All existing iterators (including seg, but not including the returned iterators) are invalidated.

Isolate is usually used when mutating part of a single segment, or when mutating segments in a range where the first segment is not necessarily split, making use of SplitBefore/SplitAfter complex.

Preconditions: seg.Range().Overlaps(r).

func (*FileRangeSet) LastGap

func (s *FileRangeSet) LastGap() FileRangeGapIterator

LastGap returns the last gap in the set.

func (*FileRangeSet) LastLargeEnoughGap

func (s *FileRangeSet) LastLargeEnoughGap(minSize uint64) FileRangeGapIterator

LastLargeEnoughGap returns the last gap in the set with at least the given length. If no such gap exists, LastLargeEnoughGap returns a terminal iterator.

Precondition: trackGaps must be 1.

func (*FileRangeSet) LastSegment

func (s *FileRangeSet) LastSegment() FileRangeIterator

LastSegment returns the last segment in the set. If the set is empty, LastSegment returns a terminal iterator.

func (*FileRangeSet) LowerBoundGap

func (s *FileRangeSet) LowerBoundGap(min uint64) FileRangeGapIterator

LowerBoundGap returns the gap with the lowest range that is greater than or equal to min.

func (*FileRangeSet) LowerBoundLargeEnoughGap

func (s *FileRangeSet) LowerBoundLargeEnoughGap(min, minSize uint64) FileRangeGapIterator

LowerBoundLargeEnoughGap returns the first gap in the set with at least the given length and whose range contains a key greater than or equal to min. If no such gap exists, LowerBoundLargeEnoughGap returns a terminal iterator.

Precondition: trackGaps must be 1.

func (*FileRangeSet) LowerBoundSegment

func (s *FileRangeSet) LowerBoundSegment(min uint64) FileRangeIterator

LowerBoundSegment returns the segment with the lowest range that contains a key greater than or equal to min. If no such segment exists, LowerBoundSegment returns a terminal iterator.

func (*FileRangeSet) LowerBoundSegmentSplitBefore

func (s *FileRangeSet) LowerBoundSegmentSplitBefore(min uint64) FileRangeIterator

LowerBoundSegmentSplitBefore combines LowerBoundSegment and SplitBefore.

LowerBoundSegmentSplitBefore is usually used when mutating segments in a range while iterating them in order of increasing keys. In such cases, LowerBoundSegmentSplitBefore provides an iterator to the first segment to be mutated, suitable as the initial value for a loop variable.

func (*FileRangeSet) Merge

func (s *FileRangeSet) Merge(first, second FileRangeIterator) FileRangeIterator

Merge attempts to merge two neighboring segments. If successful, Merge returns an iterator to the merged segment, and all existing iterators are invalidated. Otherwise, Merge returns a terminal iterator.

If first is not the predecessor of second, Merge panics.

func (*FileRangeSet) MergeAll

func (s *FileRangeSet) MergeAll()

MergeAll merges all mergeable adjacent segments in the set. All existing iterators are invalidated.

func (*FileRangeSet) MergeInsideRange

func (s *FileRangeSet) MergeInsideRange(r __generics_imported0.MappableRange)

MergeInsideRange attempts to merge all adjacent segments that contain a key in the specific range. All existing iterators are invalidated.

MergeInsideRange only makes sense after mutating the set in a way that may change the mergeability of modified segments; callers should prefer to use MergePrev or MergeNext during the mutating loop instead (depending on the direction of iteration), in order to avoid a redundant search.

func (*FileRangeSet) MergeNext

MergeNext attempts to merge the given segment with its successor if possible, and returns an updated iterator to the extended segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

MergeNext is usually used when mutating segments while iterating them in order of decreasing keys, to attempt merging of each mutated segment with its previously-mutated successor. In such cases, merging a mutated segment with its unmutated predecessor would incorrectly cause the latter to be skipped.

func (*FileRangeSet) MergeOutsideRange

func (s *FileRangeSet) MergeOutsideRange(r __generics_imported0.MappableRange)

MergeOutsideRange attempts to merge the segment containing r.Start with its predecessor, and the segment containing r.End-1 with its successor.

MergeOutsideRange only makes sense after mutating the set in a way that may change the mergeability of modified segments; callers should prefer to use MergePrev or MergeNext during the mutating loop instead (depending on the direction of iteration), in order to avoid two redundant searches.

func (*FileRangeSet) MergePrev

MergePrev attempts to merge the given segment with its predecessor if possible, and returns an updated iterator to the extended segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

MergePrev is usually used when mutating segments while iterating them in order of increasing keys, to attempt merging of each mutated segment with its previously-mutated predecessor. In such cases, merging a mutated segment with its unmutated successor would incorrectly cause the latter to be skipped.

func (*FileRangeSet) MergeUnchecked

func (s *FileRangeSet) MergeUnchecked(first, second FileRangeIterator) FileRangeIterator

MergeUnchecked attempts to merge two neighboring segments. If successful, MergeUnchecked returns an iterator to the merged segment, and all existing iterators are invalidated. Otherwise, MergeUnchecked returns a terminal iterator.

Precondition: first is the predecessor of second: first.NextSegment() == second, first == second.PrevSegment().

func (*FileRangeSet) MutateFullRange

func (s *FileRangeSet) MutateFullRange(r __generics_imported0.MappableRange, f func(seg FileRangeIterator) bool)

MutateFullRange is equivalent to MutateRange, except that if any key in r that is visited before f returns false does not correspond to a segment, MutateFullRange panics.

func (*FileRangeSet) MutateRange

func (s *FileRangeSet) MutateRange(r __generics_imported0.MappableRange, f func(seg FileRangeIterator) bool)

MutateRange applies the function f to all segments intersecting the range r, in order of ascending keys. Segments that lie partially outside r are split before f is called, such that f only observes segments entirely within r. Iterated segments are merged again after f is called. Non-empty gaps between segments are skipped. If a call to f returns false, MutateRange stops iteration immediately.

MutateRange invalidates all existing iterators.

N.B. f must not invalidate iterators into s.

func (*FileRangeSet) PagesToFill

func (s *FileRangeSet) PagesToFill(required, optional memmap.MappableRange) uint64

PagesToFill returns the number of pages that that Fill() will allocate for the given required and optional parameters.

func (*FileRangeSet) Remove

Remove removes the given segment and returns an iterator to the vacated gap. All existing iterators (including seg, but not including the returned iterator) are invalidated.

func (*FileRangeSet) RemoveAll

func (s *FileRangeSet) RemoveAll()

RemoveAll removes all segments from the set. All existing iterators are invalidated.

func (*FileRangeSet) RemoveFullRange

RemoveFullRange is equivalent to RemoveRange, except that if any key in the given range does not correspond to a segment, RemoveFullRange panics.

func (*FileRangeSet) RemoveFullRangeWith

RemoveFullRangeWith is equivalent to RemoveRangeWith, except that if any key in the given range does not correspond to a segment, RemoveFullRangeWith panics.

func (*FileRangeSet) RemoveRange

RemoveRange removes all segments in the given range. An iterator to the newly formed gap is returned, and all existing iterators are invalidated.

RemoveRange searches the set to find segments to remove. If the caller already has an iterator to either end of the range of segments to remove, or if the caller needs to do additional work before removing each segment, iterate segments and call Remove in a loop instead.

func (*FileRangeSet) RemoveRangeWith

RemoveRangeWith removes all segments in the given range. An iterator to the newly formed gap is returned, and all existing iterators are invalidated.

The function f is applied to each segment immediately before it is removed, in order of ascending keys. Segments that lie partially outside r are split before f is called, such that f only observes segments entirely within r. Non-empty gaps between segments are skipped.

RemoveRangeWith searches the set to find segments to remove. If the caller already has an iterator to either end of the range of segments to remove, or if the caller needs to do additional work before removing each segment, iterate segments and call Remove in a loop instead.

N.B. f must not invalidate iterators into s.

func (*FileRangeSet) Span

func (s *FileRangeSet) Span() uint64

Span returns the total size of all segments in the set.

func (*FileRangeSet) SpanRange

SpanRange returns the total size of the intersection of segments in the set with the given range.

func (*FileRangeSet) Split

Split splits the given segment at the given key and returns iterators to the two resulting segments. All existing iterators (including seg, but not including the returned iterators) are invalidated.

If the segment cannot be split at split (because split is at the start or end of the segment's range, so splitting would produce a segment with zero length, or because split falls outside the segment's range altogether), Split panics.

func (*FileRangeSet) SplitAfter

func (s *FileRangeSet) SplitAfter(seg FileRangeIterator, end uint64) FileRangeIterator

SplitAfter ensures that the given segment's end is at most end by splitting at end if necessary, and returns an updated iterator to the bounded segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

SplitAfter is usually used when mutating segments in a range. In such cases, when iterating segments in order of increasing keys, each iterated segment may extend beyond the end of the range to be mutated, and needs to be SplitAfter to ensure that only the part of the segment within the range is mutated. When iterating segments in order of decreasing keys, SplitBefore and SplitAfter exchange roles; i.e. SplitBefore needs to be invoked on each segment, while SplitAfter only needs to be invoked on the first.

Preconditions: seg.Start() < end.

func (*FileRangeSet) SplitBefore

func (s *FileRangeSet) SplitBefore(seg FileRangeIterator, start uint64) FileRangeIterator

SplitBefore ensures that the given segment's start is at least start by splitting at start if necessary, and returns an updated iterator to the bounded segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

SplitBefore is usually when mutating segments in a range. In such cases, when iterating segments in order of increasing keys, the first segment may extend beyond the start of the range to be mutated, and needs to be SplitBefore to ensure that only the part of the segment within the range is mutated. When iterating segments in order of decreasing keys, SplitBefore and SplitAfter; i.e. SplitBefore needs to be invoked on each segment, while SplitAfter only needs to be invoked on the first.

Preconditions: start < seg.End().

func (*FileRangeSet) SplitUnchecked

func (s *FileRangeSet) SplitUnchecked(seg FileRangeIterator, split uint64) (FileRangeIterator, FileRangeIterator)

SplitUnchecked splits the given segment at the given key and returns iterators to the two resulting segments. All existing iterators (including seg, but not including the returned iterators) are invalidated.

Preconditions: seg.Start() < key < seg.End().

func (*FileRangeSet) StateFields

func (s *FileRangeSet) StateFields() []string

func (*FileRangeSet) StateLoad

func (s *FileRangeSet) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*FileRangeSet) StateSave

func (s *FileRangeSet) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*FileRangeSet) StateTypeName

func (s *FileRangeSet) StateTypeName() string

func (*FileRangeSet) String

func (s *FileRangeSet) String() string

String stringifies a Set for debugging.

func (*FileRangeSet) Truncate

func (s *FileRangeSet) Truncate(end uint64, mf *pgalloc.MemoryFile) uint64

Truncate updates s to reflect Mappable truncation to the given length: bytes after the new EOF on the same page are zeroed, and pages after the new EOF are freed. It returns the number of pages freed.

func (*FileRangeSet) TryInsertRange

TryInsertRange attempts to insert the given segment into the set. If the new segment can be merged with adjacent segments, TryInsertRange will do so. TryInsertRange returns an iterator to the segment containing the inserted value (which may have been merged with other values). All existing iterators (excluding the returned iterator) are invalidated.

If the new segment would overlap an existing segment, TryInsertRange does nothing and returns a terminal iterator.

TryInsertRange searches the set to find the gap to insert into. If the caller already has the appropriate GapIterator, or if the caller needs to do additional work between finding the gap and insertion, use Insert instead.

func (*FileRangeSet) TryInsertWithoutMergingRange

func (s *FileRangeSet) TryInsertWithoutMergingRange(r __generics_imported0.MappableRange, val uint64) FileRangeIterator

TryInsertWithoutMergingRange attempts to insert the given segment into the set. If successful, it returns an iterator to the inserted segment; all existing iterators (excluding the returned iterator) are invalidated. If the new segment would overlap an existing segment, TryInsertWithoutMergingRange does nothing and returns a terminal iterator.

TryInsertWithoutMergingRange searches the set to find the gap to insert into. If the caller already has the appropriate GapIterator, or if the caller needs to do additional work between finding the gap and insertion, use InsertWithoutMerging instead.

func (*FileRangeSet) Unisolate

Unisolate attempts to merge the given segment with its predecessor and successor if possible, and returns an updated iterator to the extended segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

Unisolate is usually used in conjunction with Isolate when mutating part of a single segment in a way that may affect its mergeability. For the reasons described by MergePrev and MergeNext, it is usually incorrect to use the return value of Unisolate in a loop variable.

func (*FileRangeSet) UpperBoundGap

func (s *FileRangeSet) UpperBoundGap(max uint64) FileRangeGapIterator

UpperBoundGap returns the gap with the highest range that is less than or equal to max.

func (*FileRangeSet) UpperBoundLargeEnoughGap

func (s *FileRangeSet) UpperBoundLargeEnoughGap(max, minSize uint64) FileRangeGapIterator

UpperBoundLargeEnoughGap returns the last gap in the set with at least the given length and whose range contains a key less than or equal to max. If no such gap exists, UpperBoundLargeEnoughGap returns a terminal iterator.

Precondition: trackGaps must be 1.

func (*FileRangeSet) UpperBoundSegment

func (s *FileRangeSet) UpperBoundSegment(max uint64) FileRangeIterator

UpperBoundSegment returns the segment with the highest range that contains a key less than or equal to max. If no such segment exists, UpperBoundSegment returns a terminal iterator.

func (*FileRangeSet) UpperBoundSegmentSplitAfter

func (s *FileRangeSet) UpperBoundSegmentSplitAfter(max uint64) FileRangeIterator

UpperBoundSegmentSplitAfter combines UpperBoundSegment and SplitAfter.

UpperBoundSegmentSplitAfter is usually used when mutating segments in a range while iterating them in order of decreasing keys. In such cases, UpperBoundSegmentSplitAfter provides an iterator to the first segment to be mutated, suitable as the initial value for a loop variable.

func (*FileRangeSet) VisitFullRange

func (s *FileRangeSet) VisitFullRange(r __generics_imported0.MappableRange, f func(seg FileRangeIterator) bool)

VisitFullRange is equivalent to VisitRange, except that if any key in r that is visited before f returns false does not correspond to a segment, VisitFullRange panics.

func (*FileRangeSet) VisitRange

VisitRange applies the function f to all segments intersecting the range r, in order of ascending keys. Segments will not be split, so f may be called on segments lying partially outside r. Non-empty gaps between segments are skipped. If a call to f returns false, VisitRange stops iteration immediately.

N.B. f must not invalidate iterators into s.

type FileRangeSetFunctions

type FileRangeSetFunctions struct{}

FileRangeSetFunctions implements segment.Functions for FileRangeSet.

func (FileRangeSetFunctions) ClearValue

func (FileRangeSetFunctions) ClearValue(_ *uint64)

ClearValue implements segment.Functions.ClearValue.

func (FileRangeSetFunctions) MaxKey

func (FileRangeSetFunctions) MaxKey() uint64

MaxKey implements segment.Functions.MaxKey.

func (FileRangeSetFunctions) Merge

func (FileRangeSetFunctions) Merge(mr1 memmap.MappableRange, frstart1 uint64, _ memmap.MappableRange, frstart2 uint64) (uint64, bool)

Merge implements segment.Functions.Merge.

func (FileRangeSetFunctions) MinKey

func (FileRangeSetFunctions) MinKey() uint64

MinKey implements segment.Functions.MinKey.

func (FileRangeSetFunctions) Split

func (FileRangeSetFunctions) Split(mr memmap.MappableRange, frstart uint64, split uint64) (uint64, uint64)

Split implements segment.Functions.Split.

type FileRangedynamicGap

type FileRangedynamicGap [FileRangetrackGaps]uint64

dynamicGap is a type that disappears if trackGaps is 0.

func (*FileRangedynamicGap) Get

func (d *FileRangedynamicGap) Get() uint64

Get returns the value of the gap.

Precondition: trackGaps must be non-zero.

func (*FileRangedynamicGap) Set

func (d *FileRangedynamicGap) Set(v uint64)

Set sets the value of the gap.

Precondition: trackGaps must be non-zero.

type FileRangenode

type FileRangenode struct {
	// contains filtered or unexported fields
}

+stateify savable

func (*FileRangenode) StateFields

func (n *FileRangenode) StateFields() []string

func (*FileRangenode) StateLoad

func (n *FileRangenode) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*FileRangenode) StateSave

func (n *FileRangenode) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*FileRangenode) StateTypeName

func (n *FileRangenode) StateTypeName() string

func (*FileRangenode) String

func (n *FileRangenode) String() string

String stringifies a node (and all of its children) for debugging.

type FrameRefFlatSegment

type FrameRefFlatSegment struct {
	Start uint64
	End   uint64
	Value FrameRefSegInfo
}

FlatSegment represents a segment as a single object. FlatSegment is used as an intermediate representation for save/restore and tests.

+stateify savable

func (*FrameRefFlatSegment) StateFields

func (f *FrameRefFlatSegment) StateFields() []string

func (*FrameRefFlatSegment) StateLoad

func (f *FrameRefFlatSegment) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*FrameRefFlatSegment) StateSave

func (f *FrameRefFlatSegment) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*FrameRefFlatSegment) StateTypeName

func (f *FrameRefFlatSegment) StateTypeName() string

type FrameRefGapIterator

type FrameRefGapIterator struct {
	// contains filtered or unexported fields
}

A GapIterator is conceptually one of:

  • A pointer to a position between two segments, before the first segment, or after the last segment in a set, called a *gap*; or

  • A terminal iterator, which is a sentinel indicating that the end of iteration has been reached.

Note that the gap between two adjacent segments exists (iterators to it are non-terminal), but has a length of zero. GapIterator.IsEmpty returns true for such gaps. An empty set contains a single gap, spanning the entire range of the set's keys.

GapIterators are copyable values and are meaningfully equality-comparable. The zero value of GapIterator is a terminal iterator.

Unless otherwise specified, any mutation of a set invalidates all existing iterators into the set.

func (FrameRefGapIterator) End

func (gap FrameRefGapIterator) End() uint64

End is equivalent to Range().End, but should be preferred if only the end of the range is needed.

func (FrameRefGapIterator) IsEmpty

func (gap FrameRefGapIterator) IsEmpty() bool

IsEmpty returns true if the iterated gap is empty (that is, the "gap" is between two adjacent segments.)

func (FrameRefGapIterator) NextGap

NextGap returns the iterated gap's successor. If no such gap exists, NextGap returns a terminal iterator.

func (FrameRefGapIterator) NextLargeEnoughGap

func (gap FrameRefGapIterator) NextLargeEnoughGap(minSize uint64) FrameRefGapIterator

NextLargeEnoughGap returns the iterated gap's first next gap with larger length than minSize. If not found, return a terminal gap iterator (does NOT include this gap itself).

Precondition: trackGaps must be 1.

func (FrameRefGapIterator) NextSegment

func (gap FrameRefGapIterator) NextSegment() FrameRefIterator

NextSegment returns the segment immediately after the iterated gap. If no such segment exists, NextSegment returns a terminal iterator.

func (FrameRefGapIterator) Ok

func (gap FrameRefGapIterator) Ok() bool

Ok returns true if the iterator is not terminal. All other methods are only valid for non-terminal iterators.

func (FrameRefGapIterator) PrevGap

PrevGap returns the iterated gap's predecessor. If no such gap exists, PrevGap returns a terminal iterator.

func (FrameRefGapIterator) PrevLargeEnoughGap

func (gap FrameRefGapIterator) PrevLargeEnoughGap(minSize uint64) FrameRefGapIterator

PrevLargeEnoughGap returns the iterated gap's first prev gap with larger or equal length than minSize. If not found, return a terminal gap iterator (does NOT include this gap itself).

Precondition: trackGaps must be 1.

func (FrameRefGapIterator) PrevSegment

func (gap FrameRefGapIterator) PrevSegment() FrameRefIterator

PrevSegment returns the segment immediately before the iterated gap. If no such segment exists, PrevSegment returns a terminal iterator.

func (FrameRefGapIterator) Range

Range returns the range spanned by the iterated gap.

func (FrameRefGapIterator) Start

func (gap FrameRefGapIterator) Start() uint64

Start is equivalent to Range().Start, but should be preferred if only the start of the range is needed.

type FrameRefIterator

type FrameRefIterator struct {
	// contains filtered or unexported fields
}

A Iterator is conceptually one of:

  • A pointer to a segment in a set; or

  • A terminal iterator, which is a sentinel indicating that the end of iteration has been reached.

Iterators are copyable values and are meaningfully equality-comparable. The zero value of Iterator is a terminal iterator.

Unless otherwise specified, any mutation of a set invalidates all existing iterators into the set.

func FrameRefsegmentAfterPosition

func FrameRefsegmentAfterPosition(n *FrameRefnode, i int) FrameRefIterator

segmentAfterPosition returns the successor segment of the position given by n.children[i], which may or may not contain a child. If no such segment exists, segmentAfterPosition returns a terminal iterator.

func FrameRefsegmentBeforePosition

func FrameRefsegmentBeforePosition(n *FrameRefnode, i int) FrameRefIterator

segmentBeforePosition returns the predecessor segment of the position given by n.children[i], which may or may not contain a child. If no such segment exists, segmentBeforePosition returns a terminal iterator.

func (FrameRefIterator) End

func (seg FrameRefIterator) End() uint64

End is equivalent to Range().End, but should be preferred if only the end of the range is needed.

func (FrameRefIterator) NextGap

func (seg FrameRefIterator) NextGap() FrameRefGapIterator

NextGap returns the gap immediately after the iterated segment.

func (FrameRefIterator) NextNonEmpty

NextNonEmpty returns the iterated segment's successor if it is adjacent, or the gap after the iterated segment otherwise. If seg.End() == Functions.MaxKey(), NextNonEmpty will return two terminal iterators. Otherwise, exactly one of the iterators returned by NextNonEmpty will be non-terminal.

func (FrameRefIterator) NextSegment

func (seg FrameRefIterator) NextSegment() FrameRefIterator

NextSegment returns the iterated segment's successor. If there is no succeeding segment, NextSegment returns a terminal iterator.

func (FrameRefIterator) Ok

func (seg FrameRefIterator) Ok() bool

Ok returns true if the iterator is not terminal. All other methods are only valid for non-terminal iterators.

func (FrameRefIterator) PrevGap

func (seg FrameRefIterator) PrevGap() FrameRefGapIterator

PrevGap returns the gap immediately before the iterated segment.

func (FrameRefIterator) PrevNonEmpty

PrevNonEmpty returns the iterated segment's predecessor if it is adjacent, or the gap before the iterated segment otherwise. If seg.Start() == Functions.MinKey(), PrevNonEmpty will return two terminal iterators. Otherwise, exactly one of the iterators returned by PrevNonEmpty will be non-terminal.

func (FrameRefIterator) PrevSegment

func (seg FrameRefIterator) PrevSegment() FrameRefIterator

PrevSegment returns the iterated segment's predecessor. If there is no preceding segment, PrevSegment returns a terminal iterator.

func (FrameRefIterator) Range

Range returns the iterated segment's range key.

func (FrameRefIterator) SetEnd

func (seg FrameRefIterator) SetEnd(end uint64)

SetEnd mutates the iterated segment's end. If the new end value would cause the iterated segment to overlap another segment, or would result in an invalid range, SetEnd panics. This operation does not invalidate any iterators.

func (FrameRefIterator) SetEndUnchecked

func (seg FrameRefIterator) SetEndUnchecked(end uint64)

SetEndUnchecked mutates the iterated segment's end. This operation does not invalidate any iterators.

Preconditions: The new end must be valid:

  • end > seg.Start().
  • If seg.NextSegment().Ok(), then end <= seg.NextSegment().Start().

func (FrameRefIterator) SetRange

SetRange mutates the iterated segment's range key. If the new range would cause the iterated segment to overlap another segment, or if the new range is invalid, SetRange panics. This operation does not invalidate any iterators.

func (FrameRefIterator) SetRangeUnchecked

func (seg FrameRefIterator) SetRangeUnchecked(r __generics_imported0.FileRange)

SetRangeUnchecked mutates the iterated segment's range key. This operation does not invalidate any iterators.

Preconditions: - r.Length() > 0. - The new range must not overlap an existing one:

  • If seg.NextSegment().Ok(), then r.end <= seg.NextSegment().Start().
  • If seg.PrevSegment().Ok(), then r.start >= seg.PrevSegment().End().

func (FrameRefIterator) SetStart

func (seg FrameRefIterator) SetStart(start uint64)

SetStart mutates the iterated segment's start. If the new start value would cause the iterated segment to overlap another segment, or would result in an invalid range, SetStart panics. This operation does not invalidate any iterators.

func (FrameRefIterator) SetStartUnchecked

func (seg FrameRefIterator) SetStartUnchecked(start uint64)

SetStartUnchecked mutates the iterated segment's start. This operation does not invalidate any iterators.

Preconditions: The new start must be valid:

  • start < seg.End()
  • If seg.PrevSegment().Ok(), then start >= seg.PrevSegment().End().

func (FrameRefIterator) SetValue

func (seg FrameRefIterator) SetValue(val FrameRefSegInfo)

SetValue mutates the iterated segment's value. This operation does not invalidate any iterators.

func (FrameRefIterator) Start

func (seg FrameRefIterator) Start() uint64

Start is equivalent to Range().Start, but should be preferred if only the start of the range is needed.

func (FrameRefIterator) Value

func (seg FrameRefIterator) Value() FrameRefSegInfo

Value returns a copy of the iterated segment's value.

func (FrameRefIterator) ValuePtr

func (seg FrameRefIterator) ValuePtr() *FrameRefSegInfo

ValuePtr returns a pointer to the iterated segment's value. The pointer is invalidated if the iterator is invalidated. This operation does not invalidate any iterators.

type FrameRefSegInfo

type FrameRefSegInfo struct {
	// contains filtered or unexported fields
}

FrameRefSegInfo holds reference count and memory cgroup id of the segment.

+stateify savable

func (*FrameRefSegInfo) StateFields

func (f *FrameRefSegInfo) StateFields() []string

func (*FrameRefSegInfo) StateLoad

func (f *FrameRefSegInfo) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*FrameRefSegInfo) StateSave

func (f *FrameRefSegInfo) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*FrameRefSegInfo) StateTypeName

func (f *FrameRefSegInfo) StateTypeName() string

type FrameRefSet

type FrameRefSet struct {
	// contains filtered or unexported fields
}

A Set is a mapping of segments with non-overlapping Range keys. The zero value for a Set is an empty set. Set values are not safely movable nor copyable. Set is thread-compatible.

+stateify savable

func (*FrameRefSet) DecRefAndAccount

func (s *FrameRefSet) DecRefAndAccount(fr memmap.FileRange)

DecRefAndAccount removes a reference on the range fr and untracks segments that are removed from memory accounting.

func (*FrameRefSet) ExportSlice

func (s *FrameRefSet) ExportSlice() []FrameRefFlatSegment

ExportSlice returns a copy of all segments in the given set, in ascending key order.

func (*FrameRefSet) Find

Find returns the segment or gap whose range contains the given key. If a segment is found, the returned Iterator is non-terminal and the returned GapIterator is terminal. Otherwise, the returned Iterator is terminal and the returned GapIterator is non-terminal.

func (*FrameRefSet) FindGap

func (s *FrameRefSet) FindGap(key uint64) FrameRefGapIterator

FindGap returns the gap containing the given key. If no such gap exists (i.e. the set contains a segment containing that key), FindGap returns a terminal iterator.

func (*FrameRefSet) FindSegment

func (s *FrameRefSet) FindSegment(key uint64) FrameRefIterator

FindSegment returns the segment whose range contains the given key. If no such segment exists, FindSegment returns a terminal iterator.

func (*FrameRefSet) FirstGap

func (s *FrameRefSet) FirstGap() FrameRefGapIterator

FirstGap returns the first gap in the set.

func (*FrameRefSet) FirstLargeEnoughGap

func (s *FrameRefSet) FirstLargeEnoughGap(minSize uint64) FrameRefGapIterator

FirstLargeEnoughGap returns the first gap in the set with at least the given length. If no such gap exists, FirstLargeEnoughGap returns a terminal iterator.

Precondition: trackGaps must be 1.

func (*FrameRefSet) FirstSegment

func (s *FrameRefSet) FirstSegment() FrameRefIterator

FirstSegment returns the first segment in the set. If the set is empty, FirstSegment returns a terminal iterator.

func (*FrameRefSet) ImportSlice

func (s *FrameRefSet) ImportSlice(fs []FrameRefFlatSegment) error

ImportSlice initializes the given set from the given slice.

Preconditions:

  • s must be empty.
  • fs must represent a valid set (the segments in fs must have valid lengths that do not overlap).
  • The segments in fs must be sorted in ascending key order.

func (*FrameRefSet) IncRefAndAccount

func (s *FrameRefSet) IncRefAndAccount(fr memmap.FileRange, memCgID uint32)

IncRefAndAccount adds a reference on the range fr. All newly inserted segments are accounted as host page cache memory mappings. The new segments will be associated with the memCgID, if the segment already exists then the memCgID will not be changed.

func (*FrameRefSet) Insert

Insert inserts the given segment into the given gap. If the new segment can be merged with adjacent segments, Insert will do so. Insert returns an iterator to the segment containing the inserted value (which may have been merged with other values). All existing iterators (including gap, but not including the returned iterator) are invalidated.

If the gap cannot accommodate the segment, or if r is invalid, Insert panics.

Insert is semantically equivalent to a InsertWithoutMerging followed by a Merge, but may be more efficient. Note that there is no unchecked variant of Insert since Insert must retrieve and inspect gap's predecessor and successor segments regardless.

func (*FrameRefSet) InsertRange

InsertRange inserts the given segment into the set. If the new segment can be merged with adjacent segments, InsertRange will do so. InsertRange returns an iterator to the segment containing the inserted value (which may have been merged with other values). All existing iterators (excluding the returned iterator) are invalidated.

If the new segment would overlap an existing segment, or if r is invalid, InsertRange panics.

InsertRange searches the set to find the gap to insert into. If the caller already has the appropriate GapIterator, or if the caller needs to do additional work between finding the gap and insertion, use Insert instead.

func (*FrameRefSet) InsertWithoutMerging

InsertWithoutMerging inserts the given segment into the given gap and returns an iterator to the inserted segment. All existing iterators (including gap, but not including the returned iterator) are invalidated.

If the gap cannot accommodate the segment, or if r is invalid, InsertWithoutMerging panics.

func (*FrameRefSet) InsertWithoutMergingRange

func (s *FrameRefSet) InsertWithoutMergingRange(r __generics_imported0.FileRange, val FrameRefSegInfo) FrameRefIterator

InsertWithoutMergingRange inserts the given segment into the set and returns an iterator to the inserted segment. All existing iterators (excluding the returned iterator) are invalidated.

If the new segment would overlap an existing segment, or if r is invalid, InsertWithoutMergingRange panics.

InsertWithoutMergingRange searches the set to find the gap to insert into. If the caller already has the appropriate GapIterator, or if the caller needs to do additional work between finding the gap and insertion, use InsertWithoutMerging instead.

func (*FrameRefSet) InsertWithoutMergingUnchecked

func (s *FrameRefSet) InsertWithoutMergingUnchecked(gap FrameRefGapIterator, r __generics_imported0.FileRange, val FrameRefSegInfo) FrameRefIterator

InsertWithoutMergingUnchecked inserts the given segment into the given gap and returns an iterator to the inserted segment. All existing iterators (including gap, but not including the returned iterator) are invalidated.

Preconditions:

  • r.Start >= gap.Start().
  • r.End <= gap.End().

func (*FrameRefSet) IsEmpty

func (s *FrameRefSet) IsEmpty() bool

IsEmpty returns true if the set contains no segments.

func (*FrameRefSet) IsEmptyRange

func (s *FrameRefSet) IsEmptyRange(r __generics_imported0.FileRange) bool

IsEmptyRange returns true iff no segments in the set overlap the given range. This is semantically equivalent to s.SpanRange(r) == 0, but may be more efficient.

func (*FrameRefSet) Isolate

Isolate ensures that the given segment's range is a subset of r by splitting at r.Start and r.End if necessary, and returns an updated iterator to the bounded segment. All existing iterators (including seg, but not including the returned iterators) are invalidated.

Isolate is usually used when mutating part of a single segment, or when mutating segments in a range where the first segment is not necessarily split, making use of SplitBefore/SplitAfter complex.

Preconditions: seg.Range().Overlaps(r).

func (*FrameRefSet) LastGap

func (s *FrameRefSet) LastGap() FrameRefGapIterator

LastGap returns the last gap in the set.

func (*FrameRefSet) LastLargeEnoughGap

func (s *FrameRefSet) LastLargeEnoughGap(minSize uint64) FrameRefGapIterator

LastLargeEnoughGap returns the last gap in the set with at least the given length. If no such gap exists, LastLargeEnoughGap returns a terminal iterator.

Precondition: trackGaps must be 1.

func (*FrameRefSet) LastSegment

func (s *FrameRefSet) LastSegment() FrameRefIterator

LastSegment returns the last segment in the set. If the set is empty, LastSegment returns a terminal iterator.

func (*FrameRefSet) LowerBoundGap

func (s *FrameRefSet) LowerBoundGap(min uint64) FrameRefGapIterator

LowerBoundGap returns the gap with the lowest range that is greater than or equal to min.

func (*FrameRefSet) LowerBoundLargeEnoughGap

func (s *FrameRefSet) LowerBoundLargeEnoughGap(min, minSize uint64) FrameRefGapIterator

LowerBoundLargeEnoughGap returns the first gap in the set with at least the given length and whose range contains a key greater than or equal to min. If no such gap exists, LowerBoundLargeEnoughGap returns a terminal iterator.

Precondition: trackGaps must be 1.

func (*FrameRefSet) LowerBoundSegment

func (s *FrameRefSet) LowerBoundSegment(min uint64) FrameRefIterator

LowerBoundSegment returns the segment with the lowest range that contains a key greater than or equal to min. If no such segment exists, LowerBoundSegment returns a terminal iterator.

func (*FrameRefSet) LowerBoundSegmentSplitBefore

func (s *FrameRefSet) LowerBoundSegmentSplitBefore(min uint64) FrameRefIterator

LowerBoundSegmentSplitBefore combines LowerBoundSegment and SplitBefore.

LowerBoundSegmentSplitBefore is usually used when mutating segments in a range while iterating them in order of increasing keys. In such cases, LowerBoundSegmentSplitBefore provides an iterator to the first segment to be mutated, suitable as the initial value for a loop variable.

func (*FrameRefSet) Merge

func (s *FrameRefSet) Merge(first, second FrameRefIterator) FrameRefIterator

Merge attempts to merge two neighboring segments. If successful, Merge returns an iterator to the merged segment, and all existing iterators are invalidated. Otherwise, Merge returns a terminal iterator.

If first is not the predecessor of second, Merge panics.

func (*FrameRefSet) MergeAll

func (s *FrameRefSet) MergeAll()

MergeAll merges all mergeable adjacent segments in the set. All existing iterators are invalidated.

func (*FrameRefSet) MergeInsideRange

func (s *FrameRefSet) MergeInsideRange(r __generics_imported0.FileRange)

MergeInsideRange attempts to merge all adjacent segments that contain a key in the specific range. All existing iterators are invalidated.

MergeInsideRange only makes sense after mutating the set in a way that may change the mergeability of modified segments; callers should prefer to use MergePrev or MergeNext during the mutating loop instead (depending on the direction of iteration), in order to avoid a redundant search.

func (*FrameRefSet) MergeNext

func (s *FrameRefSet) MergeNext(seg FrameRefIterator) FrameRefIterator

MergeNext attempts to merge the given segment with its successor if possible, and returns an updated iterator to the extended segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

MergeNext is usually used when mutating segments while iterating them in order of decreasing keys, to attempt merging of each mutated segment with its previously-mutated successor. In such cases, merging a mutated segment with its unmutated predecessor would incorrectly cause the latter to be skipped.

func (*FrameRefSet) MergeOutsideRange

func (s *FrameRefSet) MergeOutsideRange(r __generics_imported0.FileRange)

MergeOutsideRange attempts to merge the segment containing r.Start with its predecessor, and the segment containing r.End-1 with its successor.

MergeOutsideRange only makes sense after mutating the set in a way that may change the mergeability of modified segments; callers should prefer to use MergePrev or MergeNext during the mutating loop instead (depending on the direction of iteration), in order to avoid two redundant searches.

func (*FrameRefSet) MergePrev

func (s *FrameRefSet) MergePrev(seg FrameRefIterator) FrameRefIterator

MergePrev attempts to merge the given segment with its predecessor if possible, and returns an updated iterator to the extended segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

MergePrev is usually used when mutating segments while iterating them in order of increasing keys, to attempt merging of each mutated segment with its previously-mutated predecessor. In such cases, merging a mutated segment with its unmutated successor would incorrectly cause the latter to be skipped.

func (*FrameRefSet) MergeUnchecked

func (s *FrameRefSet) MergeUnchecked(first, second FrameRefIterator) FrameRefIterator

MergeUnchecked attempts to merge two neighboring segments. If successful, MergeUnchecked returns an iterator to the merged segment, and all existing iterators are invalidated. Otherwise, MergeUnchecked returns a terminal iterator.

Precondition: first is the predecessor of second: first.NextSegment() == second, first == second.PrevSegment().

func (*FrameRefSet) MutateFullRange

func (s *FrameRefSet) MutateFullRange(r __generics_imported0.FileRange, f func(seg FrameRefIterator) bool)

MutateFullRange is equivalent to MutateRange, except that if any key in r that is visited before f returns false does not correspond to a segment, MutateFullRange panics.

func (*FrameRefSet) MutateRange

func (s *FrameRefSet) MutateRange(r __generics_imported0.FileRange, f func(seg FrameRefIterator) bool)

MutateRange applies the function f to all segments intersecting the range r, in order of ascending keys. Segments that lie partially outside r are split before f is called, such that f only observes segments entirely within r. Iterated segments are merged again after f is called. Non-empty gaps between segments are skipped. If a call to f returns false, MutateRange stops iteration immediately.

MutateRange invalidates all existing iterators.

N.B. f must not invalidate iterators into s.

func (*FrameRefSet) Remove

Remove removes the given segment and returns an iterator to the vacated gap. All existing iterators (including seg, but not including the returned iterator) are invalidated.

func (*FrameRefSet) RemoveAll

func (s *FrameRefSet) RemoveAll()

RemoveAll removes all segments from the set. All existing iterators are invalidated.

func (*FrameRefSet) RemoveFullRange

RemoveFullRange is equivalent to RemoveRange, except that if any key in the given range does not correspond to a segment, RemoveFullRange panics.

func (*FrameRefSet) RemoveFullRangeWith

func (s *FrameRefSet) RemoveFullRangeWith(r __generics_imported0.FileRange, f func(seg FrameRefIterator)) FrameRefGapIterator

RemoveFullRangeWith is equivalent to RemoveRangeWith, except that if any key in the given range does not correspond to a segment, RemoveFullRangeWith panics.

func (*FrameRefSet) RemoveRange

RemoveRange removes all segments in the given range. An iterator to the newly formed gap is returned, and all existing iterators are invalidated.

RemoveRange searches the set to find segments to remove. If the caller already has an iterator to either end of the range of segments to remove, or if the caller needs to do additional work before removing each segment, iterate segments and call Remove in a loop instead.

func (*FrameRefSet) RemoveRangeWith

RemoveRangeWith removes all segments in the given range. An iterator to the newly formed gap is returned, and all existing iterators are invalidated.

The function f is applied to each segment immediately before it is removed, in order of ascending keys. Segments that lie partially outside r are split before f is called, such that f only observes segments entirely within r. Non-empty gaps between segments are skipped.

RemoveRangeWith searches the set to find segments to remove. If the caller already has an iterator to either end of the range of segments to remove, or if the caller needs to do additional work before removing each segment, iterate segments and call Remove in a loop instead.

N.B. f must not invalidate iterators into s.

func (*FrameRefSet) Span

func (s *FrameRefSet) Span() uint64

Span returns the total size of all segments in the set.

func (*FrameRefSet) SpanRange

SpanRange returns the total size of the intersection of segments in the set with the given range.

func (*FrameRefSet) Split

Split splits the given segment at the given key and returns iterators to the two resulting segments. All existing iterators (including seg, but not including the returned iterators) are invalidated.

If the segment cannot be split at split (because split is at the start or end of the segment's range, so splitting would produce a segment with zero length, or because split falls outside the segment's range altogether), Split panics.

func (*FrameRefSet) SplitAfter

func (s *FrameRefSet) SplitAfter(seg FrameRefIterator, end uint64) FrameRefIterator

SplitAfter ensures that the given segment's end is at most end by splitting at end if necessary, and returns an updated iterator to the bounded segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

SplitAfter is usually used when mutating segments in a range. In such cases, when iterating segments in order of increasing keys, each iterated segment may extend beyond the end of the range to be mutated, and needs to be SplitAfter to ensure that only the part of the segment within the range is mutated. When iterating segments in order of decreasing keys, SplitBefore and SplitAfter exchange roles; i.e. SplitBefore needs to be invoked on each segment, while SplitAfter only needs to be invoked on the first.

Preconditions: seg.Start() < end.

func (*FrameRefSet) SplitBefore

func (s *FrameRefSet) SplitBefore(seg FrameRefIterator, start uint64) FrameRefIterator

SplitBefore ensures that the given segment's start is at least start by splitting at start if necessary, and returns an updated iterator to the bounded segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

SplitBefore is usually when mutating segments in a range. In such cases, when iterating segments in order of increasing keys, the first segment may extend beyond the start of the range to be mutated, and needs to be SplitBefore to ensure that only the part of the segment within the range is mutated. When iterating segments in order of decreasing keys, SplitBefore and SplitAfter; i.e. SplitBefore needs to be invoked on each segment, while SplitAfter only needs to be invoked on the first.

Preconditions: start < seg.End().

func (*FrameRefSet) SplitUnchecked

func (s *FrameRefSet) SplitUnchecked(seg FrameRefIterator, split uint64) (FrameRefIterator, FrameRefIterator)

SplitUnchecked splits the given segment at the given key and returns iterators to the two resulting segments. All existing iterators (including seg, but not including the returned iterators) are invalidated.

Preconditions: seg.Start() < key < seg.End().

func (*FrameRefSet) StateFields

func (s *FrameRefSet) StateFields() []string

func (*FrameRefSet) StateLoad

func (s *FrameRefSet) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*FrameRefSet) StateSave

func (s *FrameRefSet) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*FrameRefSet) StateTypeName

func (s *FrameRefSet) StateTypeName() string

func (*FrameRefSet) String

func (s *FrameRefSet) String() string

String stringifies a Set for debugging.

func (*FrameRefSet) TryInsertRange

TryInsertRange attempts to insert the given segment into the set. If the new segment can be merged with adjacent segments, TryInsertRange will do so. TryInsertRange returns an iterator to the segment containing the inserted value (which may have been merged with other values). All existing iterators (excluding the returned iterator) are invalidated.

If the new segment would overlap an existing segment, TryInsertRange does nothing and returns a terminal iterator.

TryInsertRange searches the set to find the gap to insert into. If the caller already has the appropriate GapIterator, or if the caller needs to do additional work between finding the gap and insertion, use Insert instead.

func (*FrameRefSet) TryInsertWithoutMergingRange

func (s *FrameRefSet) TryInsertWithoutMergingRange(r __generics_imported0.FileRange, val FrameRefSegInfo) FrameRefIterator

TryInsertWithoutMergingRange attempts to insert the given segment into the set. If successful, it returns an iterator to the inserted segment; all existing iterators (excluding the returned iterator) are invalidated. If the new segment would overlap an existing segment, TryInsertWithoutMergingRange does nothing and returns a terminal iterator.

TryInsertWithoutMergingRange searches the set to find the gap to insert into. If the caller already has the appropriate GapIterator, or if the caller needs to do additional work between finding the gap and insertion, use InsertWithoutMerging instead.

func (*FrameRefSet) Unisolate

func (s *FrameRefSet) Unisolate(seg FrameRefIterator) FrameRefIterator

Unisolate attempts to merge the given segment with its predecessor and successor if possible, and returns an updated iterator to the extended segment. All existing iterators (including seg, but not including the returned iterator) are invalidated.

Unisolate is usually used in conjunction with Isolate when mutating part of a single segment in a way that may affect its mergeability. For the reasons described by MergePrev and MergeNext, it is usually incorrect to use the return value of Unisolate in a loop variable.

func (*FrameRefSet) UpperBoundGap

func (s *FrameRefSet) UpperBoundGap(max uint64) FrameRefGapIterator

UpperBoundGap returns the gap with the highest range that is less than or equal to max.

func (*FrameRefSet) UpperBoundLargeEnoughGap

func (s *FrameRefSet) UpperBoundLargeEnoughGap(max, minSize uint64) FrameRefGapIterator

UpperBoundLargeEnoughGap returns the last gap in the set with at least the given length and whose range contains a key less than or equal to max. If no such gap exists, UpperBoundLargeEnoughGap returns a terminal iterator.

Precondition: trackGaps must be 1.

func (*FrameRefSet) UpperBoundSegment

func (s *FrameRefSet) UpperBoundSegment(max uint64) FrameRefIterator

UpperBoundSegment returns the segment with the highest range that contains a key less than or equal to max. If no such segment exists, UpperBoundSegment returns a terminal iterator.

func (*FrameRefSet) UpperBoundSegmentSplitAfter

func (s *FrameRefSet) UpperBoundSegmentSplitAfter(max uint64) FrameRefIterator

UpperBoundSegmentSplitAfter combines UpperBoundSegment and SplitAfter.

UpperBoundSegmentSplitAfter is usually used when mutating segments in a range while iterating them in order of decreasing keys. In such cases, UpperBoundSegmentSplitAfter provides an iterator to the first segment to be mutated, suitable as the initial value for a loop variable.

func (*FrameRefSet) VisitFullRange

func (s *FrameRefSet) VisitFullRange(r __generics_imported0.FileRange, f func(seg FrameRefIterator) bool)

VisitFullRange is equivalent to VisitRange, except that if any key in r that is visited before f returns false does not correspond to a segment, VisitFullRange panics.

func (*FrameRefSet) VisitRange

func (s *FrameRefSet) VisitRange(r __generics_imported0.FileRange, f func(seg FrameRefIterator) bool)

VisitRange applies the function f to all segments intersecting the range r, in order of ascending keys. Segments will not be split, so f may be called on segments lying partially outside r. Non-empty gaps between segments are skipped. If a call to f returns false, VisitRange stops iteration immediately.

N.B. f must not invalidate iterators into s.

type FrameRefSetFunctions

type FrameRefSetFunctions struct{}

FrameRefSetFunctions implements segment.Functions for FrameRefSet.

func (FrameRefSetFunctions) ClearValue

func (FrameRefSetFunctions) ClearValue(val *FrameRefSegInfo)

ClearValue implements segment.Functions.ClearValue.

func (FrameRefSetFunctions) MaxKey

func (FrameRefSetFunctions) MaxKey() uint64

MaxKey implements segment.Functions.MaxKey.

func (FrameRefSetFunctions) Merge

Merge implements segment.Functions.Merge.

func (FrameRefSetFunctions) MinKey

func (FrameRefSetFunctions) MinKey() uint64

MinKey implements segment.Functions.MinKey.

func (FrameRefSetFunctions) Split

Split implements segment.Functions.Split.

type FrameRefdynamicGap

type FrameRefdynamicGap [FrameReftrackGaps]uint64

dynamicGap is a type that disappears if trackGaps is 0.

func (*FrameRefdynamicGap) Get

func (d *FrameRefdynamicGap) Get() uint64

Get returns the value of the gap.

Precondition: trackGaps must be non-zero.

func (*FrameRefdynamicGap) Set

func (d *FrameRefdynamicGap) Set(v uint64)

Set sets the value of the gap.

Precondition: trackGaps must be non-zero.

type FrameRefnode

type FrameRefnode struct {
	// contains filtered or unexported fields
}

+stateify savable

func (*FrameRefnode) StateFields

func (n *FrameRefnode) StateFields() []string

func (*FrameRefnode) StateLoad

func (n *FrameRefnode) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*FrameRefnode) StateSave

func (n *FrameRefnode) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*FrameRefnode) StateTypeName

func (n *FrameRefnode) StateTypeName() string

func (*FrameRefnode) String

func (n *FrameRefnode) String() string

String stringifies a node (and all of its children) for debugging.

type HostFileMapper

type HostFileMapper struct {
	// contains filtered or unexported fields
}

HostFileMapper caches mappings of an arbitrary host file descriptor. It is used by implementations of memmap.Mappable that represent a host file descriptor.

+stateify savable

func NewHostFileMapper

func NewHostFileMapper() *HostFileMapper

NewHostFileMapper returns an initialized HostFileMapper allocated on the heap with no references or cached mappings.

func (*HostFileMapper) DecRefOn

func (f *HostFileMapper) DecRefOn(mr memmap.MappableRange)

DecRefOn decrements the reference count on all offsets in mr.

Preconditions:

  • mr.Length() != 0.
  • mr.Start and mr.End must be page-aligned.

func (*HostFileMapper) IncRefOn

func (f *HostFileMapper) IncRefOn(mr memmap.MappableRange)

IncRefOn increments the reference count on all offsets in mr.

Preconditions:

  • mr.Length() != 0.
  • mr.Start and mr.End must be page-aligned.

func (*HostFileMapper) Init

func (f *HostFileMapper) Init()

Init must be called on zero-value HostFileMappers before first use.

func (*HostFileMapper) IsInited

func (f *HostFileMapper) IsInited() bool

IsInited returns true if f.Init() has been called. This is used when restoring a checkpoint that contains a HostFileMapper that may or may not have been initialized.

func (*HostFileMapper) MapInternal

func (f *HostFileMapper) MapInternal(fr memmap.FileRange, fd int, write bool) (safemem.BlockSeq, error)

MapInternal returns a mapping of offsets in fr from fd. The returned safemem.BlockSeq is valid as long as at least one reference is held on all offsets in fr or until the next call to UnmapAll.

Preconditions: The caller must hold a reference on all offsets in fr.

func (*HostFileMapper) RegenerateMappings

func (f *HostFileMapper) RegenerateMappings(fd int) error

RegenerateMappings must be called when the file description mapped by f changes, to replace existing mappings of the previous file description.

func (*HostFileMapper) StateFields

func (f *HostFileMapper) StateFields() []string

func (*HostFileMapper) StateLoad

func (f *HostFileMapper) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*HostFileMapper) StateSave

func (f *HostFileMapper) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*HostFileMapper) StateTypeName

func (f *HostFileMapper) StateTypeName() string

func (*HostFileMapper) UnmapAll

func (f *HostFileMapper) UnmapAll()

UnmapAll unmaps all cached mappings. Callers are responsible for synchronization with mappings returned by previous calls to MapInternal.

type PreciseHostFileMapper

type PreciseHostFileMapper struct {
	// contains filtered or unexported fields
}

PreciseHostFileMapper caches mappings of an arbitrary host file descriptor. It is used by implementations of memmap.Mappable that represent a host file descriptor. It differs from HostFileMapper in that it maps at exact page boundaries specified in a file range, not in chunks.

+stateify savable

func NewPreciseHostFileMapper

func NewPreciseHostFileMapper() *PreciseHostFileMapper

NewPreciseHostFileMapper returns an initialized PreciseHostFileMapper allocated on the heap with no references or cached mappings.

func (*PreciseHostFileMapper) DecRefOn

func (f *PreciseHostFileMapper) DecRefOn(mr memmap.MappableRange)

DecRefOn decrements the reference count on all offsets in mr.

Preconditions:

  • mr.Length() != 0.
  • mr.Start and mr.End must be page-aligned.

func (*PreciseHostFileMapper) IncRefOn

func (f *PreciseHostFileMapper) IncRefOn(mr memmap.MappableRange)

IncRefOn increments the reference count on all pages in mr.

Preconditions:

  • mr.Length() != 0.
  • mr.Start and mr.End must be page-aligned.

func (*PreciseHostFileMapper) MapInternal

func (f *PreciseHostFileMapper) MapInternal(fr memmap.FileRange, fd int, write bool) (safemem.BlockSeq, error)

MapInternal returns a mapping of offsets in fr from fd. The returned safemem.BlockSeq is valid as long as at least one reference is held on all offsets in fr or until the next call to UnmapAll.

Preconditions: The caller must hold a reference on all offsets in fr.

func (*PreciseHostFileMapper) StateFields

func (f *PreciseHostFileMapper) StateFields() []string

func (*PreciseHostFileMapper) StateLoad

func (f *PreciseHostFileMapper) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*PreciseHostFileMapper) StateSave

func (f *PreciseHostFileMapper) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*PreciseHostFileMapper) StateTypeName

func (f *PreciseHostFileMapper) StateTypeName() string

func (*PreciseHostFileMapper) UnmapAll

func (f *PreciseHostFileMapper) UnmapAll()

UnmapAll unmaps all cached mappings. Callers are responsible for synchronization with mappings returned by previous calls to MapInternal.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL