metricdb

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package metricdb handles the storage for metrics.

Design

The db file name is metric and its key-value design in leveldb is:

Key:   <Name>:<Stamp>
Value: <Value>:<Score>:<Average>

For less disk usage:

1. Metric stamps will be converted to 36-hex strings before they are put to db.

2. Metric stamps will minus a "stamp horizon" before they are converted to string.

Index

Constants

View Source
const (
	// LevelDBBloomFilterBitsPerKey is the leveldb builtin bloom filter
	// bitsPerKey.
	//
	// Filter name will be persisted to disk on a per sstable basis, during
	// reads leveldb will try to find matching filter. And the filter can be
	// replaced after a DB has been created, or say that the filter can be
	// changed between db opens. But if this is done, note that old sstables
	// will continue using the old filter and every new created sstable will
	// use the new filter. For this reason, I make the parameter `bitsPerKey`
	// a constant, there is no need to replace it.
	//
	// Also, this means that no big performance penalty will be experienced
	// when changing the parameter, and the goleveldb docs points this as well.
	//
	// About the probability of false positives, the following link may help:
	// http://pages.cs.wisc.edu/~cao/papers/summary-cache/node8.html
	//
	LevelDBBloomFilterBitsPerKey = 10
)

Variables

View Source
var (
	// ErrNotFound is returned when requested data not found.
	ErrNotFound = errors.New("metricdb: not found")
	// ErrCorrupted is returned when corrupted data found.
	ErrCorrupted = errors.New("metricdb: corrupted data found")
	// ErrStampTooSmall is returned when stamp is smaller than horizon.
	ErrStampTooSmall = errors.New("metricdb: stamp is too small")
)

Functions

func Horizon

func Horizon() uint32

Horizon returns the timestamp horizon

Types

type DB

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

DB handles metrics storage.

func Open

func Open(fileName string) (*DB, error)

Open a DB by fileName.

func (*DB) Close

func (db *DB) Close() error

Close the DB.

func (*DB) Delete

func (db *DB) Delete(name string, start, end uint32) (int, error)

Delete metrics in a timestamp range, the range is left open and right closed.

func (*DB) DeleteTo

func (db *DB) DeleteTo(name string, end uint32) (int, error)

DeleteTo deletes metrics ranging to a stamp by name.

func (*DB) Get

func (db *DB) Get(name string, start, end uint32) ([]*models.Metric, error)

Get metrics in a timestamp range, the range is left open and right closed.

func (*DB) Put

func (db *DB) Put(m *models.Metric) error

Put a metric into db.

type Options added in v0.1.4

type Options struct {
}

Options is db opening options.

Jump to

Keyboard shortcuts

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