neurolang.relational_algebra.optimisers module

class neurolang.relational_algebra.optimisers.CommuteJoinsAvoidCrossProducts(*args, **kwargs)

Bases: PatternWalker

Attributes:
patterns

Property holding an iterator of triplets (pattern, guard, action).

Methods

match(expression)

Find the action for a given expression by going through the patterns.

pattern_match(pattern, expression)

Return True if pattern matches expression.

type

commute_left

commute_right

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

walk

commute_left(expression)
commute_right(expression)
type = typing.Any
class neurolang.relational_algebra.optimisers.EliminateTrivialProjections(*args, **kwargs)

Bases: PatternWalker

Attributes:
patterns

Property holding an iterator of triplets (pattern, guard, action).

Methods

match(expression)

Find the action for a given expression by going through the patterns.

pattern_match(pattern, expression)

Return True if pattern matches expression.

type

convert_extended_projection_2_projection

convert_extended_projection_2_rename

eliminate_trivial_nested_projection

eliminate_trivial_nested_unnamed_projection

eliminate_trivial_projection

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

simplify_projection_extended_projection

walk

convert_extended_projection_2_projection(expression)
convert_extended_projection_2_rename(expression)
eliminate_trivial_nested_projection(expression)
eliminate_trivial_nested_unnamed_projection(expression)
eliminate_trivial_projection(expression)
simplify_projection_extended_projection(expression)
type = typing.Any
class neurolang.relational_algebra.optimisers.ProductSimplification(*args, **kwargs)

Bases: ExpressionWalker

Attributes:
patterns

Property holding an iterator of triplets (pattern, guard, action).

Methods

match(expression)

Find the action for a given expression by going through the patterns.

pattern_match(pattern, expression)

Return True if pattern matches expression.

type

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

process_expression

process_iterable_argument

single_product

walk

single_product(product)
type = typing.Any
class neurolang.relational_algebra.optimisers.PushInSelections(*args, **kwargs)

Bases: PatternWalker

Attributes:
patterns

Property holding an iterator of triplets (pattern, guard, action).

Methods

match(expression)

Find the action for a given expression by going through the patterns.

pattern_match(pattern, expression)

Return True if pattern matches expression.

type

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

push_and_rename_in_naturaljoin

push_selection_in_extended_projection

push_selection_in_groupby

push_selection_in_left

push_selection_in_leftnaturaljoin_left

push_selection_in_leftnaturaljoin_right

push_selection_in_outernaturaljoin_left

push_selection_in_outernaturaljoin_right

push_selection_in_projection

push_selection_in_replace_null

push_selection_in_right

walk

push_and_rename_in_naturaljoin(expression)
push_selection_in_extended_projection(expression)
push_selection_in_groupby(expression)
push_selection_in_left(expression)
push_selection_in_leftnaturaljoin_left(expression)
push_selection_in_leftnaturaljoin_right(expression)
push_selection_in_outernaturaljoin_left(expression)
push_selection_in_outernaturaljoin_right(expression)
push_selection_in_projection(expression)
push_selection_in_replace_null(expression)
push_selection_in_right(expression)
type = typing.Any
class neurolang.relational_algebra.optimisers.PushUnnamedSelectionsUp(*args, **kwargs)

Bases: PatternWalker

Attributes:
patterns

Property holding an iterator of triplets (pattern, guard, action).

Methods

match(expression)

Find the action for a given expression by going through the patterns.

pattern_match(pattern, expression)

Return True if pattern matches expression.

type

invert_selection_order

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

push_selection_above_name_columns

push_selection_above_projection

standardize_projected_column

walk

invert_selection_order(expression)
push_selection_above_name_columns(expression)
push_selection_above_projection(expression)
standardize_projected_column(expression)
type = typing.Any
class neurolang.relational_algebra.optimisers.RelationalAlgebraOptimiser(*args, **kwargs)

Bases: RewriteSelections, ProductSimplification, EliminateTrivialProjections, PushInSelections, RenameOptimizations, PushUnnamedSelectionsUp, CommuteJoinsAvoidCrossProducts, ExpressionWalker

Mixing that optimises through relational algebra expressions by rewriting. equi-selection/product compositions into equijoins.

Attributes:
patterns

Property holding an iterator of triplets (pattern, guard, action).

Methods

match(expression)

Find the action for a given expression by going through the patterns.

pattern_match(pattern, expression)

Return True if pattern matches expression.

type

commute_left

commute_right

convert_extended_projection_2_projection

convert_extended_projection_2_rename

convert_rename_column

eliminate_trivial_nested_projection

eliminate_trivial_nested_unnamed_projection

eliminate_trivial_number_columns

eliminate_trivial_projection

eliminate_trivial_projection_number_columns

eliminate_trivial_selection_number_columns

get_arity

invert_selection_order

merge_nested_rename_columns

merge_rename_column_group_by

merge_rename_columns_extended_projection

merge_selections

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

process_expression

process_iterable_argument

push_and_rename_in_naturaljoin

push_rename_past_groupby

push_rename_past_projection

push_rename_past_selection

push_selection_above_name_columns

push_selection_above_projection

push_selection_in_extended_projection

push_selection_in_groupby

push_selection_in_left

