pub fn plan(
        join: &MirRelationExpr,
        input_mapper: &JoinInputMapper,
        available: &[Vec<Vec<MirScalarExpr>>],
        unique_keys: &[Vec<Vec<usize>>],
    ) -> Option<MirRelationExpr> {
        let mut new_join = join.clone();

        if let MirRelationExpr::Join {
            inputs,
            equivalences,
            implementation,
        } = &mut new_join
        {
            if inputs.len() < 2 {
                // Single input joins are filters and should be planned as
                // differential plans instead of delta queries. Because a
                // a filter gets converted into a single input join only when
                // there are existing arrangements, without this early return,
                // filters will always be planned as delta queries.
                return None;
            }

            // Determine a viable order for each relation, or return `None` if none found.
            let orders = super::optimize_orders(equivalences, available, unique_keys, input_mapper);

            // A viable delta query requires that, for every order,
            // there is an arrangement for every input except for
            // the starting one.
            if !orders
                .iter()
                .all(|o| o.iter().skip(1).all(|(c, _, _)| c.arranged))
            {
                return None;
            }

            // Convert the order information into specific (input, keys) information.
            let orders = orders
                .into_iter()
                .map(|o| {
                    o.into_iter()
                        .skip(1)
                        .map(|(_c, k, r)| (r, k))
                        .collect::<Vec<_>>()
                })
                .collect::<Vec<_>>();

            // Implement arrangements in each of the inputs.
            let lifted_mfp =
                super::implement_arrangements(inputs, available, orders.iter().flatten());

            *implementation = JoinImplementation::DeltaQuery(orders);

            super::install_lifted_mfp(&mut new_join, lifted_mfp);

            // Hooray done!
            Some(new_join)
        } else {
            panic!("delta_queries::plan call on non-join expression.")
        }
    }
/// Creates a delta query plan, and any predicates that need to be lifted.
///
/// The method returns `None` if it fails to find a sufficiently pleasing plan.
Creates a delta query plan, and any predicates that need to be lifted.
The method returns `None` if it fails to find a sufficiently pleasing plan.
Creates a delta query plan and any predicates that need to be lifted . The method returns ` None ` if it fails to find a sufficiently pleasing plan .
pub fn plan(
        join: &MirRelationExpr,
        input_mapper: &JoinInputMapper,
        available: &[Vec<Vec<MirScalarExpr>>],
        unique_keys: &[Vec<Vec<usize>>],
    ) -> Option<MirRelationExpr> {
        let mut new_join = join.clone();
        if let MirRelationExpr::Join {
            inputs,
            equivalences,
            implementation,
        } = &mut new_join
        {
            if inputs.len() < 2 {
                // Single input joins are filters and should be planned as
                // differential plans instead of delta queries. Because a
                // a filter gets converted into a single input join only when
                // there are existing arrangements, without this early return,
                // filters will always be planned as delta queries.
                return None;
            }
            // Determine a viable order for each relation, or return `None` if none found.
            let orders = super::optimize_orders(equivalences, available, unique_keys, input_mapper);
            // A viable delta query requires that, for every order,
            // there is an arrangement for every input except for
            // the starting one.
            if !orders
                .iter()
                .all(|o| o.iter().skip(1).all(|(c, _, _)| c.arranged))
            {
                return None;
            }
            // Convert the order information into specific (input, keys) information.
            let orders = orders
                .into_iter()
                .map(|o| {
                    o.into_iter()
                        .skip(1)
                        .map(|(_c, k, r)| (r, k))
                        .collect::<Vec<_>>()
                })
                .collect::<Vec<_>>();
            // Implement arrangements in each of the inputs.
            let lifted_mfp =
                super::implement_arrangements(inputs, available, orders.iter().flatten());
            *implementation = JoinImplementation::DeltaQuery(orders);
            super::install_lifted_mfp(&mut new_join, lifted_mfp);
            // Hooray done!
            Some(new_join)
        } else {
            panic!("delta_queries::plan call on non-join expression.")
        }
    }
pub fn plan ( join : & MirRelationExpr , input_mapper : & JoinInputMapper , available : & [ Vec < Vec < MirScalarExpr > > ] , unique_keys : & [ Vec < Vec < usize > > ] , ) -> Option < MirRelationExpr > { let mut new_join = join . clone ( ) ; if let MirRelationExpr :: Join { inputs , equivalences , implementation , } = & mut new_join { if inputs . len ( ) < 2 { // Single input joins are filters and should be planned as // differential plans instead of delta queries. Because a // a filter gets converted into a single input join only when // there are existing arrangements, without this early return, // filters will always be planned as delta queries. return None ; } // Determine a viable order for each relation, or return `None` if none found. let orders = super :: optimize_orders ( equivalences , available , unique_keys , input_mapper ) ; // A viable delta query requires that, for every order, // there is an arrangement for every input except for // the starting one. if ! orders . iter ( ) . all ( | o | o . iter ( ) . skip ( 1 ) . all ( | ( c , _ , _ ) | c . arranged ) ) { return None ; } // Convert the order information into specific (input, keys) information. let orders = orders . into_iter ( ) . map ( | o | { o . into_iter ( ) . skip ( 1 ) . map ( | ( _c , k , r ) | ( r , k ) ) . collect :: < Vec < _ > > ( ) } ) . collect :: < Vec < _ > > ( ) ; // Implement arrangements in each of the inputs. let lifted_mfp = super :: implement_arrangements ( inputs , available , orders . iter ( ) . flatten ( ) ) ; * implementation = JoinImplementation :: DeltaQuery ( orders ) ; super :: install_lifted_mfp ( & mut new_join , lifted_mfp ) ; // Hooray done! Some ( new_join ) } else { panic ! ( " " ) } }
Creates a delta query plan, and any predicates that need to be lifted.
Creates a delta query plan and any predicates that need to be lifted .
join
&MirRelationExpr
input_mapper
&JoinInputMapper
available
&[Vec<Vec<MirScalarExpr>>]
unique_keys
&[Vec<Vec<usize>>]
join
&MirRelationExpr
input_mapper
&JoinInputMapper
available
&[Vec<Vec<MirScalarExpr>>]
unique_keys
&[Vec<Vec<usize>>]