Skip to content

range index is not enabled when && is used with executable-model #6228

Open
@tkobayas

Description

@tkobayas

When a constraint is like age >= 0 && age < 20, executable-model doesn't split the constraint into two constraints, so it doesn't enable range index. It only affects the performance (it's enabled when more than 9 alpha nodes for the same field by default), not the rule behaviour.

age >= 0, age < 20 doesn't have this issue.

AlphaNodeRangeIndexingTest

    public void testSurroundingRange(KieBaseTestConfiguration kieBaseTestConfiguration) {
        final String drl =
                "package org.drools.compiler.test\n" +
                           "import " + Person.class.getCanonicalName() + "\n" +
                           "rule test1\n when\n" +
                           "   Person( age >= 0 && age < 20 )\n" +
                           "then\n end\n" +
                           "rule test2\n when\n" +
                           "   Person( age >= 20 && age < 40 )\n" +
                           "then\n end\n" +
                           "rule test3\n when\n" +
                           "   Person( age >= 40 && age < 60 )\n" +
                           "then\n end\n";

        final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3);
        final KieSession ksession = kbase.newKieSession();

        assertSinks(kieBaseTestConfiguration, kbase, Person.class, 3, 3, 0, 3);

        ksession.insert(new Person("John", 18));
        int fired = ksession.fireAllRules();
        assertThat(fired).isEqualTo(1);

        ksession.insert(new Person("Paul", 60));
        fired = ksession.fireAllRules();
        assertThat(fired).isEqualTo(0);
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions