system.query_processing.operators module

Concrete query-processing operators: scan, filter, simple hash join, semi-join, print, collect, count.

class system.query_processing.operators.Relation(name: str, data: list)[source]

Bases: Operator

Relation operator to iterate over the given list of tuples.

interpret_open()[source]

See Operator.interpret_open().

Source operator: pushes every tuple of the in-memory list to the parent.

interpret_next(tup)[source]

See Operator.interpret_next().

Unreachable: a source operator has no child that could push to it.

interpret_close()[source]

See Operator.interpret_close().

Leaf/source operator: no child to close.

compile(emit: str = None) → str[source]

See Operator.compile().

Not supported for in-memory relations.

dump(indent: int = 0) → None[source]

See Operator.dump().

class system.query_processing.operators.Scan(file: str, num_tuples: int = inf)[source]

Bases: Operator

Scan operator to iterate over the given number of tuples in the underlying storage file.

interpret_open()[source]

See Operator.interpret_open().

Source operator: reads the pickled tuples from the storage file and pushes up to num_tuples of them to the parent.

interpret_next(tup)[source]

See Operator.interpret_next().

Unreachable: a source operator has no child that could push to it.

interpret_close()[source]

See Operator.interpret_close().

Leaf/source operator: no child to close.

compile(emit: str = None) → str[source]

See Operator.compile().

Emits a loop over the pickled file, optionally bounded by num_tuples.

dump(indent: int = 0) → None[source]

See Operator.dump().

class system.query_processing.operators.Filter(child: Operator, pred: str)[source]

Bases: Operator

Filter operator to select tuples according to the given predicate.

interpret_open()[source]

See Operator.interpret_open().

Opens the single child operator.

interpret_next(tup)[source]

See Operator.interpret_next().

Pushes the tuple to the parent only if the predicate evaluates to true.

interpret_close()[source]

See Operator.interpret_close().

Closes the single child operator.

compile(emit: str = None) → str[source]

See Operator.compile().

Wraps the child’s compiled code in an if guarding on the predicate.

dump(indent: int = 0) → None[source]

See Operator.dump().

class system.query_processing.operators.SHJ(left_child: Operator, right_child: Operator, left_attr: str, right_attr: str)[source]

Bases: Operator

Simple-hash join operator to join the two children inputs according to the given join attributes.

interpret_open()[source]

See Operator.interpret_open().

Builds the hash table from the left child, then probes it with the right child.

interpret_next(tup)[source]

See Operator.interpret_next().

In the build phase inserts the tuple into the hash table; in the probe phase joins it with matching build tuples and pushes the merged tuples.

interpret_close()[source]

See Operator.interpret_close().

Closes both child operators.

compile(emit: str = None) → str[source]

See Operator.compile().

Emits the build loop over the left child followed by the probe loop over the right child.

dump(indent: int = 0) → None[source]

See Operator.dump().

class system.query_processing.operators.SemiJ(left_child: Operator, right_child: Operator, left_attr: str, right_attr: str)[source]

Bases: Operator

(Left) Semi-join operator to reduce the first input relation based on the join results according to the given join attributes with the second input relation.

interpret_open()[source]

See Operator.interpret_open().

Builds the hash table from the RIGHT child, then probes it with the LEFT child.

interpret_next(tup)[source]

See Operator.interpret_next().

In the build phase inserts the right tuple into the hash table; in the probe phase pushes the left tuple unchanged if a match exists (no merge).

interpret_close()[source]

See Operator.interpret_close().

Closes both child operators.

compile(emit: str = None) → str[source]

See Operator.compile().

Not supported for the semi-join operator.

dump(indent: int = 0) → None[source]

See Operator.dump().

class system.query_processing.operators.Print(child: Operator)[source]

Bases: Operator

Print operator to print tuples to the console.

interpret_open()[source]

See Operator.interpret_open().

Opens the single child operator.

interpret_next(tup)[source]

See Operator.interpret_next().

Prints the tuple’s values to the console; this is a sink, so nothing is pushed.

interpret_close()[source]

See Operator.interpret_close().

Closes the single child operator.

compile()[source]

See Operator.compile().

Sink operator: emits the child’s code with a leading import pickle and a print of each tuple. Takes no emit argument.

dump()[source]

See Operator.dump().

Sink operator: takes no indent argument.

class system.query_processing.operators.Collect(child: Operator)[source]

Bases: Operator

Collect operator to collect all resulting tuples.

interpret_open()[source]

See Operator.interpret_open().

Resets the result list and opens the single child operator.

interpret_next(tup)[source]

See Operator.interpret_next().

Appends the tuple’s values to the result list; this is a sink, so nothing is pushed.

interpret_close()[source]

See Operator.interpret_close().

Closes the single child operator.

compile()[source]

See Operator.compile().

Sink operator: emits the child’s code collecting each tuple into a result list. Takes no emit argument.

dump()[source]

See Operator.dump().

Sink operator: takes no indent argument.

class system.query_processing.operators.Count(child: Operator)[source]

Bases: Operator

Count operator to count all resulting tuples.

interpret_open()[source]

See Operator.interpret_open().

Resets the tuple counter and opens the single child operator.

interpret_next(tup)[source]

See Operator.interpret_next().

Increments the tuple counter; this is a sink, so nothing is pushed.

interpret_close()[source]

See Operator.interpret_close().

Closes the single child operator.

compile()[source]

See Operator.compile().

Sink operator: emits the child’s code incrementing a num_tuples counter. Takes no emit argument.

dump()[source]

See Operator.dump().

Sink operator: takes no indent argument.