tsdb

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Apache Software Foundation (ASF) licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Apache Software Foundation (ASF) licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptySeriesSpan = errors.New("there is no data in such time range")
	ErrItemIDMalformed = errors.New("serialized item id is malformed")
	ErrBlockAbsent     = errors.New("block is absent")
)
View Source
var (
	ErrInvalidShardID = errors.New("invalid shard id")
	ErrOpenDatabase   = errors.New("fails to open the database")
)
View Source
var AnyEntry = Entry(nil)
View Source
var ErrDuplicatedFamily = errors.New("duplicated family")
View Source
var ErrEndOfSegment = errors.New("reached the end of the segment")
View Source
var ErrNoTime = errors.New("no time specified")
View Source
var ErrNoVal = errors.New("no value specified")
View Source
var ErrUnsupportedIndexRule = errors.New("the index rule is not supported")

Functions

func GenerateInternalID

func GenerateInternalID(unit IntervalUnit, suffix int) uint16

func GlobalSeriesID

func GlobalSeriesID(scope Entry) common.SeriesID

func Hash

func Hash(entry []byte) []byte

func HashEntity

func HashEntity(entity Entity) []byte

func SeriesID

func SeriesID(entity Entity) common.SeriesID

func WalkDir

func WalkDir(root, prefix string, walkFn WalkFn) error

Types

type BlockID

type BlockID struct {
	SegID   uint16
	BlockID uint16
}

type BlockState

type BlockState struct {
	ID        BlockID
	TimeRange timestamp.TimeRange
	Closed    bool
}

type Condition

type Condition map[string][]index.ConditionValue

type Database

type Database interface {
	io.Closer
	Shards() []Shard
	Shard(id common.ShardID) (Shard, error)
}

func OpenDatabase

func OpenDatabase(ctx context.Context, opts DatabaseOpts) (Database, error)

type DatabaseOpts

type DatabaseOpts struct {
	Location       string
	ShardNum       uint32
	EncodingMethod EncodingMethod
	SegmentSize    IntervalRule
	BlockSize      IntervalRule
}

type EncodingMethod

type EncodingMethod struct {
	EncoderPool encoding.SeriesEncoderPool
	DecoderPool encoding.SeriesDecoderPool
}

type Entity

type Entity []Entry

func (Entity) Marshal

func (e Entity) Marshal() []byte

func (Entity) Prepend

func (e Entity) Prepend(entry Entry) Entity

type Entry

type Entry []byte

type GlobalItemID

type GlobalItemID struct {
	ShardID common.ShardID

	SeriesID common.SeriesID
	ID       common.ItemID
	// contains filtered or unexported fields
}

func (*GlobalItemID) Marshal

func (i *GlobalItemID) Marshal() []byte

func (*GlobalItemID) UnMarshal

func (i *GlobalItemID) UnMarshal(data []byte) error

type IndexDatabase

type IndexDatabase interface {
	WriterBuilder() IndexWriterBuilder
	Seek(field index.Field) ([]GlobalItemID, error)
}

type IndexSeekBuilder

type IndexSeekBuilder interface {
}

type IndexWriter

type IndexWriter interface {
	WriteLSMIndex(field index.Field) error
	WriteInvertedIndex(field index.Field) error
}

type IndexWriterBuilder

type IndexWriterBuilder interface {
	Scope(scope Entry) IndexWriterBuilder
	Time(ts time.Time) IndexWriterBuilder
	GlobalItemID(itemID GlobalItemID) IndexWriterBuilder
	Build() (IndexWriter, error)
}

type IntervalRule

type IntervalRule struct {
	Unit IntervalUnit
	Num  int
}

func (IntervalRule) EstimatedDuration

func (ir IntervalRule) EstimatedDuration() time.Duration

func (IntervalRule) NextTime

func (ir IntervalRule) NextTime(current time.Time) time.Time

type IntervalUnit

type IntervalUnit int
const (
	HOUR IntervalUnit = iota
	DAY
)

func (IntervalUnit) String

func (iu IntervalUnit) String() string

type Item

type Item interface {
	Family(family []byte) ([]byte, error)
	Val() ([]byte, error)
	ID() common.ItemID
	SortedField() []byte
	Time() uint64
}

type Iterator

type Iterator interface {
	Next() bool
	Val() Item
	Close() error
}

type Path

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

func NewPath

func NewPath(entries []Entry) Path

func (Path) Prepand

func (p Path) Prepand(entry Entry) Path

type ScopedShard

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

func (*ScopedShard) Close

func (sd *ScopedShard) Close() error

func (*ScopedShard) ID

func (sd *ScopedShard) ID() common.ShardID

func (*ScopedShard) Index

func (sd *ScopedShard) Index() IndexDatabase

func (*ScopedShard) Series

func (sd *ScopedShard) Series() SeriesDatabase

func (*ScopedShard) State

func (sd *ScopedShard) State() ShardState

type Seeker

type Seeker interface {
	Seek() ([]Iterator, error)
}

type SeekerBuilder

type SeekerBuilder interface {
	Filter(indexRule *databasev1.IndexRule, condition Condition) SeekerBuilder
	OrderByIndex(indexRule *databasev1.IndexRule, order modelv1.Sort) SeekerBuilder
	OrderByTime(order modelv1.Sort) SeekerBuilder
	Build() (Seeker, error)
}

type Series

type Series interface {
	ID() common.SeriesID
	Span(timeRange timestamp.TimeRange) (SeriesSpan, error)
	Get(id GlobalItemID) (Item, io.Closer, error)
}

type SeriesDatabase

type SeriesDatabase interface {
	observability.Observable
	io.Closer
	GetByID(id common.SeriesID) (Series, error)
	Get(entity Entity) (Series, error)
	GetByHashKey(key []byte) (Series, error)
	List(path Path) (SeriesList, error)
}

type SeriesList

type SeriesList []Series

func (SeriesList) Len

func (a SeriesList) Len() int

func (SeriesList) Less

func (a SeriesList) Less(i, j int) bool

func (SeriesList) Swap

func (a SeriesList) Swap(i, j int)

type SeriesSpan

type SeriesSpan interface {
	io.Closer
	WriterBuilder() WriterBuilder
	SeekerBuilder() SeekerBuilder
}

type Shard

type Shard interface {
	io.Closer
	ID() common.ShardID
	Series() SeriesDatabase
	Index() IndexDatabase
	State() ShardState
}

func NewScopedShard

func NewScopedShard(scope Entry, delegated Shard) Shard

func OpenShard

func OpenShard(ctx context.Context, id common.ShardID,
	root string, segmentSize, blockSize IntervalRule, openedBlockSize int) (Shard, error)

type ShardState

type ShardState struct {
	Blocks     []BlockState
	OpenBlocks []BlockID
}

type Supplier

type Supplier interface {
	SupplyTSDB() Database
}

type WalkFn

type WalkFn func(suffix, absolutePath string) error

type Writer

type Writer interface {
	IndexWriter
	Write() (GlobalItemID, error)
	ItemID() GlobalItemID
	String() string
}

type WriterBuilder

type WriterBuilder interface {
	Family(name []byte, val []byte) WriterBuilder
	Time(ts time.Time) WriterBuilder
	Val(val []byte) WriterBuilder
	Build() (Writer, error)
}

Directories

Path Synopsis
Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements.
Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements.

Jump to

Keyboard shortcuts

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