Documentation ¶
Overview ¶
Package lib provide useful functions and features that are not particularly tied up with any storage algorithm. They are meant to be small, self-contained and shall not depend on anything other than the standard library.
Index ¶
- Variables
- func AbsInt64(x int64) int64
- func Bytes2str(bytes []byte) string
- func FailsafePost(reqch chan []interface{}, cmd []interface{}, finch chan struct{}) error
- func FailsafeRequest(reqch, respch chan []interface{}, cmd []interface{}, finch chan struct{}) ([]interface{}, error)
- func Fixbuffer(buffer []byte, size int64) []byte
- func GetStacktrace(skip int, stack []byte) string
- func Memcpy(dst, src unsafe.Pointer, ln int) int
- func Parsecsv(input string) []string
- func Prettystats(stats map[string]interface{}, pretty bool) string
- func ResponseError(err error, response []interface{}, idx int) error
- func Str2bytes(str string) []byte
- type AverageInt64
- func (av *AverageInt64) Add(sample int64)
- func (av *AverageInt64) Clone() *AverageInt64
- func (av *AverageInt64) Max() int64
- func (av *AverageInt64) Mean() int64
- func (av *AverageInt64) Min() int64
- func (av *AverageInt64) SD() int64
- func (av *AverageInt64) Samples() int64
- func (av *AverageInt64) Stats() map[string]interface{}
- func (av *AverageInt64) Sum() int64
- func (av *AverageInt64) Variance() int64
- type Bit32
- type Bit8
- type HistogramInt64
- func (h *HistogramInt64) Add(sample int64)
- func (h *HistogramInt64) Clone() *HistogramInt64
- func (h *HistogramInt64) Fullstats() map[string]interface{}
- func (h *HistogramInt64) Logstring() string
- func (h *HistogramInt64) Max() int64
- func (h *HistogramInt64) Mean() int64
- func (h *HistogramInt64) Min() int64
- func (h *HistogramInt64) SD() int64
- func (h *HistogramInt64) Samples() int64
- func (h *HistogramInt64) Stats() map[string]int64
- func (h *HistogramInt64) Sum() int64
- func (h *HistogramInt64) Variance() int64
- type Uuid
Constants ¶
This section is empty.
Variables ¶
var ErrorUuidInvalidSize = errors.New("uuid.invalidsize")
ErrorUuidInvalidSize while generating uuid byte-string, the size of the byte-string shall be > 8 and shall be even numbered.
Functions ¶
func AbsInt64 ¶
AbsInt64 absolute value of int64 number. Except for -2^63, where returned value will be same as input.
func Bytes2str ¶
Bytes2str morph byte slice to a string without copying. Note that the source byte-slice should remain in scope as long as string is in scope.
func FailsafePost ¶
func FailsafePost( reqch chan []interface{}, cmd []interface{}, finch chan struct{}) error
FailsafePost for gen-server design pattern. While posting a message to reqch channel, if i/p channel is full but gen-server has exited or crashed, prevent caller from blocking.
func FailsafeRequest ¶
func FailsafeRequest( reqch, respch chan []interface{}, cmd []interface{}, finch chan struct{}) ([]interface{}, error)
FailsafeRequest for gen-server design pattern. While posting a request to reqch channel, if channel is full but gen-server has exited or crashed, prevent caller from blocking. Similarly, while waiting for a response from respch channel, if gen-server has exited or crashed, prevent caller from blocking.
func Fixbuffer ¶
Fixbuffer will expand the buffer if its capacity is less than size and return the buffer of size length.
func GetStacktrace ¶
GetStacktrace return stack-trace in human readable format.
func Memcpy ¶
Memcpy copy memory block of length `ln` from `src` to `dst`. This function is useful if memory block is obtained outside golang runtime.
func Prettystats ¶
Prettystats uses, if pretty is true, json.MarshalIndent instead of json.Marshal. If Marshal return error Prettystats will panic.
func ResponseError ¶
ResponseError for gen-server design pattern. Return err is not nil, else type-cast idx-th element in response to error and return the same.
Types ¶
type AverageInt64 ¶
type AverageInt64 struct {
// contains filtered or unexported fields
}
AverageInt64 compute statistical mean, median and variance for a sample set of int64 numbers.
func (*AverageInt64) Clone ¶
func (av *AverageInt64) Clone() *AverageInt64
Clone copies the entire instance.
func (*AverageInt64) Max ¶
func (av *AverageInt64) Max() int64
Max return maximum value from sample.
func (*AverageInt64) Mean ¶
func (av *AverageInt64) Mean() int64
Mean return the average value of all samples.
func (*AverageInt64) Min ¶
func (av *AverageInt64) Min() int64
Min return minimum value from sample.
func (*AverageInt64) SD ¶
func (av *AverageInt64) SD() int64
SD return by how much the samples differ from the mean value of sample set.
func (*AverageInt64) Samples ¶
func (av *AverageInt64) Samples() int64
Samples return total number of samples in the set.
func (*AverageInt64) Stats ¶
func (av *AverageInt64) Stats() map[string]interface{}
Stats return a map of statistics.
func (*AverageInt64) Sum ¶
func (av *AverageInt64) Sum() int64
Sum return the sum of all sample values.
func (*AverageInt64) Variance ¶
func (av *AverageInt64) Variance() int64
Variance return the squared deviation of a random sample from its mean.
type Bit32 ¶
type Bit32 uint32
Bit32 alias for uint32, provides bit twiddling methods on 32-bit number.
type Bit8 ¶
type Bit8 byte
Bit8 alias for byte, provides bit twiddling methods on 8-bit number.
type HistogramInt64 ¶
type HistogramInt64 struct {
// contains filtered or unexported fields
}
HistogramInt64 statistical histogram.
func NewhistorgramInt64 ¶
func NewhistorgramInt64(from, till, width int64) *HistogramInt64
NewhistorgramInt64 return a new histogram object.
func (*HistogramInt64) Add ¶
func (h *HistogramInt64) Add(sample int64)
Add a sample to this histogram.
func (*HistogramInt64) Clone ¶
func (h *HistogramInt64) Clone() *HistogramInt64
Clone copies the entire instance.
func (*HistogramInt64) Fullstats ¶
func (h *HistogramInt64) Fullstats() map[string]interface{}
Fullstats includes mean,variance,stddeviance in the Stats().
func (*HistogramInt64) Logstring ¶
func (h *HistogramInt64) Logstring() string
Logstring return Fullstats as loggable string.
func (*HistogramInt64) Max ¶
func (h *HistogramInt64) Max() int64
Max return maximum value from sample.
func (*HistogramInt64) Mean ¶
func (h *HistogramInt64) Mean() int64
Mean return the average value of all samples.
func (*HistogramInt64) Min ¶
func (h *HistogramInt64) Min() int64
Min return minimum value from sample.
func (*HistogramInt64) SD ¶
func (h *HistogramInt64) SD() int64
SD return by how much the samples differ from the mean value of sample set.
func (*HistogramInt64) Samples ¶
func (h *HistogramInt64) Samples() int64
Samples return total number of samples in the set.
func (*HistogramInt64) Stats ¶
func (h *HistogramInt64) Stats() map[string]int64
Stats return a map of histogram.
func (*HistogramInt64) Sum ¶
func (h *HistogramInt64) Sum() int64
Sum return the sum of all sample values.
func (*HistogramInt64) Variance ¶
func (h *HistogramInt64) Variance() int64
Variance return the squared deviation of a random sample from its mean.