finder

package
v0.13.4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: MIT Imports: 18 Imported by: 6

Documentation

Index

Constants

View Source
const DefaultTreeDate = "1970-02-12"
View Source
const ReverseLevelOffset = 10000
View Source
const ReverseTreeLevelOffset = 30000
View Source
const TreeLevelOffset = 20000

Variables

View Source
var EmptyList [][]byte = [][]byte{}
View Source
var ErrEmptyArgs = errors.New("empty arguments")
View Source
var ErrInvalidSeriesByTag = errs.NewErrorWithCode("wrong seriesByTag call", http.StatusBadRequest)
View Source
var ErrNotImplemented = errors.New("not implemented")

Functions

func Leaf

func Leaf(value []byte) ([]byte, bool)

Leaf strips last dot and detect IsLeaf

func ReverseBytes added in v0.3.2

func ReverseBytes(target []byte) []byte

func ReverseString added in v0.3.2

func ReverseString(target string) string

func TaggedDecode added in v0.13.4

func TaggedDecode(v []byte) []byte

func TaggedTermWhere1 added in v0.7.0

func TaggedTermWhere1(term *TaggedTerm) (string, error)

func TaggedTermWhereN added in v0.7.0

func TaggedTermWhereN(term *TaggedTerm) (string, error)

func TaggedWhere added in v0.11.6

func TaggedWhere(terms []TaggedTerm) (*where.Where, *where.Where, error)

Types

type BaseFinder

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

func (*BaseFinder) Abs

func (b *BaseFinder) Abs(v []byte) []byte

func (*BaseFinder) Bytes added in v0.13.4

func (b *BaseFinder) Bytes() ([]byte, error)

func (*BaseFinder) Execute

func (b *BaseFinder) Execute(ctx context.Context, query string, from int64, until int64, stat *FinderStat) (err error)

func (*BaseFinder) List

func (b *BaseFinder) List() [][]byte

func (*BaseFinder) Series

func (b *BaseFinder) Series() [][]byte

type BlacklistFinder added in v0.4.0

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

func WrapBlacklist added in v0.4.0

func WrapBlacklist(f Finder, blacklist []*regexp.Regexp) *BlacklistFinder

func (*BlacklistFinder) Abs added in v0.4.0

func (p *BlacklistFinder) Abs(v []byte) []byte

func (*BlacklistFinder) Bytes added in v0.13.4

func (p *BlacklistFinder) Bytes() ([]byte, error)

func (*BlacklistFinder) Execute added in v0.4.0

func (p *BlacklistFinder) Execute(ctx context.Context, query string, from int64, until int64, stat *FinderStat) (err error)

func (*BlacklistFinder) List added in v0.4.0

func (p *BlacklistFinder) List() [][]byte

func (*BlacklistFinder) Series added in v0.4.0

func (p *BlacklistFinder) Series() [][]byte

For Render

type DateFinder added in v0.5.0

type DateFinder struct {
	*BaseFinder
	// contains filtered or unexported fields
}

func (*DateFinder) Execute added in v0.5.0

func (b *DateFinder) Execute(ctx context.Context, query string, from int64, until int64, stat *FinderStat) (err error)

type DateFinderV3 added in v0.6.3

type DateFinderV3 struct {
	*BaseFinder
}

func (*DateFinderV3) Execute added in v0.6.3

func (f *DateFinderV3) Execute(ctx context.Context, query string, from int64, until int64, stat *FinderStat) (err error)

func (*DateFinderV3) List added in v0.6.3

func (f *DateFinderV3) List() [][]byte

func (*DateFinderV3) Series added in v0.6.3

func (f *DateFinderV3) Series() [][]byte

type Finder

type Finder interface {
	Result
	Execute(ctx context.Context, query string, from int64, until int64, stat *FinderStat) error
}

func NewBase

func NewBase(url string, table string, opts clickhouse.Options) Finder

func NewCachedIndex added in v0.13.4

func NewCachedIndex(body []byte) Finder

func NewDateFinder added in v0.5.0

func NewDateFinder(url string, table string, tableVersion int, opts clickhouse.Options) Finder

func NewDateFinderV3 added in v0.6.3

