/// Merge the given delete predicates into this select predicate.
/// Since we want to eliminate data filtered by the delete predicates,
/// they are first converted into their negated form: NOT(delete_predicate)
/// then added/merged into the selection one
Merge the given delete predicates into this select predicate.
Since we want to eliminate data filtered by the delete predicates,
they are first converted into their negated form: NOT(delete_predicate)
then added/merged into the selection one
Merge the given delete predicates into this select predicate . Since we want to eliminate data filtered by the delete predicates they are first converted into their negated form : NOT ( delete_predicate ) then added / merged into the selection one
pub fn merge_delete_predicates<S>(&mut self, delete_predicates: &[S])
    where
        S: AsRef<Self>,
    {
        // Create a list of disjunctive negated expressions.
        // Example: there are two deletes as follows (note that time_range is stored separated in the Predicate
        //  but we need to put it together with the exprs here)
        //   . Delete_1: WHERE city != "Boston"  AND temp = 70  AND time_range in [10, 30)
        //   . Delete 2: WHERE state = "NY" AND route != "I90" AND time_range in [20, 50)
        // The negated list will be "NOT(Delete_1)", NOT(Delete_2)" which means
        //    NOT(city != "Boston"  AND temp = 70 AND time_range in [10, 30]),  NOT(state = "NY" AND route != "I90" AND time_range in [20, 50]) which means
        //   [NOT(city = Boston") OR NOT(temp = 70) OR NOT(time_range in [10, 30])], [NOT(state = "NY") OR NOT(route != "I90") OR NOT(time_range in [20, 50])]
        // Note that the "NOT(time_range in [20, 50])]" or "NOT(20 <= time <= 50)"" is replaced with "time < 20 OR time > 50"
        for pred in delete_predicates {
            let pred = pred.as_ref();
            let mut expr: Option<Expr> = None;
            // Time range
            if let Some(range) = pred.range {
                // time_expr =  NOT(start <= time_range <= end)
                // Equivalent to: (time < start OR time > end)
                let time_expr = col(TIME_COLUMN_NAME)
                    .lt(lit_timestamp_nano(range.start()))
                    .or(col(TIME_COLUMN_NAME).gt(lit_timestamp_nano(range.end())));
                match expr {
                    None => expr = Some(time_expr),
                    Some(e) => expr = Some(e.or(time_expr)),
                }
            }
            // Exprs
            for exp in &pred.exprs {
                match expr {
                    None => expr = Some(exp.clone().not()),
                    Some(e) => expr = Some(e.or(exp.clone().not())),
                }
            }
            // Push the negated expression of the delete predicate into the list exprs of the select predicate
            if let Some(e) = expr {
                self.exprs.push(e);
            }
        }
    }
pub fn merge_delete_predicates < S > ( & mut self , delete_predicates : & [ S ] ) where S : AsRef < Self > , { // Create a list of disjunctive negated expressions. // Example: there are two deletes as follows (note that time_range is stored separated in the Predicate //  but we need to put it together with the exprs here) //   . Delete_1: WHERE city != "Boston"  AND temp = 70  AND time_range in [10, 30) //   . Delete 2: WHERE state = "NY" AND route != "I90" AND time_range in [20, 50) // The negated list will be "NOT(Delete_1)", NOT(Delete_2)" which means //    NOT(city != "Boston"  AND temp = 70 AND time_range in [10, 30]),  NOT(state = "NY" AND route != "I90" AND time_range in [20, 50]) which means //   [NOT(city = Boston") OR NOT(temp = 70) OR NOT(time_range in [10, 30])], [NOT(state = "NY") OR NOT(route != "I90") OR NOT(time_range in [20, 50])] // Note that the "NOT(time_range in [20, 50])]" or "NOT(20 <= time <= 50)"" is replaced with "time < 20 OR time > 50" for pred in delete_predicates { let pred = pred . as_ref ( ) ; let mut expr : Option < Expr > = None ; // Time range if let Some ( range ) = pred . range { // time_expr =  NOT(start <= time_range <= end) // Equivalent to: (time < start OR time > end) let time_expr = col ( TIME_COLUMN_NAME ) . lt ( lit_timestamp_nano ( range . start ( ) ) ) . or ( col ( TIME_COLUMN_NAME ) . gt ( lit_timestamp_nano ( range . end ( ) ) ) ) ; match expr { None => expr = Some ( time_expr ) , Some ( e ) => expr = Some ( e . or ( time_expr ) ) , } } // Exprs for exp in & pred . exprs { match expr { None => expr = Some ( exp . clone ( ) . not ( ) ) , Some ( e ) => expr = Some ( e . or ( exp . clone ( ) . not ( ) ) ) , } } // Push the negated expression of the delete predicate into the list exprs of the select predicate if let Some ( e ) = expr { self . exprs . push ( e ) ; } } }
Merge the given delete predicates into this select predicate.
Merge the given delete predicates into this select predicate .
&mut self
delete_predicates
&[S]