-
Bug
-
Resolution: Done
-
Major
-
7.51.0.Final
-
None
-
2021 Week 10-12 (from Mar 8)
-
3
-
Undefined
-
NEW
-
NEW
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; }