Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-6092

Missing BetaIndex with this in exec-model

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 7.52.0.Final
    • 7.51.0.Final
    • executable model
    • None
    • 2021 Week 10-12 (from Mar 8)
    • 3
    • Undefined
    • NEW
    • NEW

    Description

      Add this test to IndexingTest and fix

          @Test(timeout = 10000)
          public void testBuildsIndexedMemory() {
              // tests indexes are correctly built
              final String drl =
                    "package org.drools.compiler.test\n" +
                    "import " + Person.class.getCanonicalName() + "\n" +
                    "global java.util.List list\n" +
                    "rule test1\n" +
                    "when\n" +
                    "   $p1  : Person()\n" +
                    "   $p2 : String(this == $p1.name)\n" + //indexed
                    "then\n" +
                    "end\n";
      
              InternalWorkingMemory wm = (InternalWorkingMemory) getKieSession( drl );
              try {
                  final ObjectTypeNode node = KieUtil.getObjectTypeNode(wm.getKnowledgeBase(), Person.class);
                  assertNotNull(node);
                  final LeftInputAdapterNode liaNode = (LeftInputAdapterNode) node.getObjectSinkPropagator().getSinks()[0];
                  final JoinNode             j2      = (JoinNode) liaNode.getSinkPropagator().getSinks()[0];
      
                  SingleBetaConstraints c = (SingleBetaConstraints) j2.getRawConstraints();
                  assertTrue(c.isIndexed());
                  BetaMemory bm = (BetaMemory) wm.getNodeMemory(j2);
                  assertTrue(bm.getLeftTupleMemory() instanceof TupleIndexHashTable);
                  assertTrue(bm.getRightTupleMemory() instanceof TupleIndexHashTable);
              } finally {
                  wm.dispose();
              }
          }
          public static ObjectTypeNode getObjectTypeNode(final KieBase kbase, final Class<?> nodeClass) {
              final List<ObjectTypeNode> nodes = ((KnowledgeBaseImpl) kbase).getRete().getObjectTypeNodes();
              for (final ObjectTypeNode n : nodes) {
                  if (((ClassObjectType) n.getObjectType()).getClassType() == nodeClass) {
                      return n;
                  }
              }
              return null;
          }
      

      Attachments

        Activity

          People

            rhn-support-tkobayas Toshiya Kobayashi
            rhn-support-tkobayas Toshiya Kobayashi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: