Documentation ¶
Overview ¶
Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func MinMaxViews(views []string, q TimeQuantum) (min string, max string)
- func TimeOfView(v string, adj bool) (time.Time, error)
- func ViewByTimeUnit(name string, t time.Time, unit rune) string
- func ViewsByTime(name string, t time.Time, q TimeQuantum) []string
- func ViewsByTimeInto(fullBuf []byte, into [][]byte, t time.Time, q TimeQuantum) [][]byte
- func ViewsByTimeRange(name string, start, end time.Time, q TimeQuantum) []string
- type TimeQuantum
- func (q TimeQuantum) Granularity() rune
- func (q TimeQuantum) HasDay() bool
- func (q TimeQuantum) HasHour() bool
- func (q TimeQuantum) HasMonth() bool
- func (q TimeQuantum) HasYear() bool
- func (q TimeQuantum) IsEmpty() bool
- func (q *TimeQuantum) Set(value string) error
- func (q TimeQuantum) String() string
- func (q TimeQuantum) Type() string
- func (q TimeQuantum) Valid() bool
Constants ¶
const TimeFormat = "2006-01-02T15:04"
Variables ¶
var ErrInvalidTimeQuantum = errors.New("invalid time quantum")
ErrInvalidTimeQuantum is returned when parsing a time quantum.
Functions ¶
func MinMaxViews ¶
func MinMaxViews(views []string, q TimeQuantum) (min string, max string)
MinMaxViews returns the min and max view from a list of views with a time quantum taken into consideration. It assumes that all views represent the same base view name (the logic depends on the views sorting correctly in alphabetical order).
func TimeOfView ¶
TimeOfView returns a valid time.Time based on the view string. For upper bound use, the result can be adjusted by one by setting the `adj` argument to `true`.
func ViewByTimeUnit ¶
ViewByTimeUnit returns the view name for time with a given quantum unit.
func ViewsByTime ¶
func ViewsByTime(name string, t time.Time, q TimeQuantum) []string
ViewsByTime returns a list of views for a given timestamp.
func ViewsByTimeInto ¶ added in v0.22.7
ViewsByTimeInto computes the list of views for a given time. It expects to be given an initial buffer of the form `name_YYYYMMDDHH`, and a slice of []bytes. This allows us to reuse the buffer for all the sub-buffers, and also to reuse the slice of slices, to eliminate all those allocations. This might seem crazy, but even including the JSON parsing and all the disk activity, the straightforward viewsByTime implementation was 25% of runtime in an ingest test.
func ViewsByTimeRange ¶
func ViewsByTimeRange(name string, start, end time.Time, q TimeQuantum) []string
ViewsByTimeRange returns a list of views to traverse to query a time range.
Types ¶
type TimeQuantum ¶
type TimeQuantum string
TimeQuantum represents a time granularity for time-based bitmaps.
func (TimeQuantum) Granularity ¶
func (q TimeQuantum) Granularity() rune
func (TimeQuantum) HasDay ¶
func (q TimeQuantum) HasDay() bool
HasDay returns true if the quantum contains a 'D' unit.
func (TimeQuantum) HasHour ¶
func (q TimeQuantum) HasHour() bool
HasHour returns true if the quantum contains a 'H' unit.
func (TimeQuantum) HasMonth ¶
func (q TimeQuantum) HasMonth() bool
HasMonth returns true if the quantum contains a 'M' unit.
func (TimeQuantum) HasYear ¶
func (q TimeQuantum) HasYear() bool
HasYear returns true if the quantum contains a 'Y' unit.
func (TimeQuantum) IsEmpty ¶
func (q TimeQuantum) IsEmpty() bool
IsEmpty returns true if the quantum is empty.
func (*TimeQuantum) Set ¶
func (q *TimeQuantum) Set(value string) error
Set sets the time quantum value.
func (TimeQuantum) String ¶
func (q TimeQuantum) String() string
func (TimeQuantum) Type ¶
func (q TimeQuantum) Type() string
Type returns the type of a time quantum value.
func (TimeQuantum) Valid ¶
func (q TimeQuantum) Valid() bool
Valid returns true if q is a valid time quantum value.