query

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregation

type Aggregation interface {
	// Translates the aggregation to a human readable format
	String() string
	// The target name of the attribute holding this aggregation
	Name() string
}

A Aggregation represents operations performed during the aggregation phase

type AndPredicate

type AndPredicate struct {
	Lhs Predicate
	Rhs Predicate
}

AndPredicate evaluates the boolean AND operation between two predicates

func (AndPredicate) Selectivity

func (p AndPredicate) Selectivity(d dataset.DataSet) float64

Selectivity implements Predicate.Selectivity by multiplying the selectivities of the sub-predicates

func (AndPredicate) String

func (q AndPredicate) String() string

type ArraySizeComparisonPredicate

type ArraySizeComparisonPredicate struct {
	Path    string
	Number  uint64
	Smaller bool
	Equal   bool
}

ArraySizeComparisonPredicate evaluates the Number comparison (<,>,<=,>=) operation between the number of entries in an array path and a given number

func (ArraySizeComparisonPredicate) Selectivity

Selectivity implements Predicate.Selectivity by estimating the selectivity given the data set. If no DataPath with matching type and path exists, 0 is returned If a data path exists, but has no count, 0.33333 is assumed and returned (predicate selects 1/3 of all documents) If min and max exists, a uniform distribution is assumed if the value is within the bounds and a selectivity of (1/(max-min)) is returned.

func (ArraySizeComparisonPredicate) String

type BoolEqualityPredicate

type BoolEqualityPredicate struct {
	Path  string
	Value bool
}

BoolEqualityPredicate evaluates the boolean equality operation between a path and a boolean

func (BoolEqualityPredicate) Selectivity

func (p BoolEqualityPredicate) Selectivity(d dataset.DataSet) float64

Selectivity implements Predicate.Selectivity by estimating the selectivity given the data set. If no DataPath with matching type and path exists, 0 is returned If a data path exists, but has no count, 0.5 is assumed and returned (predicate selects 50% of all documents) If true/false counts exist, an exact selectivity is returned.

func (BoolEqualityPredicate) String

func (q BoolEqualityPredicate) String() string

type CountAggregation

type CountAggregation struct {
	// The path to aggregate
	Path string
}

func (CountAggregation) Name

func (q CountAggregation) Name() string

func (CountAggregation) String

func (q CountAggregation) String() string

type ExistsPredicate

type ExistsPredicate struct {
	Path string
}

Predicate evaluating the existence of the given path

func (ExistsPredicate) Selectivity

func (p ExistsPredicate) Selectivity(d dataset.DataSet) float64

func (ExistsPredicate) String

func (q ExistsPredicate) String() string

type FloatComparisonPredicate

type FloatComparisonPredicate struct {
	Path    string
	Number  float64
	Smaller bool
	Equal   bool
}

FloatComparisonPredicate evaluates the Number comparison (<,>,<=,>=) operation between a path and a given number

func (FloatComparisonPredicate) Selectivity

Selectivity implements Predicate.Selectivity by estimating the selectivity given the data set. If no DataPath with matching type and path exists, 0 is returned If a data path exists, but has no count, 0.33333 is assumed and returned (predicate selects 1/3 of all documents) If min and max exists, a uniform distribution is assumed if the value is within the bounds and a selectivity of (1/(max-min)) is returned.

func (FloatComparisonPredicate) String

func (q FloatComparisonPredicate) String() string

type GlobalCountAggregation

type GlobalCountAggregation struct {
	// The path to aggregate
	Path string
}

func (GlobalCountAggregation) Name

func (q GlobalCountAggregation) Name() string

func (GlobalCountAggregation) String

func (q GlobalCountAggregation) String() string

type GroupedAggregation

type GroupedAggregation struct {
	// The path to aggregate
	Path string
	// Subaggregation to use
	Agg Aggregation
}

func (GroupedAggregation) Name

func (q GroupedAggregation) Name() string

func (GroupedAggregation) String

func (q GroupedAggregation) String() string

type IntEqualityPredicate

type IntEqualityPredicate struct {
	Path   string
	Number int64
}

IntEqualityPredicate evaluates the Number equality operation between a path and a given number

func (IntEqualityPredicate) Selectivity

func (p IntEqualityPredicate) Selectivity(d dataset.DataSet) float64

Selectivity implements Predicate.Selectivity by estimating the selectivity given the data set. If no DataPath with matching type and path exists, 0 is returned If a data path exists, but has no count, 0.01 is assumed and returned (predicate selects 1% of all documents) If a count exists, equality assumes that exactly one element is chosen, hence a selectivity of 1/count is returned. If min and max exists, a uniform distribution is assumed if the value is within the bounds and a selectivity of (1/(max-min)) is returned.

func (IntEqualityPredicate) String

func (q IntEqualityPredicate) String() string

type IsStringPredicate

type IsStringPredicate struct {
	Path string
}

Predicate evaluating the type of the given path

func (IsStringPredicate) Selectivity

func (p IsStringPredicate) Selectivity(d dataset.DataSet) float64

func (IsStringPredicate) String

func (q IsStringPredicate) String() string

type ObjectSizeComparisonPredicate

type ObjectSizeComparisonPredicate struct {
	Path    string
	Number  uint64
	Smaller bool
	Equal   bool
}

