filter

package
v0.0.0-...-c1dc28d Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: MIT Imports: 1 Imported by: 4

Documentation

Overview

Package filter provides structures that represent filters. This package is primarily used by driver implementors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition interface {
	IsSatisfiedBy(*document.Document) bool
	Accept(Visitor) (bool, error)
}

Condition is a predicate that checks if a document meets a certain criteria.

type Filter

type Filter struct {
	Conditions []Condition
}

Filter is a collection of zero or more conditions. A filter with no conditions does not match any documents.

func New

func New(conds []Condition) *Filter

New returns a new filter with the given conditions.

func Optimize

func Optimize(f *Filter) *Filter

Optimize performs basic optimization of the given filter.

func (*Filter) Accept

func (f *Filter) Accept(v Visitor) (bool, error)

Accept calls c.Accept(v) for each condition in f.

If f is nil, Accept() returns true. If f is non-nil, but contains no matchers it returns false. The behavior is useful for building custom matchers.

func (*Filter) IsSatisfiedBy

func (f *Filter) IsSatisfiedBy(doc *document.Document) bool

IsSatisfiedBy returns true if doc meets this all of the conditions in the filter.

type HasKeys

type HasKeys struct {
	Values Set
}

HasKeys is a condition that matches documents that have all of a given set of keys.

func (*HasKeys) Accept

func (c *HasKeys) Accept(v Visitor) (bool, error)

Accept calls v.HasKeys(c).

func (*HasKeys) IsSatisfiedBy

func (c *HasKeys) IsSatisfiedBy(doc *document.Document) bool

IsSatisfiedBy returns true if doc meets this condition.

type HasUniqueKeyIn

type HasUniqueKeyIn struct {
	Values Set
}

HasUniqueKeyIn is a condition that matches documents with unique keys in given set.

func (*HasUniqueKeyIn) Accept

func (c *HasUniqueKeyIn) Accept(v Visitor) (bool, error)

Accept calls v.HasUniqueKeyIn(c).

func (*HasUniqueKeyIn) IsSatisfiedBy

func (c *HasUniqueKeyIn) IsSatisfiedBy(doc *document.Document) bool

IsSatisfiedBy returns true if doc meets this condition.

type IsOneOf

type IsOneOf struct {
	Values Set
}

IsOneOf is a condition that matches documents with IDs in a specific set.

func (*IsOneOf) Accept

func (c *IsOneOf) Accept(v Visitor) (bool, error)

Accept calls v.IsOneOf(c).

func (*IsOneOf) IsSatisfiedBy

func (c *IsOneOf) IsSatisfiedBy(doc *document.Document) bool

IsSatisfiedBy returns true if doc meets this condition.

type Set

type Set map[string]struct{}

Set is a set of strings.

func NewSet

func NewSet(members ...string) Set

NewSet returns a string set from a slice of its members.

func (Set) Copy

func (s Set) Copy() Set

Copy returns a copy of s.

func (Set) IntersectInPlace

func (s Set) IntersectInPlace(x Set)

IntersectInPlace updates s to the intersection of x and itself.

func (Set) UnionInPlace

func (s Set) UnionInPlace(x Set)

UnionInPlace updates s to the union of x and itself.

type Visitor

type Visitor interface {
	IsOneOf(*IsOneOf) (bool, error)
	HasUniqueKeyIn(*HasUniqueKeyIn) (bool, error)
	HasKeys(*HasKeys) (bool, error)
}

Visitor an interface for performing operations with filter conditions.

Jump to

Keyboard shortcuts

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