Documentation
¶
Overview ¶
Package timesortedlist is a package of a data structure storing time series data. It's goal is to store data such as logs, sequence, ... that should be ordered.
Feature
- in memory time series data store
- any data sorted in time series
- query data using from or until in unixtime
Usage ¶
Here is a simple usage.
Add item ¶
When you add item, this list will automatically sort.
tsl.AddItem(unixTime, timeItem)
Searching data through unixtime ¶
Since this data structure intented to store time series data, it has abilty to search item via unix time.
timeItems := tsl.GetItemsFrom(unixTime) timeItems := tsl.GetItemsUntil(unixTime)
Index ¶
- type ITimeSortedList
- type TimeItem
- type TimeSortedList
- func (tsl *TimeSortedList) AddItem(unixTime int64, item interface{})
- func (tsl *TimeSortedList) AddTimeItem(item *TimeItem)
- func (tsl *TimeSortedList) Cap() int
- func (tsl *TimeSortedList) Filled() bool
- func (tsl *TimeSortedList) GetItem(idx int) *TimeItem
- func (tsl *TimeSortedList) GetItemsFrom(fromUnixTime int64) []TimeItem
- func (tsl *TimeSortedList) GetItemsFromUntil(fromUnixTime, untilUnixTime int64) []TimeItem
- func (tsl *TimeSortedList) GetItemsUntil(untilUnixTime int64) []TimeItem
- func (tsl *TimeSortedList) Len() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ITimeSortedList ¶
type ITimeSortedList interface { Len() int Cap() int AddItem(unixTime int64, item interface{}) AddTimeItem(item *TimeItem) Filled() bool GetItem(idx int) *TimeItem GetItemsFrom(fromUnixTime int64) []TimeItem GetItemsUntil(untilUnixTime int64) []TimeItem GetItemsFromUntil(fromUnixTime, untilUnixTime int64) []TimeItem }
ITimeSortedList is a interface of TimeSortedList. Use for mocking in your test.
func NewTimeSortedList ¶
func NewTimeSortedList(capacity int) ITimeSortedList
NewTimeSortedList initializes TimeSortedList. capacity is the max size of internal slice for not using more memory.
type TimeItem ¶
type TimeItem struct { UnixTime int64 Item interface{} }
TimeItem is a struct for storing item with time infomation.
type TimeSortedList ¶
type TimeSortedList struct {
// contains filtered or unexported fields
}
TimeSortedList holds time series items which are sorted. Inserted items can be obtained by specifying unix time.
func (*TimeSortedList) AddItem ¶
func (tsl *TimeSortedList) AddItem(unixTime int64, item interface{})
AddItem adds any structure with specified time.
func (*TimeSortedList) AddTimeItem ¶
func (tsl *TimeSortedList) AddTimeItem(item *TimeItem)
AddTimeItem adds TimeItem with time ordered.
func (*TimeSortedList) Cap ¶
func (tsl *TimeSortedList) Cap() int
Cap gets initialized capacity. If length of list is same as Cap then the list is filled.
func (*TimeSortedList) Filled ¶
func (tsl *TimeSortedList) Filled() bool
Filled checks if the list is filled.
func (*TimeSortedList) GetItem ¶
func (tsl *TimeSortedList) GetItem(idx int) *TimeItem
GetItem gets item with specified index.
func (*TimeSortedList) GetItemsFrom ¶
func (tsl *TimeSortedList) GetItemsFrom(fromUnixTime int64) []TimeItem
GetItemsFrom gets item from specified time
func (*TimeSortedList) GetItemsFromUntil ¶
func (tsl *TimeSortedList) GetItemsFromUntil(fromUnixTime, untilUnixTime int64) []TimeItem
GetItemsFromUntil get items with specified time range
func (*TimeSortedList) GetItemsUntil ¶
func (tsl *TimeSortedList) GetItemsUntil(untilUnixTime int64) []TimeItem
GetItemsUntil gets item until specified time