Uploaded image for project: 'Red Hat Decision Manager'
  1. Red Hat Decision Manager
  2. RHDM-1636

Complex constraints containing BigDecimal '%' operation cannot be jitted.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Done
    • 7.10.0.GA
    • None
    • BRE
    • This issue was reported on RHDM 7.9.0.
      It is also reproducible on 7.10.0.

    • Hide

      Two reproducers are attached. reproducer_jitting_2a.zip is a reproducer similar to real-world example, and reproducer_jitting_2b.zip is a further simplified one of it.

      reproducer_jitting_2a.zip

      1. Extract reproducer.
        $ unzip reproducer_jitting_2a.zip
        $ cd reproducer_jitting_2a
        
      1. Build and execute the rule.
        $ ./run_mvn
            :
            :
        ***** start
        ***** rule_jitting_2a_2: TargetDate{date = 19500131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19510131, leapYear = false}
        ***** rule_jitting_2a_1: TargetDate{date = 19520131, leapYear = true}
        ***** rule_jitting_2a_2: TargetDate{date = 19530131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19540131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19550131, leapYear = false}
        ***** rule_jitting_2a_1: TargetDate{date = 19560131, leapYear = true}
        ***** rule_jitting_2a_2: TargetDate{date = 19570131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19580131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19590131, leapYear = false}
        ***** rule_jitting_2a_1: TargetDate{date = 19600131, leapYear = true}
        ***** rule_jitting_2a_2: TargetDate{date = 19610131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19620131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19630131, leapYear = false}
        ***** rule_jitting_2a_1: TargetDate{date = 19640131, leapYear = true}
        ***** rule_jitting_2a_2: TargetDate{date = 19650131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19660131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19670131, leapYear = false}
        ***** rule_jitting_2a_1: TargetDate{date = 19680131, leapYear = true}
        ***** rule_jitting_2a_2: TargetDate{date = 19690131, leapYear = false}
        15:11:23.349 [drools-worker-2] WARN  org.drools.mvel.MVELConstraint - Exception jitting: ($year % 400) == 0 || (($year % 4) == 0 && ($year % 100) != 0) This is NOT an error and NOT prevent the correct execution since the constraint will be evaluated in intrepreted mode    // ..... (*3-1)
        15:11:23.349 [drools-worker-3] WARN  org.drools.mvel.MVELConstraint - Exception jitting: ($year % 4) != 0 || (($year % 400) != 0 && ($year % 100) == 0) This is NOT an error and NOT prevent the correct execution since the constraint will be evaluated in intrepreted mode    // ..... (*3-2)
        ***** rule_jitting_2a_2: TargetDate{date = 19700131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19710131, leapYear = false}
        ***** rule_jitting_2a_1: TargetDate{date = 19720131, leapYear = true}
        ***** rule_jitting_2a_2: TargetDate{date = 19730131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19740131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19750131, leapYear = false}
        ***** rule_jitting_2a_1: TargetDate{date = 19760131, leapYear = true}
        ***** rule_jitting_2a_2: TargetDate{date = 19770131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19780131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 19790131, leapYear = false}
        ***** rule_jitting_2a_1: TargetDate{date = 19800131, leapYear = true}
            :
            :
        ***** rule_jitting_2a_1: TargetDate{date = 20160131, leapYear = true}
        ***** rule_jitting_2a_2: TargetDate{date = 20170131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 20180131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 20190131, leapYear = false}
        ***** rule_jitting_2a_1: TargetDate{date = 20200131, leapYear = true}
        ***** rule_jitting_2a_2: TargetDate{date = 20210131, leapYear = false}
        ***** rule_jitting_2a_2: TargetDate{date = 20220131, leapYear = false}
        ***** end
            :
            :
        

        This is a sample reproducer which determines whether the date is in a leap year. You can see that jitting failed by warning messages (*3-1) and (*3-2).

      reproducer_jitting_2b.zip

      1. Extract reproducer.
        $ unzip reproducer_jitting_2b.zip
        $ cd reproducer_jitting_2b
        
      1. Build and execute the rule.
        $ ./run_mvn
            :
            :
        ***** start
        15:21:02.416 [main] WARN  org.drools.mvel.MVELConstraint - Exception jitting: (value % 400) == 0 || ((value % 4) == 0 && (value % 100) != 0) This is NOT an error and NOT prevent the correct execution since the constraint will be evaluated in intrepreted mode    // ..... (*4-1)
        15:21:02.427 [main] WARN  org.drools.mvel.MVELConstraint - Exception jitting: (value % 4) != 0 || ((value % 400) != 0 && (value % 100) == 0) This is NOT an error and NOT prevent the correct execution since the constraint will be evaluated in intrepreted mode    // ..... (*4-2)
        ***** rule_jitting_2b_1: leap year, value = 2020
        ***** end
            :
            :
        

        In this reproducer, -Ddrools.jittingThreshold=0 is specified in pom.xml.
        You can see that jitting failed by warning messages (*4-1) and (*4-2).

      Show
      Two reproducers are attached. reproducer_jitting_2a.zip is a reproducer similar to real-world example, and reproducer_jitting_2b.zip is a further simplified one of it. reproducer_jitting_2a.zip Extract reproducer. $ unzip reproducer_jitting_2a.zip $ cd reproducer_jitting_2a Build and execute the rule. $ ./run_mvn : : ***** start ***** rule_jitting_2a_2: TargetDate{date = 19500131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19510131, leapYear = false} ***** rule_jitting_2a_1: TargetDate{date = 19520131, leapYear = true} ***** rule_jitting_2a_2: TargetDate{date = 19530131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19540131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19550131, leapYear = false} ***** rule_jitting_2a_1: TargetDate{date = 19560131, leapYear = true} ***** rule_jitting_2a_2: TargetDate{date = 19570131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19580131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19590131, leapYear = false} ***** rule_jitting_2a_1: TargetDate{date = 19600131, leapYear = true} ***** rule_jitting_2a_2: TargetDate{date = 19610131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19620131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19630131, leapYear = false} ***** rule_jitting_2a_1: TargetDate{date = 19640131, leapYear = true} ***** rule_jitting_2a_2: TargetDate{date = 19650131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19660131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19670131, leapYear = false} ***** rule_jitting_2a_1: TargetDate{date = 19680131, leapYear = true} ***** rule_jitting_2a_2: TargetDate{date = 19690131, leapYear = false} 15:11:23.349 [drools-worker-2] WARN org.drools.mvel.MVELConstraint - Exception jitting: ($year % 400) == 0 || (($year % 4) == 0 && ($year % 100) != 0) This is NOT an error and NOT prevent the correct execution since the constraint will be evaluated in intrepreted mode // ..... (*3-1) 15:11:23.349 [drools-worker-3] WARN org.drools.mvel.MVELConstraint - Exception jitting: ($year % 4) != 0 || (($year % 400) != 0 && ($year % 100) == 0) This is NOT an error and NOT prevent the correct execution since the constraint will be evaluated in intrepreted mode // ..... (*3-2) ***** rule_jitting_2a_2: TargetDate{date = 19700131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19710131, leapYear = false} ***** rule_jitting_2a_1: TargetDate{date = 19720131, leapYear = true} ***** rule_jitting_2a_2: TargetDate{date = 19730131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19740131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19750131, leapYear = false} ***** rule_jitting_2a_1: TargetDate{date = 19760131, leapYear = true} ***** rule_jitting_2a_2: TargetDate{date = 19770131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19780131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 19790131, leapYear = false} ***** rule_jitting_2a_1: TargetDate{date = 19800131, leapYear = true} : : ***** rule_jitting_2a_1: TargetDate{date = 20160131, leapYear = true} ***** rule_jitting_2a_2: TargetDate{date = 20170131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 20180131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 20190131, leapYear = false} ***** rule_jitting_2a_1: TargetDate{date = 20200131, leapYear = true} ***** rule_jitting_2a_2: TargetDate{date = 20210131, leapYear = false} ***** rule_jitting_2a_2: TargetDate{date = 20220131, leapYear = false} ***** end : : This is a sample reproducer which determines whether the date is in a leap year. You can see that jitting failed by warning messages (*3-1) and (*3-2). reproducer_jitting_2b.zip Extract reproducer. $ unzip reproducer_jitting_2b.zip $ cd reproducer_jitting_2b Build and execute the rule. $ ./run_mvn : : ***** start 15:21:02.416 [main] WARN org.drools.mvel.MVELConstraint - Exception jitting: (value % 400) == 0 || ((value % 4) == 0 && (value % 100) != 0) This is NOT an error and NOT prevent the correct execution since the constraint will be evaluated in intrepreted mode // ..... (*4-1) 15:21:02.427 [main] WARN org.drools.mvel.MVELConstraint - Exception jitting: (value % 4) != 0 || ((value % 400) != 0 && (value % 100) == 0) This is NOT an error and NOT prevent the correct execution since the constraint will be evaluated in intrepreted mode // ..... (*4-2) ***** rule_jitting_2b_1: leap year, value = 2020 ***** end : : In this reproducer, -Ddrools.jittingThreshold=0 is specified in pom.xml . You can see that jitting failed by warning messages (*4-1) and (*4-2).
    • 2021 Week 10-12 (from Mar 8)
    • +

    Description

      Complex constraints containing remainder (%) operation for BigDecimal value like below cannot be jitted. Where value is a BigDecimal-type property.

      • (value % 400) == 0 || ((value % 4) == 0 && (value % 100) != 0) ..... (*1-1)
      • (value % 4) != 0 || ((value % 400) != 0 && (value % 100) == 0) ..... (*1-2)

      The warning messages when jitting fails are (*2). Constraints replaced '%' operators all with '+', '-', '*' or '/' are successfully jitted.

      (*1)

      package com.example.reproducer
      
      rule "rule_jitting_2b_1"
          when
              $fact : Fact( (value % 400) == 0 || ((value % 4) == 0 && (value % 100) != 0) )    // ..... (*1-1)
          then
              System.out.println("***** rule_jitting_2b_1: leap year, value = " + $fact.getValue());
      end
      
      rule "rule_jitting_2b_2"
          when
              $fact : Fact( (value % 4) != 0 || ((value % 400) != 0 && (value % 100) == 0) )    // ..... (*1-2)
          then
              System.out.println("***** rule_jitting_2b_2: common year, value = " + $fact.getValue());
      end
      
      // Fact#value is a BigDecimal property.
      

      (*2)

      15:21:02.416 [main] WARN  org.drools.mvel.MVELConstraint - Exception jitting: (value % 400) == 0 || ((value % 4) == 0 && (value % 100) != 0) This is NOT an error and NOT prevent the correct execution since the constraint will be evaluated in intrepreted mode    // ..... (\*2-1)
      15:21:02.427 [main] WARN  org.drools.mvel.MVELConstraint - Exception jitting: (value % 4) != 0 || ((value % 400) != 0 && (value % 100) == 0) This is NOT an error and NOT prevent the correct execution since the constraint will be evaluated in intrepreted mode    // ..... (\*2-2)
      

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            rhn-support-myoshida Masato Yoshida
            Daniel Rosa Daniel Rosa
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: