kv

package
v0.0.0-...-a6f45d6 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

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

func NewChannel

func NewChannel(kve kv.DB) *Channel

func (*Channel) Exists

func (c *Channel) Exists(key channel.Key) (bool, error)

func (*Channel) Get

func (c *Channel) Get(keys ...channel.Key) (res []channel.Channel, err error)

func (*Channel) Set

func (c *Channel) Set(ch channel.Channel) error
type Header struct {
	// contains filtered or unexported fields
}

func NewHeader

func NewHeader(kve kv.DB) *Header

func (*Header) Get

func (s *Header) Get(key segment.Key) (res segment.Header, err error)

func (*Header) Set

func (s *Header) Set(header segment.Header) error

func (*Header) SetMultiple

func (s *Header) SetMultiple(headers []segment.Header) error

type Iterator

type Iterator interface {
	// First moves the Iterator to the first segment in its Bounds. Returns true if:
	//
	//  	1. The Iterator is pointing at a valid segment within its Bounds.
	//
	//		2. Iterator.Error is nil.
	//
	// If true is returned, sets Iterator.View to the range of the first segment.
	First() bool
	// Last moves the Iterator to the last segment in its Bounds. Returns true if:
	//
	//		1. The Iterator is pointing at a valid segment within its Bounds.
	//
	//		2. Iterator.Error is nil
	//
	// If true is returned, sets Iterator.View to the range of the last segment.
	Last() bool
	// Next moves the Iterator to the next segment in its Bounds. Returns true if:
	//
	// 		1. The Iterator is pointing at a valid segment within its Bounds i.e.
	//		the Iterator bounds partially or completely overlap with the segment's
	//		range.
	//
	//		2. Iterator.Error is nil
	//
	// If true is returned, sets Iterator.View to the range of the segment. If the
	// segment range exceeds the iterator bounds, sets Value().Bounds.End to the
	// ends of the Iterator bounds. Constrains Iterator.View in the same manner.
	Next() bool
	// Prev moves the Iterator to the previous segment in its Bounds. Returns true if:
	//
	//		1. The Iterator is pointing at a valid segment within its Bounds i.e.
	//		the Iterator bounds partially or completely overlap with the segment's
	//		range.
	//
	//		2. Iterator.Error is nil.
	//
	// If true is returned, sets Iterator.View to the range of the segment. If the
	// segment range exceeds the iterator Bounds, sets Value().Bounds.Start to the
	// start of the Iterator.Bounds. Constrains Iterator.View in the same manner.
	Prev() bool
	// NextSpan moves the Iterator across the provided span, loading any segments it
	// encounters. Returns true if:
	//
	//		1. Iterator.View is pointing to a non-zero span within its Bounds.
	//	 	The span does not have to contain data for this condition to be met.
	//
	// 		2. Iterator.Error is nil.
	//
	NextSpan(span telem.TimeSpan) bool
	// PrevSpan moves the iterator backwards across the provided span, loading any
	// segments it encounters. Returns true if:
	//
	//		1. Iterator.View is pointing to a non-zero span within
	//	 	the Iterator.Bounds. The span does not have to contain data for
	//	 	this condition to be met.
	//
	//		2. Iterator.Error is nil.
	//
	PrevSpan(span telem.TimeSpan) bool
	// SetRange calls Seek to the start of the time range and calls NextSpan on the
	// span of the range. Returns true if both Seek and NextSpan return true.
	SetRange(tr telem.TimeRange) bool
	// SeekFirst seeks the Iterator to the first valid segment. Returns true if:
	//
	// 		1. The Iterator is pointing at a valid segment within its Bounds.
	//
	//		2. Iterator.Error is nil.
	//
	// If true is returned, sets Iterator.View to a zero-span range starting and ending
	// at the start of the first segment (constrained by Iterator.Bounds). Calls to
	// Iterator.Range will return an invalid Range. Next, NextSpan,
	// or SetRange must be called to load segments into Iterator.Range.
	SeekFirst() bool
	// SeekLast seeks the Iterator to the last valid segment.
	// Resets Iterator.Error.  Returns true if the Iterator is pointing at a valid
	// segment within its bounds.
	//
	// If true is returned, sets Iterator.View to a zero-span range starting and ending
	// at the end of the last segment (constrained by the Iterator.Bounds). Calls
	// to Iterator.Range will return an invalid Range. Prev, PrevSpan, or SetRange
	// must be called to load segments into Iterator.Range.
	SeekLast() bool
	// SeekLT seeks the Iterator to the first segment whose start timestamp is before
	// the provided stamp. Returns true if the Iterator is pointing to a valid
	// segment within Iterator.Bounds. Resets Iterator.Error.
	//
	// If true is returned, sets Iterator.View to a zero-span range starting and ending
	// at the start of the segment (constrained by Iterator.Bounds). Calls to Iterator.
	// Range will return an invalid Range. Next, NextSpan, Prev, PrevSpan or SetRange
	// must be called to load segments into Iterator.Range.
	SeekLT(stamp telem.TimeStamp) bool
	// SeekGE seeks the iterator to the first segment whose start timestamp
	// is after the provided stamp. Returns true if the Iterator is pointing
	// to a valid segment within Iterator.Bounds. Resets Iterator.Error.
	//
	// If true is returned, sets Iterator.View to a zero-span range starting and ending
	// at the start of the segment (constrained by Iterator.Bounds). Calls to Iterator.
	// Range will return an invalid Range. Calls to Iterator. Valid will return false.
	// Next, NextSpan, Prev, PrevSpan or SetRange must be called to load segments into
	// Iterator.Range and validate the Iterator.
	SeekGE(stamp telem.TimeStamp) bool
	// Seek seeks the Iterator to the provided timestamp. Returns true if stamp
	// is within the Iterator bounds. Sets the iterator view to a zero spanned
	// range starting and ending at the provided stamp. Calls to Iterator.Range
	// will return an invalid Range. Valid will return false. Next, NextSpan, Prev,
	// PrevSpan, or SetRange must be called to load segments into Iterator.Range and
	// validate the Iterator.
	Seek(stamp telem.TimeStamp) bool
	// Ranges returns a set of Range containing segments that overlap the current
	// Iterator.View. The segments in the range are not guaranteed to be contiguous or
	// contain data, but they are guaranteed to be sequential and overlap with the
	// Iterator.View. The bounds of reach range will be constrained by Iterator.View.
	//
	// It's important to note that the TimeRange returned by Range().Range() will
	// either be equal to or contained in the current View. On the other hande,
	// Range().UnboundedRange() is either equal or contains Range().Range() (meaning
	// it may be larger than the current View().
	Ranges() []*segment.Range
	// Range returns the Range for the first channel in the iterator. Returns
	// a nil range if the channel does not exist in the iterator. This is useful for
	// iterating over a single channel. See Ranges for details on what the returned
	// Range contains.
	Range() *segment.Range
	// GetValue returns the range for the provided channel key. Returns a nil range
	// if the channel does not exist in the iterator. Passing a channel key of 0
	// is identical to calling Range(). See Ranges for details on what the returned
	// Range contains.
	GetValue(key channel.Key) *segment.Range
	// View returns a telem.TimeRange representing the iterators current 'view' of the
	// data i.e. what is the potential set of segments currently loaded into Range().
	View() telem.TimeRange
	// Error returns any errors accumulated by the iterator. Error is reset after any
	// absolute call (First(), Last(), SeekFirst(), SeekLast(), SeekLT(),
	// SeekGE(), Seek(), SetRange()). If Error is non-nil, any relative calls (Next(),
	// Prev(), NextSpan(), PrevSpan(), or Valid()) will return false.
	Error() error
	// Valid returns true if the iterator View has a non-zero span and Iterator.Error
	// is not nil. This will return false after any seeking operations (Seek(),
	// SeekFirst(), SeekLast(), SeekLT(), SeekGE()).
	Valid() bool
	// Close closes the iterator. Returns any errors accumulated during iterator.
	Close() error
	// Bounds returns the bounds of the Iterator.
	Bounds() telem.TimeRange
}

Iterator is used to iterate over one or more channel's data. Iterator stores its values as a bounded range of segment headers. Iterator is not goroutine safe, but it is safe to open several iterators over the same data. Iterator segment metadata

func NewIterator

func NewIterator(kve kv.DB, rng telem.TimeRange, keys ...channel.Key) (iter Iterator)

NewIterator opens a new unaryIterator over the specified time range of a channel.

Jump to

Keyboard shortcuts

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