system.query_optimization.join_graph module

Join graph model and factories for chain, star, cycle, and clique queries.

class system.query_optimization.join_graph.JoinGraph(number_of_relations: int)[source]

Bases: object

A join graph for a query. Internally, it uses an adjacency list to represent the graph.

add_join(left_relation: int, right_relation: int)[source]

Adds a join between the left and the right relation. :param left_relation: The id of the left relation. :param right_relation: The id of the right relation.

are_connected(left: Problem, right: Problem) → bool[source]

Checks whether the left and right problem are connected. :param left: The left problem. :param right: The right problem. :return: True, if the problems are connected, False if not.

is_connected(problem: Problem) → bool[source]

Checks whether the problem is connected in the join graph. :param problem: The problem to be checked. :return: True, if the problem is connected, False if not.

get_neighbors(s: Problem) → Problem[source]

Get all neighbors of a given problem s (excluding s). :param s: The set whose neighbors are of interest. :return: The neighbors as problem.

class system.query_optimization.join_graph.JoinGraphFactory[source]

Bases: ABC

A simple, abstract factory class to create certain join graph schemes.

abstractmethod static construct_join_graph(num_nodes: int) → JoinGraph[source]

Construct a join graph following this factory’s scheme. :param num_nodes: The number of relations in the join graph. :return: The constructed join graph.

class system.query_optimization.join_graph.ChainQueryFactory[source]

Bases: JoinGraphFactory

Creates a chain query of the given size.

static construct_join_graph(num_nodes: int) → JoinGraph[source]

See JoinGraphFactory.construct_join_graph().

Builds a chain query, joining each relation i with relation i + 1.

class system.query_optimization.join_graph.StarQueryFactory[source]

Bases: JoinGraphFactory

Creates a star query of the given size.

static construct_join_graph(num_nodes: int) → JoinGraph[source]

See JoinGraphFactory.construct_join_graph().

Builds a star query, joining the fact table (relation 0) with every other relation.

class system.query_optimization.join_graph.CycleQueryFactory[source]

Bases: JoinGraphFactory

Creates a cycle query of the given size.

static construct_join_graph(num_nodes: int) → JoinGraph[source]

See JoinGraphFactory.construct_join_graph().

Builds a cycle query, i.e., a chain query with an additional edge closing the last relation back to the first.

class system.query_optimization.join_graph.CliqueQueryFactory[source]

Bases: JoinGraphFactory

Creates a clique query of the given size.

static construct_join_graph(num_nodes: int) → JoinGraph[source]

See JoinGraphFactory.construct_join_graph().

Builds a clique query, joining every relation with every relation (self-joins included).