storage

package
v0.0.0-...-c4188eb Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version      uint16 = 1
	MetaSize     uint64 = 512
	MetaBaseSize uint64 = 3
	RootBaseSize uint64 = 12
)
View Source
const (
	LevelRoot    = 0x0001
	LevelYear    = 0x0002
	LevelMonth   = 0x0004
	LevelDay     = 0x0008
	LevelHour    = 0x0010
	LevelMinute  = 0x0020
	LevelSecond  = 0x0040
	LevelMSecond = 0x0080
	LevelUSecond = 0x0100
	LevelNSecond = 0x0200

	LevelFlag         = 0x0FFF
	LeafFlag          = 0x3000
	InteriorChunkFlag = 0x1000
	LeafChunkFlag     = 0x2000
)
View Source
const ChunkCrcSize int64 = 4
View Source
const ChunkLengthSize int64 = 4
View Source
const TimeFormat string = "2006-01-02 15:04:05"

Variables

View Source
var (
	// ErrDatabaseNotOpen is returned when a DB instance is accessed before it
	// is opened or after it is closed.
	ErrDatabaseNotOpen = errors.New("database not open")

	// ErrNotFound is returned when key is not exists.
	ErrNotFound = errors.New("key not found")

	// ErrInvalid is returned when both meta pages on a database are invalid.
	// This typically occurs when a file is not a database.
	ErrInvalid = errors.New("invalid database")

	// ErrVersionMismatch is returned when the data file was created with a different version.
	ErrVersionMismatch = errors.New("version mismatch")

	// ErrChecksum is returned when either meta page checksum does not match.
	ErrChecksum = errors.New("checksum error")

	// ErrTimeout is returned when a database cannot obtain an exclusive lock
	// on the data file after the timeout passed to Open().
	ErrTimeout = errors.New("timeout")

	ErrChunkBadCrc = errors.New("chunk crc bad")

	ErrChunkDataLessThanSize = errors.New("chunk data less than size")
)

Functions

This section is empty.

Types

type Cursor

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

type DB

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

func Open

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

func (*DB) Close

func (db *DB) Close() error

func (*DB) Cursor

func (db *DB) Cursor() *Cursor

func (*DB) Delete

func (db *DB) Delete(from int64, to int64)

func (*DB) Flush

func (db *DB) Flush() error

func (*DB) Get

func (db *DB) Get(key int64) (*Point, error)

func (*DB) Path

func (db *DB) Path() string

Path returns the path to currently open database file.

func (*DB) Put

func (db *DB) Put(key int64, value map[string]float64) error

put insert data, key is unixnano.

func (*DB) Query

func (db *DB) Query(from int64, to int64, level uint16, count int, reducer map[string]string) []*Point

Build a query

type Ops

type Ops struct {
	File *os.File
}

Quick operations for database file.

func (*Ops) GotoEOF

func (o *Ops) GotoEOF() (ret int64, err error)

func (*Ops) OpenFile

func (o *Ops) OpenFile(path string, flag int, perm os.FileMode) (*os.File, error)

func (*Ops) ReadAt

func (o *Ops) ReadAt(b []byte, off int64) (n int, err error)

func (*Ops) Sync

func (o *Ops) Sync() error

func (*Ops) WriteAt

func (o *Ops) WriteAt(b []byte, off int64) (n int, err error)

type Point

type Point struct {
	Timestamp int64              `json:timestamp`
	Value     map[string]float64 `json:value`
}

type Time

type Time struct {
	Time time.Time
	TS   int64
}

func NewTime

func NewTime(tm int64) Time

func (*Time) Level

func (t *Time) Level() uint16

func (*Time) Timestamp

func (t *Time) Timestamp(level uint16) int64

type Value

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

Jump to

Keyboard shortcuts

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