Ejemplo n.º 1
0
 @SuppressWarnings("unchecked")
 private InternalFactHandle createFactHandle(
     final PropagationContext context,
     final InternalWorkingMemory workingMemory,
     final LeftTuple leftTuple) {
   InternalFactHandle handle = null;
   ProtobufMessages.FactHandle _handle = null;
   if (context.getReaderContext() != null) {
     Map<TupleKey, QueryElementContext> map =
         (Map<TupleKey, QueryElementContext>) context.getReaderContext().nodeMemories.get(getId());
     if (map != null) {
       _handle = map.get(PersisterHelper.createTupleKey(leftTuple)).handle;
     }
   }
   if (_handle != null) {
     // create a handle with the given id
     handle =
         workingMemory
             .getFactHandleFactory()
             .newFactHandle(
                 _handle.getId(), null, _handle.getRecency(), null, workingMemory, workingMemory);
   } else {
     handle =
         workingMemory
             .getFactHandleFactory()
             .newFactHandle(null, null, workingMemory, workingMemory);
   }
   return handle;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 @SuppressWarnings("unchecked")
 private InternalFactHandle createResultFactHandle(
     final PropagationContext context,
     final InternalWorkingMemory workingMemory,
     final LeftTuple leftTuple,
     final Object result) {
   InternalFactHandle handle = null;
   ProtobufMessages.FactHandle _handle = null;
   if (context.getReaderContext() != null) {
     Map<ProtobufInputMarshaller.TupleKey, ProtobufMessages.FactHandle> map =
         (Map<ProtobufInputMarshaller.TupleKey, ProtobufMessages.FactHandle>)
             context.getReaderContext().nodeMemories.get(getId());
     if (map != null) {
       _handle = map.get(PersisterHelper.createTupleKey(leftTuple));
     }
   }
   if (_handle != null) {
     // create a handle with the given id
     handle =
         workingMemory
             .getFactHandleFactory()
             .newFactHandle(
                 _handle.getId(),
                 result,
                 _handle.getRecency(),
                 workingMemory
                     .getObjectTypeConfigurationRegistry()
                     .getObjectTypeConf(context.getEntryPoint(), result),
                 workingMemory,
                 null); // so far, result is not an event
   } else {
     handle =
         workingMemory
             .getFactHandleFactory()
             .newFactHandle(
                 result,
                 workingMemory
                     .getObjectTypeConfigurationRegistry()
                     .getObjectTypeConf(context.getEntryPoint(), result),
                 workingMemory,
                 null); // so far, result is not an event
   }
   return handle;
 }