Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data] Define optimizer rules with global variables #36920

Merged
merged 2 commits into from
Jun 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions python/ray/data/_internal/logical/optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,32 @@
)
from ray.data._internal.planner.planner import Planner

# TODO(scottjlee): add back LimitPushdownRule once we
# enforce number of input/output rows remains the same
# for Map/MapBatches ops.
LOGICAL_OPTIMIZER_RULES = [
ReorderRandomizeBlocksRule,
]

PHYSICAL_OPTIMIZER_RULES = [
OperatorFusionRule,
]


class LogicalOptimizer(Optimizer):
"""The optimizer for logical operators."""

@property
def rules(self) -> List[Rule]:
# TODO(scottjlee): add back LimitPushdownRule once we
# enforce number of input/output rows remains the same
# for Map/MapBatches ops.
return [ReorderRandomizeBlocksRule()]
return [rule_cls() for rule_cls in LOGICAL_OPTIMIZER_RULES]


class PhysicalOptimizer(Optimizer):
"""The optimizer for physical operators."""

@property
def rules(self) -> List["Rule"]:
return [OperatorFusionRule()]
return [rule_cls() for rule_cls in PHYSICAL_OPTIMIZER_RULES]


def get_execution_plan(logical_plan: LogicalPlan) -> PhysicalPlan:
Expand Down