func NewDateFinderV3(url string, table string, opts clickhouse.Options) Finder

Same as v2, but reversed

func NewIndex added in v0.9.0

func NewIndex(url string, table string, dailyEnabled bool, reverse string, reverses config.IndexReverses, opts clickhouse.Options, useCache bool) Finder

type FinderStat added in v0.13.4

type FinderStat struct {
	ReadBytes   int64
	ChReadRows  int64
	ChReadBytes int64
	Table       string
}

type IndexFinder added in v0.9.0

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

func (*IndexFinder) Abs added in v0.9.0

func (idx *IndexFinder) Abs(v []byte) []byte

func (*IndexFinder) Bytes added in v0.13.4

func (idx *IndexFinder) Bytes() ([]byte, error)

func (*IndexFinder) Execute added in v0.9.0

func (idx *IndexFinder) Execute(ctx context.Context, query string, from int64, until int64, stat *FinderStat) (err error)

func (*IndexFinder) List added in v0.9.0

func (idx *IndexFinder) List() [][]byte

func (*IndexFinder) Series added in v0.9.0

func (idx *IndexFinder) Series() [][]byte

type MockFinder

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

MockFinder is used for testing purposes

func NewMockFinder

func NewMockFinder(result [][]byte) *MockFinder

NewMockFinder returns new MockFinder object with given result

func NewMockTagged added in v0.13.4

func NewMockTagged(result [][]byte) *MockFinder

NewMockTagged returns new MockFinder object with given result

func (*MockFinder) Abs

func (m *MockFinder) Abs(v []byte) []byte

Abs returns the same given v

func (*MockFinder) Bytes added in v0.13.4

func (m *MockFinder) Bytes() ([]byte, error)

func (*MockFinder) Execute

func (m *MockFinder) Execute(ctx context.Context, query string, from int64, until int64, stat *FinderStat) (err error)

Execute assigns given query to the query field

func (*MockFinder) List

func (m *MockFinder) List() [][]byte

List returns the result

func (*MockFinder) Series

func (m *MockFinder) Series() [][]byte

Series returns the result

func (*MockFinder) Strings added in v0.13.0

func (m *MockFinder) Strings() []string

Strings returns the result converted to []string

type PrefixFinder

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

func WrapPrefix

func WrapPrefix(f Finder, prefix string) *PrefixFinder

func (*PrefixFinder) Abs

func (p *PrefixFinder) Abs(value []byte) []byte

func (*PrefixFinder) Bytes added in v0.13.4

func (p *PrefixFinder) Bytes() ([]byte, error)

func (*PrefixFinder) Execute

func (p *PrefixFinder) Execute(ctx context.Context, query string, from int64, until int64, stat *FinderStat) error

func (*PrefixFinder) List

func (p *PrefixFinder) List() [][]byte

func (*PrefixFinder) Series

func (p *PrefixFinder) Series() [][]byte

For Render

type PrefixMatchResult

type PrefixMatchResult int
const (
	PrefixNotMatched PrefixMatchResult = iota
	PrefixMatched
	PrefixPartialMathed
)

type Result added in v0.6.0

type Result interface {
	List() [][]byte
	Series() [][]byte
	Abs([]byte) []byte
	Bytes() ([]byte, error)
}

func Find added in v0.6.0

func Find(config *config.Config, ctx context.Context, query string, from int64, until int64, stat *FinderStat) (Result, error)

func FindTagged added in v0.11.6

func FindTagged(config *config.Config, ctx context.Context, terms []TaggedTerm, from int64, until int64, stat *FinderStat) (Result, error)

type ReverseFinder added in v0.3.2

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

func WrapReverse added in v0.3.2

func WrapReverse(f Finder, url string, table string, opts clickhouse.Options) *ReverseFinder

func (*ReverseFinder) Abs added in v0.3.2

func (r *ReverseFinder) Abs(v []byte) []byte

func (*ReverseFinder) Bytes added in v0.13.4

func (f *ReverseFinder) Bytes() ([]byte, error)

func (*ReverseFinder) Execute added in v0.3.2

