eval

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(record int, filter ast.Node) (bool, error)

Types

type Accessor

type Accessor ast.Node // for now

type Accessors

type Accessors map[ast.Ident]Accessor

type BooleanGetter

type BooleanGetter struct {
	Name string
	Func func(int) bool
}

func (BooleanGetter) String

func (n BooleanGetter) String() string

func (BooleanGetter) Transform

func (n BooleanGetter) Transform(cb ast.Cb) ast.Node

type Card

type Card struct {
	Name   string
	Value  int
	Filter string
}

type Dataset

type Dataset[T any, D ~[]T] struct {
	Source    D
	Accessors Accessors
	Facets    func(D, int) []Facet
	Sorters   Sorters[T]
}

func (Dataset[T, D]) IsBoolean

func (d Dataset[T, D]) IsBoolean(raw ast.Node) bool

func (Dataset[T, D]) IsFailure

func (d Dataset[T, D]) IsFailure(n ast.Node) (error, bool)

func (Dataset[T, D]) IsNumber

func (d Dataset[T, D]) IsNumber(raw ast.Node) bool

func (Dataset[T, D]) IsString

func (d Dataset[T, D]) IsString(raw ast.Node) bool

func (Dataset[T, D]) MatchAll

func (d Dataset[T, D]) MatchAll(m ast.Node) (or ast.Or)

MatchAll runs optimisation for single-string-filters: if filter is just a text, search in all string fields EXAMPLE: text -> a~test OR b~text OR c~text

func (Dataset[T, D]) Query

func (d Dataset[T, D]) Query(query string) (*QueryResult[T], error)

func (Dataset[T, D]) StringFrom

func (d Dataset[T, D]) StringFrom(n ast.Node) (ast.Node, bool)

func (Dataset[T, D]) Transform

func (d Dataset[T, D]) Transform(src ast.Query) ast.Node

type EqualNumber

type EqualNumber struct {
	Left, Right ast.Node
}

func (EqualNumber) Transform

func (n EqualNumber) Transform(cb ast.Cb) ast.Node

type EqualString

type EqualString struct {
	Left, Right ast.Node
}

func (EqualString) Transform

func (n EqualString) Transform(cb ast.Cb) ast.Node

type Facet

type Facet struct {
	Name string
	Top  []Card
}

type FacetRetriever

type FacetRetriever interface {
	Bucket() bucket
}

type FacetRetrievers

type FacetRetrievers[T any] []FacetRetriever

func (FacetRetrievers[T]) Facets

func (f FacetRetrievers[T]) Facets(result []T, topN int) (facets []Facet)

type GreaterThanNumber

type GreaterThanNumber struct {
	Left, Right ast.Node
}

func (GreaterThanNumber) Transform

func (n GreaterThanNumber) Transform(cb ast.Cb) ast.Node

type GreaterThanString

type GreaterThanString struct {
	Left, Right ast.Node
}

func (GreaterThanString) Transform

func (n GreaterThanString) Transform(cb ast.Cb) ast.Node

type Invalid

type Invalid struct {
	Message string
	Node    ast.Node
}

func (Invalid) Error

func (i Invalid) Error() string

func (Invalid) Transform

func (n Invalid) Transform(cb ast.Cb) ast.Node

type LessThanNumber

type LessThanNumber struct {
	Left, Right ast.Node
}

func (LessThanNumber) Transform

func (n LessThanNumber) Transform(cb ast.Cb) ast.Node

type LessThanString

type LessThanString struct {
	Left, Right ast.Node
}

func (LessThanString) Transform

func (n LessThanString) Transform(cb ast.Cb) ast.Node

type NumberGetter

type NumberGetter struct {
	Name string
	Func func(int) float64
}

func (NumberGetter) String

func (n NumberGetter) String() string

func (NumberGetter) Transform

func (n NumberGetter) Transform(cb ast.Cb) ast.Node

type NumberRanges added in v0.2.0

type NumberRanges struct {
	Getter   func(int) float64
	Field    string
	Name     string
	Duration bool
	Size     bool
	TimeAgo  bool
}

func (NumberRanges) Bucket added in v0.2.0

func (s NumberRanges) Bucket() bucket

type QueryResult

type QueryResult[T any] struct {
	Total   int
	Records []T
	Facets  []Facet
}

type Sorter

type Sorter[T any] struct {
	Asc         func(left, right T) bool
	Desc        func(left, right T) bool
	AscDefault  bool
	DescDefault bool
}

func (Sorter[T]) Comparator

func (s Sorter[T]) Comparator(ob ast.OrderBy) func(left, right T) bool

type Sorters

type Sorters[T any] map[string]Sorter[T]

func (Sorters[T]) Sort

func (s Sorters[T]) Sort(sort ast.Sort) (func(left, right T) bool, error)

type StringFacet

type StringFacet struct {
	Getter   func(int) string
	Field    string
	Name     string
	Contains bool
}

func (StringFacet) Bucket

func (s StringFacet) Bucket() bucket

type StringGetter

type StringGetter struct {
	Name string
	Func func(int) string
}

func (StringGetter) String

func (n StringGetter) String() string

func (StringGetter) Transform

func (n StringGetter) Transform(cb ast.Cb) ast.Node

Jump to

Keyboard shortcuts

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