push_selection_in_leftnaturaljoin_left

push_selection_in_leftnaturaljoin_right

push_selection_in_outernaturaljoin_left

push_selection_in_outernaturaljoin_right

push_selection_in_projection

push_selection_in_replace_null

push_selection_in_right

remove_trivial_rename

selection_between_columns_product

selection_by_constant_on_product

selection_on_equijoin

selection_on_equijoin_columns

selection_push_right

selection_selection_swap

selection_shorten_right

simplify_projection_extended_projection

simplify_renames_name

single_product

sort_formula_args

split_relations_column

split_rename_left_naturaljoin

split_rename_naturaljoin

split_rename_outer_naturaljoin

standardize_projected_column

swap_formula_args

switch_rename_replace_null

walk

type = typing.Any
class neurolang.relational_algebra.optimisers.RenameOptimizations(*args, **kwargs)

Bases: PatternWalker

Attributes:
patterns

Property holding an iterator of triplets (pattern, guard, action).

Methods

match(expression)

Find the action for a given expression by going through the patterns.

pattern_match(pattern, expression)

Return True if pattern matches expression.

type

convert_rename_column

eliminate_trivial_number_columns

eliminate_trivial_projection_number_columns

eliminate_trivial_selection_number_columns

merge_nested_rename_columns

merge_rename_column_group_by

merge_rename_columns_extended_projection

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

push_rename_past_groupby

push_rename_past_projection

push_rename_past_selection

remove_trivial_rename

simplify_renames_name

split_rename_left_naturaljoin

split_rename_naturaljoin

split_rename_outer_naturaljoin

switch_rename_replace_null

walk

convert_rename_column(expression)
eliminate_trivial_number_columns(expression)
eliminate_trivial_projection_number_columns(expression)
eliminate_trivial_selection_number_columns(expression)
merge_nested_rename_columns(expression)
merge_rename_column_group_by(expression)
merge_rename_columns_extended_projection(expression)
push_rename_past_groupby(expression)
push_rename_past_projection(expression)
push_rename_past_selection(expression)
remove_trivial_rename(expression)
simplify_renames_name(expression)
split_rename_left_naturaljoin(expression)
split_rename_naturaljoin(expression)
split_rename_outer_naturaljoin(expression)
switch_rename_replace_null(expression)
type = typing.Any
class neurolang.relational_algebra.optimisers.RewriteSelections(*args, **kwargs)

Bases: ExpressionWalker

Mixing that optimises through relational algebra expressions.

The pushing selections (Selection) down and compositions and reduces the reach of selections. Then it converts equi-selection/product compositions into equijoins.

Attributes:
patterns

Property holding an iterator of triplets (pattern, guard, action).

Methods

match(expression)

Find the action for a given expression by going through the patterns.

pattern_match(pattern, expression)

Return True if pattern matches expression.

type

get_arity

merge_selections

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

process_expression

process_iterable_argument

selection_between_columns_product

selection_by_constant_on_product

selection_on_equijoin

selection_on_equijoin_columns

selection_push_right

selection_selection_swap

selection_shorten_right

sort_formula_args

split_relations_column

swap_formula_args

walk

static get_arity(expression)
merge_selections(expression)
selection_between_columns_product(selection)
selection_by_constant_on_product(selection)
selection_on_equijoin(selection)
selection_on_equijoin_columns(selection)
selection_push_right(selection)
selection_selection_swap(selection)
selection_shorten_right(selection)
sort_formula_args(selection)
static split_relations_column(relations, column)
swap_formula_args(selection)
type = typing.Any
class neurolang.relational_algebra.optimisers.SimplifyExtendedProjectionsWithConstants(*args, **kwargs)

Bases: PatternWalker

Attributes:
patterns

Property holding an iterator of triplets (pattern, guard, action).

Methods

match(expression)

Find the action for a given expression by going through the patterns.

pattern_match(pattern, expression)

Return True if pattern matches expression.

type

nested_extended_projection_constant

nested_extended_projection_leftnaturaljoin_constant

nested_extended_projection_leftnaturaljoin_constantr

nested_extended_projection_naturaljoin_constant_l

nested_extended_projection_naturaljoin_constantr

nested_extended_projection_outernaturaljoin_constant

nested_extended_projection_outernaturaljoin_constantr

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

push_computed_columns_up

push_computed_columns_up_flip

push_computed_columns_up_left

push_computed_columns_up_outer

push_replace_null_in_ext_proj

replace_trivial_agg_groupby

walk

nested_extended_projection_constant(expression)
nested_extended_projection_leftnaturaljoin_constant(expression)
nested_extended_projection_leftnaturaljoin_constantr(expression)
nested_extended_projection_naturaljoin_constant_l(expression)
nested_extended_projection_naturaljoin_constantr(expression)
nested_extended_projection_outernaturaljoin_constant(expression)
nested_extended_projection_outernaturaljoin_constantr(expression)
push_computed_columns_up(expression, flip=False)
push_computed_columns_up_flip(expression)
push_computed_columns_up_left(expression)
push_computed_columns_up_outer(expression)
push_replace_null_in_ext_proj(expression)
replace_trivial_agg_groupby(expression)
type = typing.Any