query

package
v0.0.0-...-348c89d Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_TERMS = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type Expression

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

Expression corresponds to SQL expressions.

func NewConstantExpression

func NewConstantExpression(val *record.Constant) *Expression

NewConstantExpression creates a new expression with a constant value.

func NewFieldExpression

func NewFieldExpression(fldname string) *Expression

NewFieldExpression creates a new expression with a field name.

func (*Expression) AppliesTo

func (e *Expression) AppliesTo(sch *record.Schema) bool

AppliesTo determines if all of the fields mentioned in this expression are contained in the specified schema.

func (*Expression) AsConstant

func (e *Expression) AsConstant() *record.Constant

AsConstant returns the constant corresponding to a constant expression, or nil if the expression does not denote a constant.

func (*Expression) AsFieldName

func (e *Expression) AsFieldName() string

AsFieldName returns the field name corresponding to a constant expression, or an empty string if the expression does not denote a field.

func (*Expression) Evaluate

func (e *Expression) Evaluate(s Scan) *record.Constant

Evaluate evaluates the expression with respect to the current record of the specified scan.

func (*Expression) IsFieldName

func (e *Expression) IsFieldName() bool

IsFieldName returns true if the expression is a field reference.

func (*Expression) ToString

func (e *Expression) ToString() string

ToString returns the string representation of the expression.

type PlanInfo

type PlanInfo interface {
	DistinctValues(fldname string) int
}

type Predicate

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

Predicate is a Boolean combination of terms.

func NewPredicate

func NewPredicate(term *Term) *Predicate

NewPredicate creates an empty predicate, corresponding to "true".

func NewPredicateWithTerm

func NewPredicateWithTerm(t *Term) *Predicate

NewPredicateWithTerm creates a predicate containing a single term.

func (*Predicate) ConjoinWith

func (p *Predicate) ConjoinWith(pred *Predicate)

ConjoinWith modifies the predicate to be the conjunction of itself and the specified predicate.

func (*Predicate) EquatesWithConstant

func (p *Predicate) EquatesWithConstant(fldname string) *record.Constant

EquatesWithConstant determines if there is a term of the form "F=c" where F is the specified field and c is some constant.

func (*Predicate) EquatesWithField

func (p *Predicate) EquatesWithField(fldname string) string

EquatesWithField determines if there is a term of the form "F1=F2" where F1 is the specified field and F2 is another field.

func (*Predicate) IsSatisfied

func (p *Predicate) IsSatisfied(s Scan) bool

IsSatisfied returns true if the predicate evaluates to true with respect to the specified scan.

func (*Predicate) JoinSubPred

func (p *Predicate) JoinSubPred(sch1, sch2 *record.Schema) *Predicate

JoinSubPred returns the subpredicate consisting of terms that apply to the union of the two specified schemas, but not to either schema separately.

func (*Predicate) ReductionFactor

func (p *Predicate) ReductionFactor(plan PlanInfo) int

ReductionFactor calculates the extent to which selecting on the predicate reduces the number of records output by a query.

func (*Predicate) SelectSubPred

func (p *Predicate) SelectSubPred(sch *record.Schema) *Predicate

SelectSubPred returns the subpredicate that applies to the specified schema.

func (*Predicate) String

func (p *Predicate) String() string

type ProductScan

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

ProductScan corresponds to the product relational algebra operator.

func NewProductScan

func NewProductScan(s1, s2 Scan) *ProductScan

NewProductScan creates a product scan having the two underlying scans.

func (*ProductScan) BeforeFirst

func (ps *ProductScan) BeforeFirst()

BeforeFirst positions the scan before its first record. In particular, the LHS scan is positioned at its first record, and the RHS scan is positioned before its first record.

func (*ProductScan) Close

func (ps *ProductScan) Close()

Close closes both underlying scans.

func (*ProductScan) GetInt

func (ps *ProductScan) GetInt(fldname string) int

GetInt returns the integer value of the specified field. The value is obtained from whichever scan contains the field.

func (*ProductScan) GetString

func (ps *ProductScan) GetString(fldname string) string

GetString returns the string value of the specified field. The value is obtained from whichever scan contains the field.

func (*ProductScan) GetVal

func (ps *ProductScan) GetVal(fldname string) *record.Constant

GetVal returns the value of the specified field. The value is obtained from whichever scan contains the field.

func (*ProductScan) HasField

func (ps *ProductScan) HasField(fldname string) bool

HasField returns true if the specified field is in either of the underlying scans.

func (*ProductScan) Next

func (ps *ProductScan) Next() bool

Next moves the scan to the next record. The method moves to the next RHS record, if possible. Otherwise, it moves to the next LHS record and the first RHS record. If there are no more LHS records, the method returns false.

type ProjectScan

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

func NewProjectScan

func NewProjectScan(s Scan, fieldlist []string) *ProjectScan

func (*ProjectScan) BeforeFirst

func (ps *ProjectScan) BeforeFirst()

func (*ProjectScan) Close

func (ps *ProjectScan) Close()

func (*ProjectScan) GetInt

func (ps *ProjectScan) GetInt(fldname string) int

func (*ProjectScan) GetString

func (ps *ProjectScan) GetString(fldname string) string

func (*ProjectScan) GetVal

func (ps *ProjectScan) GetVal(fldname string) *record.Constant

func (*ProjectScan) HasField

func (ps *ProjectScan) HasField(fldname string) bool

func (*ProjectScan) Next

func (ps *ProjectScan) Next() bool

type Scan

type Scan interface {
	// BeforeFirst positions the scan before its first record.
	// A subsequent call to Next will return the first record.
	BeforeFirst()

	// Next moves the scan to the next record.
	// Returns false if there is no next record.
	Next() bool

	// GetInt returns the value of the specified integer field in the current record.
	// The fldname parameter represents the name of the field.
	GetInt(fldname string) int

	// GetString returns the value of the specified string field in the current record.
	// The fldname parameter represents the name of the field.
	GetString(fldname string) string

	// GetVal returns the value of the specified field in the current record, expressed as a Constant.
	// The fldname parameter represents the name of the field.
	GetVal(fldname string) *record.Constant

	// HasField checks if the scan has the specified field.
	// The fldname parameter represents the name of the field.
	// Returns true if the scan has that field.
	HasField(fldname string) bool

	// Close closes the scan and its subscans, if any.
	Close()
}

type SelectScan

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

func NewSelectScan

func NewSelectScan(s Scan, pred Predicate) *SelectScan

NewSelectScan creates a new SelectScan instance

func (*SelectScan) BeforeFirst

func (ss *SelectScan) BeforeFirst()

BeforeFirst positions the scan before its first record

func (*SelectScan) Close

func (ss *SelectScan) Close()

func (*SelectScan) Delete

func (ss *SelectScan) Delete()

func (*SelectScan) GetInt

func (ss *SelectScan) GetInt(fldname string) int

func (*SelectScan) GetRid

func (ss *SelectScan) GetRid() *record.RID

func (*SelectScan) GetString

func (ss *SelectScan) GetString(fldname string) string

func (*SelectScan) GetVal

func (ss *SelectScan) GetVal(fldname string) *record.Constant

func (*SelectScan) HasField

func (ss *SelectScan) HasField(fldname string) bool

func (*SelectScan) Insert

func (ss *SelectScan) Insert()

func (*SelectScan) MoveToRid

func (ss *SelectScan) MoveToRid(rid *record.RID)

func (*SelectScan) Next

func (ss *SelectScan) Next() bool

Next moves the scan to the next record and returns true if there is such a record

func (*SelectScan) SetInt

func (ss *SelectScan) SetInt(fldname string, val int)

func (*SelectScan) SetString

func (ss *SelectScan) SetString(fldname string, val string)

func (*SelectScan) SetVal

func (ss *SelectScan) SetVal(fldname string, val *record.Constant)

type Term

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

func NewTerm

func NewTerm(lhs, rhs Expression) *Term

NewTerm creates a new Term instance with two expressions

func (*Term) AppliesTo

func (t *Term) AppliesTo(sch *record.Schema) bool

func (*Term) EquatesWithConstant

func (t *Term) EquatesWithConstant(fldname string) *record.Constant

func (*Term) EquatesWithField

func (t *Term) EquatesWithField(fldname string) string

func (*Term) IsSatisfied

func (t *Term) IsSatisfied(s Scan) bool

func (*Term) ReductionFactor

func (t *Term) ReductionFactor(p PlanInfo) int

func (*Term) String

func (t *Term) String() string

type UpdateScan

type UpdateScan interface {
	Scan // Embed the Scan interface

	// SetVal modifies the field value of the current record using a Constant
	SetVal(fldname string, val *record.Constant)

	// SetInt modifies the field value of the current record with an integer value
	SetInt(fldname string, val int)

	// SetString modifies the field value of the current record with a string value
	SetString(fldname string, val string)

	// Insert inserts a new record somewhere in the scan
	Insert()

	// Delete deletes the current record from the scan
	Delete()

	// GetRid returns the ID of the current record
	GetRid() *record.RID

	// MoveToRid positions the scan so that the current record has the specified ID
	MoveToRid(rid *record.RID)
}

Jump to

Keyboard shortcuts

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