filter

package
v0.0.0-...-ad801e6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolFilter

type BoolFilter interface {
	// Match returns true if the given value is considered a match.
	Match(v bool) bool
}

BoolFilter matches against bool values.

type BytesFilter

type BytesFilter interface {
	// Match returns true if the given value is considered a match.
	Match(v xbytes.Bytes) bool
}

BytesFilter matches against bytes values.

type Combinator

type Combinator int

Combinator combines multiple filters.

const (
	UnknownCombinator Combinator = iota
	And
	Or
)

A list of supported filter combinators.

func (Combinator) String

func (f Combinator) String() string

String returns the string representation of the filter combinator.

func (*Combinator) ToProto

ToProto converts a filter combinator to an optional filter combinator protobuf message.

func (*Combinator) UnmarshalJSON

func (f *Combinator) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a JSON object as a filter combinator.

type DoubleFilter

type DoubleFilter interface {
	// Match returns true if the given value is considered a match.
	Match(v float64) bool
}

DoubleFilter matches against double values.

type IntFilter

type IntFilter interface {
	// Match returns true if the given value is considered a match.
	Match(v int) bool
}

IntFilter matches against int values.

type Op

type Op int

Op represents a filter operator.

const (
	UnknownOp Op = iota
	Equals
	NotEquals
	LargerThan
	LargerThanOrEqual
	SmallerThan
	SmallerThanOrEqual
	StartsWith
	DoesNotStartWith
	EndsWith
	DoesNotEndWith
	Contains
	DoesNotContain
	IsNull
	IsNotNull
	Exists
	DoesNotExist
)

A list of supported filter operators.

func (Op) AllowedTypes

func (f Op) AllowedTypes(v *field.ValueUnion) (field.ValueTypeSet, error)

AllowedTypes returns a list of value types that are allowed for the given filter operator and the right-hand-side value.

func (Op) BoolFilter

func (f Op) BoolFilter(v *field.ValueUnion) (BoolFilter, error)

BoolFilter returns a bool filter using the given value as the filter arguments.

func (Op) BoolIsInRange

func (f Op) BoolIsInRange(numTrues, numFalses int, filterVal bool) bool

BoolIsInRange returns true if filterVal exists in the values that this filter is acting on.

func (Op) BytesFilter

func (f Op) BytesFilter(v *field.ValueUnion) (BytesFilter, error)

BytesFilter returns a bytes filter using the given value as the filter arguments.

func (Op) BytesMaybeInRange

func (f Op) BytesMaybeInRange(min, max, filterVal []byte) bool

BytesMaybeInRange returns true if filterVal is within the range defined in by min and max. If this returns false, it means filterVal is definitely not within the value range [min, max]. If this returns true, it doesn't necessarily mean the filterVal exists in the values that this filter is acting on.

func (Op) DocIDSetFilterFn

func (f Op) DocIDSetFilterFn(numTotalDocs int32) (index.DocIDSetIteratorFn, error)

DocIDSetFilterFn returns the function associated with the filter operator to transform an input doc ID set iterator into a new doc ID set iterator, if applicable. This is used to distinguish doc ID filter operators such as `Exist` and `DoesNotExist` whose application transforms the doc ID set of a field into a new doc ID set. This is in contrast with other value filters that operate on the field values. If the operator is a valid value filter operator, it returns a nil function with a nil error. If the operator is invalid, it returns an error.

func (Op) DoubleFilter

func (f Op) DoubleFilter(v *field.ValueUnion) (DoubleFilter, error)

DoubleFilter returns a double filter using the given value as the filter arguments.

func (Op) DoubleMaybeInIntRange

func (f Op) DoubleMaybeInIntRange(min, max int, filterVal float64) (int, bool, error)

DoubleMaybeInIntRange returns true if filterVal may produce a match against the int values in the int range [min, max]. If this returns false, it means there can be no value match within the int value range [min, max] against the given double filter value. If this returns true, it returns the equivalent integer value for more efficient filtering, but doesn't guarantee a match against the integer values in range [min, max].

func (Op) DoubleMaybeInRange

func (f Op) DoubleMaybeInRange(min, max, filterVal float64) bool

DoubleMaybeInRange returns true if filterVal is within the range defined by min and max. If this returns false, it means filterVal is definitely not within the value range [min, max]. If this returns true, it doesn't necessarily mean the filterVal exists in the values that this filter is acting on.

func (Op) IntFilter

func (f Op) IntFilter(v *field.ValueUnion) (IntFilter, error)

IntFilter returns an int filter using the given value as the filter arguments.

func (Op) IntMaybeInRange

func (f Op) IntMaybeInRange(min, max, filterVal int) bool

IntMaybeInRange returns true if filterVal is within the range defined by min and max. If this returns false, it means filterVal is definitely not within the value range [min, max]. If this returns true, it doesn't necessarily mean the filterVal exists in the values that this filter is acting on.

func (Op) IsDocIDSetFilter

func (f Op) IsDocIDSetFilter() bool

IsDocIDSetFilter returns true if the filter should be applied to the doc ID set associated with the field values.

func (Op) IsValid

func (f Op) IsValid() bool

IsValid returns true if a filter operator is valid.

func (Op) IsValueFilter

func (f Op) IsValueFilter() bool

IsValueFilter returns true if the filter should be applied to individual field values.

func (Op) MultiTypeCombinator

func (f Op) MultiTypeCombinator() (Combinator, error)

MultiTypeCombinator returns the filter combinator to join the filter result for multi-typed field values. Specifically, if a field has values of type A and values of type B, applying the operator against the field will produce a result as follows: `filter(field) = filter(field_type_A) Combinator filter(field_type_B)`, where the Combinator is returned by this function.

func (Op) MustDocIDSetFilterFn

func (f Op) MustDocIDSetFilterFn(numTotalDocs int32) index.DocIDSetIteratorFn

MustDocIDSetFilterFn returns the function associated with the filter operator to transform an input doc ID set iterator into a new doc ID set iterator, or panics if an error is encountered.

func (Op) String

func (f Op) String() string

String returns the string representation of the filter operator.

func (Op) TimeFilter

func (f Op) TimeFilter(v *field.ValueUnion) (TimeFilter, error)

TimeFilter returns a time filter using the given value as the filter arguments.

func (Op) TimeMaybeInRange

func (f Op) TimeMaybeInRange(min, max, filterVal int64) bool

TimeMaybeInRange returns true if filterVal is within the range defined by min and max. If this returns false, it means filterVal is definitely not within the value range [min, max]. If this returns true, it doesn't necessarily mean the filterVal exists in the values that this filter is acting on.

func (Op) ToProto

func (f Op) ToProto() (servicepb.Filter_Op, error)

ToProto converts a filter op to a filter op proto message.

func (*Op) UnmarshalJSON

func (f *Op) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a JSON object as a filter operator.

type TimeFilter

type TimeFilter interface {
	// Match returns true if the given value is considered a match.
	Match(v int64) bool
}

TimeFilter matches against time values.

type TimeRangeFilter

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

TimeRangeFilter is a time range filter that matches time values in [startNanosInclusive, endNanosExclusive).

func NewTimeRangeFilter

func NewTimeRangeFilter(
	startNanosInclusive int64,
	endNanosExclusive int64,
) *TimeRangeFilter

NewTimeRangeFilter creates a new time range filter.

func (*TimeRangeFilter) Match

func (f *TimeRangeFilter) Match(timeNanos int64) bool

Match returns true if the time value in nanoseconds is in [start, end).

Jump to

Keyboard shortcuts

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