Documentation ¶
Index ¶
- type Interval
- type IntervalIndex
- type Layer
- func (l *Layer) Close() error
- func (l *Layer) Limit() int64
- func (l *Layer) MinSize() int64
- func (l *Layer) Read(buf []byte) (int, error)
- func (l *Layer) Seek(offset int64, whence int) (int64, error)
- func (l *Layer) SetSize(size int64)
- func (l *Layer) Truncate(size int64)
- func (l *Layer) Write(buf []byte) (int, error)
- type Modification
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interval ¶
type Interval interface { // Range returns the minimum and maximum of the interval. // Minimum value is inclusive, maximum value exclusive. // In other notation: [min, max) Range() (int64, int64) // Merge merges the interval `i` to this interval. // The range borders should be fixed accordingly, // so that [min(i.min, self.min), max(i.max, self.max)] applies. Merge(i Interval) }
Interval represents a 2er set of integers modelling a range.
type IntervalIndex ¶
type IntervalIndex struct { // Max is the maximum interval offset given to Add() Max int64 // contains filtered or unexported fields }
IntervalIndex represents a continuous array of sorted intervals. When adding intervals to the index, it will merge them overlapping areas. Holes between the intervals are allowed.
func (*IntervalIndex) Add ¶
func (ivl *IntervalIndex) Add(n Interval)
Add inserts a single interval to the index. If it overlaps with existing intervals, it's data will take priority over other intervals.
func (*IntervalIndex) Overlays ¶
func (ivl *IntervalIndex) Overlays(start, end int64) []Interval
Overlays returns all intervals that intersect with [start, end)
type Layer ¶
type Layer struct {
// contains filtered or unexported fields
}
Layer is a io.ReadWriter that takes an underlying Reader and caches Writes on top of it. To the outside it delivers a zipped stream of the recent writes and the underlying stream.
func NewLayer ¶
func NewLayer(r io.ReadSeeker) *Layer
NewLayer returns a new in memory layer. No IO is performed on creation.
func (*Layer) Limit ¶
Limit returns the current truncation limit or a number < 0 if no truncation is done.
func (*Layer) MinSize ¶
MinSize returns the minimum size that the layer will have. Underlying stream might be larger, so caller needs to check that.
func (*Layer) Read ¶
Read will read from the underlying stream and overlay with the relevant write chunks on it's way, possibly extending the underlying stream.
func (*Layer) Seek ¶
Seek remembers the new position and delegates the seek down. Note: if the file was truncated before, a seek after the limit
will extend the truncation again and NOT return io.EOF. This might be surprising, but is convenient for first truncating to zero and then writing to the file.
type Modification ¶
type Modification struct {
// contains filtered or unexported fields
}
Modification represents a single write
func (*Modification) Merge ¶
func (n *Modification) Merge(i Interval)
Merge adds the data of another interval where they intersect. The overlapping parts are taken from `n` always. Note: `i` shall not be used after calling Merge.
func (*Modification) Range ¶
func (n *Modification) Range() (int64, int64)
Range returns the fitting integer interval