intervals

package
v1.8.13-0...-2e0391e Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2018 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Intervals

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

Intervals store a list of intervals. Its purpose is to provide methods to add new intervals and retrieve missing intervals that need to be added. It may be used in synchronization of streaming data to persist retrieved data ranges between sessions.

func NewIntervals

func NewIntervals(start uint64) *Intervals

New creates a new instance of Intervals. Start argument limits the lower bound of intervals. No range bellow start bound will be added by Add method or returned by Next method. This limit may be used for tracking "live" synchronization, where the sync session starts from a specific value, and if "live" sync intervals need to be merged with historical ones, it can be safely done.

func (*Intervals) Add

func (i *Intervals) Add(start, end uint64)

Add adds a new range to intervals. Range start and end are values are both inclusive.

func (*Intervals) Last

func (i *Intervals) Last() (end uint64)

Last returns the value that is at the end of the last interval.

func (*Intervals) MarshalBinary

func (i *Intervals) MarshalBinary() (data []byte, err error)

MarshalBinary encodes Intervals parameters into a semicolon separated list. The first element in the list is base36-encoded start value. The following elements are two base36-encoded value ranges separated by comma.

func (*Intervals) Merge

func (i *Intervals) Merge(m *Intervals)

Merge adds all the intervals from the the m Interval to current one.

func (*Intervals) Next

func (i *Intervals) Next() (start, end uint64)

Next returns the first range interval that is not fulfilled. Returned start and end values are both inclusive, meaning that the whole range including start and end need to be added in order to full the gap in intervals. Returned value for end is 0 if the next interval is after the whole range that is stored in Intervals. Zero end value represents no limit on the next interval length.

func (*Intervals) String

func (i *Intervals) String() string

String returns a descriptive representation of range intervals in [] notation, as a list of two element vectors.

func (*Intervals) UnmarshalBinary

func (i *Intervals) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary decodes data according to the Intervals.MarshalBinary format.

Jump to

Keyboard shortcuts

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