use of org.drools.core.common.TripleNonIndexSkipBetaConstraints in project drools by kiegroup.
the class IndexingTest method testIndexingOnQueryUnification.
@Test(timeout = 10000)
public void testIndexingOnQueryUnification() throws Exception {
String str = "";
str += "package org.drools.compiler.test \n";
str += "import org.drools.compiler.Person \n";
str += "query peeps( String $name, String $likes, String $street) \n";
str += " $p : Person( $name := name, $likes := likes, $street := address.street ) \n";
str += "end\n";
KieBase kbase = loadKnowledgeBaseFromString(str);
List<ObjectTypeNode> nodes = ((KnowledgeBaseImpl) kbase).getRete().getObjectTypeNodes();
ObjectTypeNode node = null;
for (ObjectTypeNode n : nodes) {
if (((ClassObjectType) n.getObjectType()).getClassType() == DroolsQuery.class) {
node = n;
break;
}
}
InternalWorkingMemory wm = ((StatefulKnowledgeSessionImpl) kbase.newKieSession());
AlphaNode alphanode = (AlphaNode) node.getObjectSinkPropagator().getSinks()[0];
LeftInputAdapterNode liaNode = (LeftInputAdapterNode) alphanode.getObjectSinkPropagator().getSinks()[0];
// $p2
JoinNode j = (JoinNode) liaNode.getSinkPropagator().getSinks()[0];
TripleNonIndexSkipBetaConstraints c = (TripleNonIndexSkipBetaConstraints) j.getRawConstraints();
// assertEquals( "$name", ((VariableConstraint)c.getConstraint()).getRequiredDeclarations()[0].getIdentifier() );
assertTrue(c.isIndexed());
BetaMemory bm = (BetaMemory) wm.getNodeMemory(j);
assertTrue(bm.getLeftTupleMemory() instanceof TupleIndexHashTable);
assertTrue(bm.getRightTupleMemory() instanceof TupleIndexHashTable);
}
Aggregations