func (r *ReverseFinder) Execute(ctx context.Context, query string, from int64, until int64, stat *FinderStat) (err error)

func (*ReverseFinder) List added in v0.3.2

func (r *ReverseFinder) List() [][]byte

func (*ReverseFinder) Series added in v0.3.2

func (r *ReverseFinder) Series() [][]byte

type TagFinder

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

func WrapTag

func WrapTag(f Finder, url string, table string, opts clickhouse.Options) *TagFinder

func (*TagFinder) Abs

func (t *TagFinder) Abs(v []byte) []byte

func (*TagFinder) Bytes added in v0.13.4

func (t *TagFinder) Bytes() ([]byte, error)

func (*TagFinder) Execute

func (t *TagFinder) Execute(ctx context.Context, query string, from int64, until int64, stat *FinderStat) (err error)

func (*TagFinder) List

func (t *TagFinder) List() [][]byte

func (*TagFinder) MakeSQL

func (t *TagFinder) MakeSQL(query string) (string, error)

func (*TagFinder) Series

func (t *TagFinder) Series() [][]byte

type TagQ

type TagQ struct {
	Param *string
	Value *string
}

func (TagQ) String

func (q TagQ) String() string

func (*TagQ) Where

func (q *TagQ) Where(field string) string

type TagState

type TagState int
const (
	TagRoot     TagState = iota // query = "*"
	TagSkip                     // not _tag prefix
	TagInfoRoot                 // query = "_tag"
	TagList
	TagListSeriesRoot
	TagListSeries
	TagListParam
)

type TaggedFinder added in v0.6.0

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

func NewCachedTags added in v0.13.4

func NewCachedTags(body []byte) *TaggedFinder

func NewTagged added in v0.6.0

func NewTagged(url string, table string, dailyEnabled bool, absKeepEncoded bool, opts clickhouse.Options, taggedCosts map[string]*config.Costs) *TaggedFinder

func (*TaggedFinder) Abs added in v0.6.0

func (t *TaggedFinder) Abs(v []byte) []byte

func (*TaggedFinder) Bytes added in v0.13.4

func (t *TaggedFinder) Bytes() ([]byte, error)

func (*TaggedFinder) Execute added in v0.6.0

func (t *TaggedFinder) Execute(ctx context.Context, query string, from int64, until int64, stat *FinderStat) error

func (*TaggedFinder) ExecutePrepared added in v0.11.6

func (t *TaggedFinder) ExecutePrepared(ctx context.Context, terms []TaggedTerm, from int64, until int64, stat *FinderStat) error

func (*TaggedFinder) List added in v0.6.0

func (t *TaggedFinder) List() [][]byte

func (*TaggedFinder) Series added in v0.6.0

func (t *TaggedFinder) Series() [][]byte

type TaggedTerm added in v0.7.0

type TaggedTerm struct {
	Key         string
	Op          TaggedTermOp
	Value       string
	HasWildcard bool // only for TaggedTermEq

	NonDefaultCost bool
	Cost           int // tag cost for use ad primary filter (use tag with maximal selectivity). 0 by default, minimal is better.

}

func ParseSeriesByTag added in v0.11.6

func ParseSeriesByTag(query string, tagCosts map[string]*config.Costs) ([]TaggedTerm, error)

func ParseTaggedConditions added in v0.11.6

func ParseTaggedConditions(conditions []string, taggedCosts map[string]*config.Costs) ([]TaggedTerm, error)

type TaggedTermList added in v0.7.0

type TaggedTermList []TaggedTerm

func (TaggedTermList) Len added in v0.7.0

func (s TaggedTermList) Len() int

func (TaggedTermList) Less added in v0.7.0

func (s TaggedTermList) Less(i, j int) bool

func (TaggedTermList) Swap added in v0.7.0

func (s TaggedTermList) Swap(i, j int)

type TaggedTermOp added in v0.7.0

type TaggedTermOp int
const (
	TaggedTermEq       TaggedTermOp = 1
	TaggedTermMatch    TaggedTermOp = 2
	TaggedTermNe       TaggedTermOp = 3
	TaggedTermNotMatch TaggedTermOp = 4
)

Jump to

Keyboard shortcuts

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