use of org.drools.core.reteoo.QueryTerminalNode in project drools by kiegroup.
the class QueryTerminalNodeVisitor method doVisit.
@Override
protected void doVisit(NetworkNode node, Stack<NetworkNode> nodeStack, StatefulKnowledgeSessionInfo info) {
QueryTerminalNode rtn = (QueryTerminalNode) node;
RuleImpl rule = rtn.getRule();
// first thing, associate all nodes belonging to this rule
for (NetworkNode snode : nodeStack) {
info.assign(snode, rule);
}
// Query Terminal Nodes no longer have memory
// TODO delete this
// final LinkedList<?> memory = (LinkedList<?>) info.getSession().getNodeMemory( rtn );
// final DefaultNodeInfo ni = (DefaultNodeInfo) info.getNodeInfo( node );
// ni.setMemoryEnabled( true );
// ni.setTupleMemorySize( memory.size() );
}
use of org.drools.core.reteoo.QueryTerminalNode in project drools by kiegroup.
the class StatefulKnowledgeSessionImpl method internalGetQueryResult.
protected QueryResultsImpl internalGetQueryResult(boolean calledFromRHS, String queryName, Object... arguments) {
try {
startOperation();
this.lock.lock();
this.kBase.executeQueuedActions();
// eventually enqueued by events that have been inserted when already expired
if (calledFromRHS) {
flushPropagations();
flushPropagations();
} else {
agenda.executeFlush();
agenda.executeFlush();
}
DroolsQuery queryObject = new DroolsQuery(queryName, arguments, getQueryListenerInstance(), false, null, null, null, null, null);
InternalFactHandle handle = this.handleFactory.newFactHandle(queryObject, null, this, this);
final PropagationContext pCtx = pctxFactory.createPropagationContext(getNextPropagationIdCounter(), PropagationContext.Type.INSERTION, null, null, handle, getEntryPoint());
BaseNode[] tnodes = evalQuery(queryName, queryObject, handle, pCtx, calledFromRHS);
List<Map<String, Declaration>> decls = new ArrayList<Map<String, Declaration>>();
if (tnodes != null) {
for (BaseNode node : tnodes) {
decls.add(((QueryTerminalNode) node).getSubRule().getOuterDeclarations());
}
}
this.handleFactory.destroyFactHandle(handle);
return new QueryResultsImpl((List<QueryRowWithSubruleIndex>) queryObject.getQueryResultCollector().getResults(), decls.toArray(new Map[decls.size()]), this, (queryObject.getQuery() != null) ? queryObject.getQuery().getParameters() : new Declaration[0]);
} finally {
this.lock.unlock();
endOperation();
}
}
use of org.drools.core.reteoo.QueryTerminalNode in project drools by kiegroup.
the class AbstractQueryViewListener method rowAdded.
public void rowAdded(final RuleImpl rule, final LeftTuple tuple, final PropagationContext context, final InternalWorkingMemory workingMemory) {
InternalFactHandle[] handles = new InternalFactHandle[tuple.getIndex() + 1];
LeftTuple entry = tuple;
// Add all the FactHandles
while (entry != null) {
InternalFactHandle handle = entry.getFactHandle();
if (handle != null) {
handles[entry.getIndex()] = getHandle(handle);
}
entry = entry.getParent();
}
QueryTerminalNode node = (QueryTerminalNode) tuple.getTupleSink();
this.results.add(new QueryRowWithSubruleIndex(handles, node.getSubruleIndex()));
}
Aggregations