o
    bi	                     @   s  d dl mZ ddlmZ d dlmZmZmZmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ eeegZeeeeee
gZedefddZedefddZG dd deZG dd deZdedefddZdS )    )List   )Ruleset)LogicalPlan	OptimizerPhysicalPlanRule)%ConfigureMapTaskMemoryUsingOutputSize)InheritBatchFormatRule)InheritTargetMaxBlockSizeRule)FuseOperators)ReorderRandomizeBlocksRule)SetReadParallelismRule)EliminateBuildOutputBlocks)DeveloperAPIreturnc                   C      t S N)_LOGICAL_RULESET r   r   Y/home/ubuntu/.local/lib/python3.10/site-packages/ray/data/_internal/logical/optimizers.pyget_logical_ruleset,      r   c                   C   r   r   )_PHYSICAL_RULESETr   r   r   r   get_physical_ruleset1   r   r   c                   @   &   e Zd ZdZedee fddZdS )LogicalOptimizerz$The optimizer for logical operators.r   c                 C      dd t  D S )Nc                 S      g | ]}| qS r   r   .0rule_clsr   r   r   
<listcomp>;       z*LogicalOptimizer.rules.<locals>.<listcomp>)r   selfr   r   r   rules9      zLogicalOptimizer.rulesN__name__
__module____qualname____doc__propertyr   r   r&   r   r   r   r   r   6       r   c                   @   r   )PhysicalOptimizerz%The optimizer for physical operators.r   c                 C   r   )Nc                 S   r   r   r   r   r   r   r   r"   C   r#   z+PhysicalOptimizer.rules.<locals>.<listcomp>)r   r$   r   r   r   r&   A   r'   zPhysicalOptimizer.rulesNr(   r   r   r   r   r/   >   r.   r/   logical_planc                 C   s8   ddl m} t | }|j| _| |}t |S )a  Get the physical execution plan for the provided logical plan.

    This process has 3 steps:
    (1) logical optimization: optimize logical operators.
    (2) planning: convert logical to physical operators.
    (3) physical optimization: optimize physical operators.
    r   )create_planner)ray.data._internal.plannerr1   r   optimizedag_dagplanr/   )r0   r1   optimized_logical_planphysical_planr   r   r   get_execution_planF   s
   r9   N) typingr   rulesetr   %ray.data._internal.logical.interfacesr   r   r   r   :ray.data._internal.logical.rules.configure_map_task_memoryr	   5ray.data._internal.logical.rules.inherit_batch_formatr
   >ray.data._internal.logical.rules.inherit_target_max_block_sizer   0ray.data._internal.logical.rules.operator_fusionr   1ray.data._internal.logical.rules.randomize_blocksr   5ray.data._internal.logical.rules.set_read_parallelismr   5ray.data._internal.logical.rules.zero_copy_map_fusionr   ray.util.annotationsr   r   r   r   r   r   r/   r9   r   r   r   r   <module>   s>    