ObjectSizeComparisonPredicate evaluates the Number comparison (<,>,<=,>=) operation between the number of members in a path and a given number

func (ObjectSizeComparisonPredicate) Selectivity

Selectivity implements Predicate.Selectivity by estimating the selectivity given the data set. If no DataPath with matching type and path exists, 0 is returned If a data path exists, but has no count, 0.33333 is assumed and returned (predicate selects 1/3 of all documents) If min and max exists, a uniform distribution is assumed if the value is within the bounds and a selectivity of (1/(max-min)) is returned.

func (ObjectSizeComparisonPredicate) String

type OrPredicate

type OrPredicate struct {
	Lhs Predicate
	Rhs Predicate
}

OrPredicate evaluates the boolean OR operation between two predicates

func (OrPredicate) Selectivity

func (p OrPredicate) Selectivity(d dataset.DataSet) float64

Selectivity implements Predicate.Selectivity by adding the selectivities of the sub-predicates

func (OrPredicate) String

func (q OrPredicate) String() string

type Predicate

type Predicate interface {
	// Returns the estimated selectivity of filtering the given dataset with the predicate
	Selectivity(d dataset.DataSet) float64
	// Translates the predicate to a human readable format
	String() string
}

A Predicate represents operations performed during the filter phase

type Query

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

Query struct, specifying how the queries are constructed.

func RemoveIntermediateSets

func RemoveIntermediateSets(queries []Query) []Query

func (*Query) Aggregate

func (q *Query) Aggregate(agg Aggregation) *Query

Sets the aggreation of the query

func (*Query) Aggregation

func (q *Query) Aggregation() Aggregation

Gets the aggregation of the query

func (*Query) AggregationIsGrouped

func (q *Query) AggregationIsGrouped() bool

func (*Query) Base

func (q *Query) Base() *dataset.DataSet

Gets the loaded base dataset

func (*Query) BaseName

func (q *Query) BaseName() string

Gets the name of the storing dataset

func (*Query) BasedOn

func (q *Query) BasedOn(query *Query) *Query

func (Query) CopyWithoutAggregation

func (q Query) CopyWithoutAggregation() Query

Creates a copy of the query without any aggregation

func (*Query) CreateFrom

func (q *Query) CreateFrom() Query

func (*Query) Filter

func (q *Query) Filter(predicate Predicate) *Query

Filters the loaded dataset by a predicate (e.g.: WHERE x; CHOOSE x; FILTER x;)

func (*Query) FilterPredicate

func (q *Query) FilterPredicate() Predicate

Gets the name of the storing dataset

func (*Query) GenerateDataset

func (q *Query) GenerateDataset() dataset.DataSet

Uses the selectivity estimation to create a new mock dataset based on the query result

func (*Query) GetBaseQuery

func (q *Query) GetBaseQuery() *Query

func (Query) IsCopy

func (q Query) IsCopy() bool

Checks if a query only copies a dataset without changing it

func (*Query) Load

func (q *Query) Load(dataSet *dataset.DataSet) *Query

Loads a given dataset (e.g.: FROM x; LOAD x; USE x;)

func (Query) MergeQuery

func (q Query) MergeQuery() Query

func (*Query) Store

func (q *Query) Store(name string) *Query

Stores the query result in a new set (e.g.: INSERT INTO ... ; STORE x;)

func (*Query) StoreName

func (q *Query) StoreName() string

Gets the name of the storing dataset

func (*Query) String

func (q *Query) String() string

Translates the query to a human readable format

type StrEqualityPredicate

type StrEqualityPredicate struct {
	Path string
	Str  string
}

StrEqualityPredicate evaluates the String equality operation between a path and a given string

func (StrEqualityPredicate) Selectivity

func (p StrEqualityPredicate) Selectivity(d dataset.DataSet) float64

Selectivity implements Predicate.Selectivity by estimating the selectivity given the data set. If no DataPath with matching type and path exists, 0 is returned If a data path exists, but has no count, 0.01 is assumed and returned (predicate selects 1% of all documents) If a count exists, equality assumes that exactly one element is chosen, hence a selectivity of 1/count is returned. If min and max exists, a uniform distribution is assumed if the value is within the bounds and a selectivity of (1/(max-min)) is returned.

func (StrEqualityPredicate) String

func (q StrEqualityPredicate) String() string

type StrPrefixPredicate

type StrPrefixPredicate struct {
	Path   string
	Prefix string
}

StrPrefixPredicate checks if a given path contains a string with the given prefix

func (StrPrefixPredicate) Selectivity

func (p StrPrefixPredicate) Selectivity(d dataset.DataSet) float64

Selectivity implements Predicate.Selectivity by estimating the selectivity given the data set. If no DataPath with matching type and path exists, 0 is returned If a data path exists, but has no count, 0.01 is assumed and returned (predicate selects 1% of all documents) If a count and prefix list exists with a matching prefix, uniform distribution is assumed and 1/#prefixes is returned

func (StrPrefixPredicate) String

func (q StrPrefixPredicate) String() string

type SumAggregation

type SumAggregation struct {
	// The path to aggregate
	Path string
}

func (SumAggregation) Name

func (q SumAggregation) Name() string

func (SumAggregation) String

func (q SumAggregation) String() string

Jump to

Keyboard shortcuts

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