Esempio n. 1
0
 @SuppressWarnings("unchecked")
 private QueryElementFactHandle createQueryResultHandle(
     PropagationContext context, InternalWorkingMemory workingMemory, Object[] objects) {
   QueryElementFactHandle handle = null;
   ProtobufMessages.FactHandle _handle = null;
   if (context.getReaderContext() != null) {
     Map<TupleKey, QueryElementContext> map =
         (Map<TupleKey, QueryElementContext>)
             context.getReaderContext().nodeMemories.get(node.getId());
     if (map != null) {
       QueryElementContext _context = map.get(PersisterHelper.createTupleKey(leftTuple));
       if (_context != null) {
         _handle = _context.results.removeFirst();
       }
     }
   }
   if (_handle != null) {
     // create a handle with the given id
     handle = new QueryElementFactHandle(objects, _handle.getId(), _handle.getRecency());
   } else {
     handle =
         new QueryElementFactHandle(
             objects,
             workingMemory.getFactHandleFactory().getAtomicId().incrementAndGet(),
             workingMemory.getFactHandleFactory().getAtomicRecency().incrementAndGet());
   }
   return handle;
 }