Documentation
¶
Index ¶
- Constants
- Variables
- func GetInstanceType(labels map[string]string) (string, bool)
- func GetOperatingSystem(labels map[string]string) (string, bool)
- func GetRegion(labels map[string]string) (string, bool)
- func GetZone(labels map[string]string) (string, bool)
- func IsApproximately(a, b float64) bool
- func IsWithin(a, b, delta float64) bool
- func VectorValue(v float64, ok bool) *float64
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) ReadBool() bool
- func (b *Buffer) ReadBytes(length int) []byte
- func (b *Buffer) ReadFloat32() float32
- func (b *Buffer) ReadFloat64() float64
- func (b *Buffer) ReadInt() int
- func (b *Buffer) ReadInt16() int16
- func (b *Buffer) ReadInt32() int32
- func (b *Buffer) ReadInt64() int64
- func (b *Buffer) ReadInt8() int8
- func (b *Buffer) ReadString() string
- func (b *Buffer) ReadUInt() uint
- func (b *Buffer) ReadUInt16() uint16
- func (b *Buffer) ReadUInt32() uint32
- func (b *Buffer) ReadUInt64() uint64
- func (b *Buffer) ReadUInt8() uint8
- func (b *Buffer) WriteBool(t bool)
- func (b *Buffer) WriteBytes(bytes []byte)
- func (b *Buffer) WriteFloat32(i float32)
- func (b *Buffer) WriteFloat64(i float64)
- func (b *Buffer) WriteInt(i int)
- func (b *Buffer) WriteInt16(i int16)
- func (b *Buffer) WriteInt32(i int32)
- func (b *Buffer) WriteInt64(i int64)
- func (b *Buffer) WriteInt8(i int8)
- func (b *Buffer) WriteString(i string)
- func (b *Buffer) WriteUInt(i uint)
- func (b *Buffer) WriteUInt16(i uint16)
- func (b *Buffer) WriteUInt32(i uint32)
- func (b *Buffer) WriteUInt64(i uint64)
- func (b *Buffer) WriteUInt8(i uint8)
- type FixedMapPool
- type FlexibleMapPool
- type Semaphore
- type UnboundedMapPool
- type Vector
- type VectorJoinOp
- type VectorMapPool
- type VectorSlice
Constants ¶
const MapPoolSize = 4
Variables ¶
var NonPrimitiveTypeError error = errors.New("Type provided to read/write does not fit inside 8 bytes.")
NonPrimitiveTypeError represents an error where the user provided a non-primitive data type for reading/writing
Functions ¶
func IsApproximately ¶
IsApproximately returns true is a approximately equals b, within a delta computed as a function of the size of a and b.
func VectorValue ¶
returns a nil ptr or valid float ptr based on the ok bool
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a utility type which implements a very basic binary protocol for writing core go types.
func NewBuffer ¶
func NewBuffer() *Buffer
NewBuffer creates a new Buffer instance using LittleEndian ByteOrder.
func NewBufferFrom ¶
NewBufferFrom creates a new Buffer instance using the remaining unread data from the provided Buffer instance. The new buffer assumes ownership of the underlying data.
func NewBufferFromBytes ¶
NewBufferFromBytes creates a new Buffer instance using the provided byte slice. The new buffer assumes ownership of the byte slice.
func (*Buffer) ReadBytes ¶
ReadBytes reads the specified length from the buffer and returns the byte slice.
func (*Buffer) ReadFloat32 ¶
ReadFloat32 reads a float32 value from the buffer.
func (*Buffer) ReadFloat64 ¶
ReadFloat64 reads a float64 value from the buffer.
func (*Buffer) ReadString ¶
ReadString reads a uint16 value from the buffer representing the string's length, then uses the length to extract the exact length []byte representing the string.
func (*Buffer) ReadUInt16 ¶
ReadUInt16 reads a uint16 value from the buffer.
func (*Buffer) ReadUInt32 ¶
ReadUInt32 reads a uint32 value from the buffer.
func (*Buffer) ReadUInt64 ¶
ReadUInt64 reads a uint64 value from the buffer.
func (*Buffer) WriteBytes ¶
WriteBytes writes the contents of the byte slice to the buffer.
func (*Buffer) WriteFloat32 ¶
WriteFloat32 writes a float32 value to the buffer.
func (*Buffer) WriteFloat64 ¶
WriteFloat64 writes a float64 value to the buffer.
func (*Buffer) WriteInt16 ¶
WriteInt16 writes an int16 value to the buffer.
func (*Buffer) WriteInt32 ¶
WriteInt32 writes an int32 value to the buffer.
func (*Buffer) WriteInt64 ¶
WriteInt64 writes an int64 value to the buffer.
func (*Buffer) WriteString ¶
WriteString writes the string's length as a uint16 followed by the string contents.
func (*Buffer) WriteUInt16 ¶
WriteUInt16 writes a uint16 value to the buffer.
func (*Buffer) WriteUInt32 ¶
WriteUInt32 writes a uint32 value to the buffer.
func (*Buffer) WriteUInt64 ¶
WriteUInt64 writes a uint64 value to the buffer.
func (*Buffer) WriteUInt8 ¶
WriteUInt8 writes a uint8 value to the buffer.
type FixedMapPool ¶
type FixedMapPool struct {
// contains filtered or unexported fields
}
A buffered channel implementation of a vector map pool which controls the total number of maps allowed in/out of the pool at any given moment. Attempting to Get() with no available maps will block until one is available. You will be unable to Put() a map if the buffer is full.
func (*FixedMapPool) Get ¶
func (mp *FixedMapPool) Get() map[uint64]float64
Returns a map from the pool. Blocks if no maps are available for re-use
func (*FixedMapPool) Put ¶
func (mp *FixedMapPool) Put(m map[uint64]float64)
Adds a map back to the pool if there is room. Does not block on overflow.
type FlexibleMapPool ¶
type FlexibleMapPool struct {
// contains filtered or unexported fields
}
A buffered channel implementation of a vector map pool which controls the total number of maps allowed in/out of the pool at any given moment. Unlike the FixedMapPool, this pool will not block if maps are over requested, but will only maintain a buffer up the size limitation.
func (*FlexibleMapPool) Get ¶
func (mp *FlexibleMapPool) Get() map[uint64]float64
Returns a map from the pool. Does not block on over-request.
func (*FlexibleMapPool) Put ¶
func (mp *FlexibleMapPool) Put(m map[uint64]float64)
Adds a map back to the pool if there is room. Does not block on overflow.
type Semaphore ¶
type Semaphore struct {
// contains filtered or unexported fields
}
Semaphore implements a non-weighted semaphore for restricting concurrent access to a limited number of processes.
func NewSemaphore ¶
NewSemaphore creates a new Semaphore that allows max number of concurrent access
type UnboundedMapPool ¶
type UnboundedMapPool struct {
// contains filtered or unexported fields
}
Implementation backed by sync.Pool
func (*UnboundedMapPool) Get ¶
func (mp *UnboundedMapPool) Get() map[uint64]float64
Returns a map from the pool. Does not block on over-request.
func (*UnboundedMapPool) Put ¶
func (mp *UnboundedMapPool) Put(m map[uint64]float64)
Adds a map back to the pool if there is room. Does not block on overflow.
type Vector ¶
func ApplyVectorOp ¶
func ApplyVectorOp(xvs []*Vector, yvs []*Vector, op VectorJoinOp) []*Vector
ApplyVectorOp accepts two vectors, synchronizes timestamps, and executes an operation on each vector. See VectorJoinOp for details.
func NormalizeVectorByVector ¶
NormalizeVectorByVector produces a version of xvs (a slice of Vectors) which has had its timestamps rounded and its values divided by the values of the Vectors of yvs, such that yvs is the "unit" Vector slice.
type VectorJoinOp ¶
VectorJoinOp is an operation func that accepts a result vector pointer for a specific timestamp and two float64 pointers representing the input vectors for that timestamp. x or y inputs can be nil, but not both. The op should use x and y values to set the Value on the result ptr. If a result could not be generated, the op should return false, which will omit the vector for the specific timestamp. Otherwise, return true denoting a successful op.
type VectorMapPool ¶
A pool of vector maps for mapping float64 timestamps to float64 values
func NewFixedMapPool ¶
func NewFixedMapPool(size int) VectorMapPool
Creates a new fixed map pool which maintains a fixed pool size
func NewFlexibleMapPool ¶
func NewFlexibleMapPool(size int) VectorMapPool
Creates a new fixed map pool which maintains a fixed pool size
func NewUnboundedMapPool ¶
func NewUnboundedMapPool() VectorMapPool
Creates a new unbounded map pool which allows the runtime to decide when pooled values should be evicted
type VectorSlice ¶
type VectorSlice []*Vector
func (VectorSlice) Len ¶
func (p VectorSlice) Len() int
func (VectorSlice) Less ¶
func (p VectorSlice) Less(i, j int) bool
func (VectorSlice) Swap ¶
func (p VectorSlice) Swap(i, j int)