Package org.drools.reteoo

Examples of org.drools.reteoo.BetaNode


            }         

            trgTuples = new StagedLeftTuples();
           
            if ( NodeTypeEnums.isBetaNode( node ) ) {
                BetaNode betaNode = ( BetaNode )node;
                BetaMemory bm = (BetaMemory) nodeMem;
                if ( betaNode.isRightInputIsRiaNode() ) {
                    StagedLeftTuples peerTuples = new StagedLeftTuples();
                    SegmentPropagator.processPeers( srcTuples, peerTuples, betaNode );
                   
                    // Make sure subnetwork Segment has tuples to process
                    SegmentMemory subSmem = bm.getSubnetworkSegmentMemory();
                    StagedLeftTuples subnetworkStaged =  subSmem.getStagedLeftTuples();
                    subnetworkStaged.addAllDeletes( srcTuples.getDeleteFirst() );
                    subnetworkStaged.addAllUpdates( srcTuples.getUpdateFirst() );
                    subnetworkStaged.addAllInserts( srcTuples.getInsertFirst() );
                  
                    List<RuleMemory> ruleMemories = subSmem.getRuleMemories();
                   
                    RiaRuleMemory rm = null;
                    if ( ruleMemories.size() == 1 ) {
                        rm = ( RiaRuleMemory) ruleMemories.get( 0 ) ;
                    } else {
                        for ( int i = 0, size = ruleMemories.size(); i < size; i++ ) {
                            if ( ruleMemories.get( i ) instanceof RiaRuleMemory ) {
                                rm = ( RiaRuleMemory) ruleMemories.get( i ) ;
                            }
                        }
                    }
                   
                    RightInputAdapterNode riaNode = ( RightInputAdapterNode ) betaNode.getRightInput();
                    // At this point we have the tuples to apply to the left and to the right of the subnetwork root node
                    StagedLeftTuples riaStagedTuples = eval( subSmem.getRootNode(), subSmem.getNodeMemories().getFirst(), rm.getSegmentMemories(), 0, srcTuples, null, wm );
                    StagedRightTuples riaStageRight = bm.getStagedRightTuples();
                    for ( LeftTuple leftTuple = riaStagedTuples.getInsertFirst(); leftTuple != null; leftTuple = leftTuple.getStagedNext() ) {
                        InternalFactHandle handle = riaNode.createFactHandle( leftTuple, leftTuple.getPropagationContext(), wm );
                        RightTuple rightTuple = betaNode.createRightTuple( handle, betaNode, leftTuple.getPropagationContext() );
                        //riaStagedTuples.
                    }
                   
                }
               
View Full Code Here


      long allLinkedTestMask = 0;
     
      while ( true ) {
            if ( NodeTypeEnums.isBetaNode( tupleSource ) ) {
                BetaMemory betaMemory;
                BetaNode betaNode = ( BetaNode ) tupleSource;
                if ( NodeTypeEnums.AccumulateNode == tupleSource.getType() ) {      
                    betaMemory = (( AccumulateMemory ) smem.createNodeMemory( ( AccumulateNode ) tupleSource, wm  )).getBetaMemory();
                } else {                   
                    betaMemory = ( BetaMemory ) smem.createNodeMemory( betaNode, wm );
   
                }
   
                if ( betaNode.isRightInputIsRiaNode() ) {
                    // we need to iterate to find correct pair
                    // as there may be more than one set of sub networks, due to sharing.
                    LeftTupleSinkNode sinkNode = betaNode.getLeftTupleSource().getSinkPropagator().getFirstLeftTupleSink();
                    while ( sinkNode.getNextLeftTupleSinkNode() != betaNode ) {
                        sinkNode = sinkNode.getNextLeftTupleSinkNode();
                    }
                   
                    SegmentMemory subNetworkSegmentMemory = createSegmentMemory( ( LeftTupleSource ) sinkNode, wm );
View Full Code Here

                node = n;
                break;
            }
        }
       
        BetaNode betaanode = (BetaNode) node.getSinkPropagator().getSinks()[0];
        BetaNodeFieldConstraint[] constraint = ( BetaNodeFieldConstraint[] ) betaanode.getConstraints();
        PredicateConstraint c = ( PredicateConstraint ) constraint[0];
        assertTrue( c.getPredicateExpression() instanceof PredicateExpression );
        assertTrue( c.getPredicateExpression() instanceof CompiledInvoker );
        assertTrue( !(c.getPredicateExpression() instanceof MVELPredicateExpression ) );
        
View Full Code Here

            SlidingTimeWindowContext slCtx = ( SlidingTimeWindowContext ) bjobCtx.behaviorContext;
 
            RightTuple rightTuple = slCtx.getQueue().peek();
            //outputCtx.writeInt( rightTuple.getFactHandle().getId() );
           
            BetaNode node = (BetaNode) rightTuple.getRightTupleSink();
            outputCtx.writeInt( node.getId() );
           
            Behavior[] behaviors = node.getBehaviors();
            int i = 0;
            for ( ; i < behaviors.length; i++ ) {    
                if ( behaviors[i] == bjobCtx.behavior ) {
                    break;
                }
View Full Code Here

            BehaviorJobContext bjobCtx = ( BehaviorJobContext ) jobCtx;
            // write out SlidingTimeWindowContext
            SlidingTimeWindowContext slCtx = ( SlidingTimeWindowContext ) bjobCtx.behaviorContext;
 
            RightTuple rightTuple = slCtx.getQueue().peek();
            BetaNode node = (BetaNode) rightTuple.getRightTupleSink();
           
            Behavior[] behaviors = node.getBehaviors();
            int i = 0;
            for ( ; i < behaviors.length; i++ ) {    
                if ( behaviors[i] == bjobCtx.behavior ) {
                    break;
                }
            }
            return ProtobufMessages.Timers.Timer.newBuilder()
                    .setType( ProtobufMessages.Timers.TimerType.BEHAVIOR )
                    .setBehavior( ProtobufMessages.Timers.BehaviorTimer.newBuilder()
                                  .setNodeId( node.getId() )
                                  .setBehaviorIndex( i )
                                  .build() )
                    .build();
        }
View Full Code Here

    }
   
    public static class BehaviorJobContextTimerInputMarshaller implements TimersInputMarshaller {
        public void read(MarshallerReaderContext inCtx) throws IOException, ClassNotFoundException {
            int sinkId = inCtx.readInt();
            BetaNode betaNode = (BetaNode) inCtx.sinks.get( sinkId );
           
            BetaMemory betaMemory = null;      
            if ( betaNode instanceof AccumulateNode ) {
                betaMemory = (( AccumulateMemory ) inCtx.wm.getNodeMemory( betaNode )).betaMemory;
            } else {
                betaMemory = ( BetaMemory ) inCtx.wm.getNodeMemory( betaNode );
            }
           
            Object[] behaviorContext = ( Object[]  ) betaMemory.getBehaviorContext();
           
            int i = inCtx.readInt();
            SlidingTimeWindowContext stwCtx = ( SlidingTimeWindowContext ) behaviorContext[i];
                      
            updateNextExpiration( ( RightTuple) stwCtx.queue.peek(),
                                  inCtx.wm,
                                  (SlidingTimeWindow) betaNode.getBehaviors()[i],
                                  stwCtx );
        }
View Full Code Here

        }

        public void deserialize(MarshallerReaderContext inCtx,
                                Timer _timer) throws ClassNotFoundException {
            int sinkId = _timer.getBehavior().getNodeId();
            BetaNode betaNode = (BetaNode) inCtx.sinks.get( sinkId );
           
            BetaMemory betaMemory = null;      
            if ( betaNode instanceof AccumulateNode ) {
                betaMemory = (( AccumulateMemory ) inCtx.wm.getNodeMemory( betaNode )).betaMemory;
            } else {
                betaMemory = ( BetaMemory ) inCtx.wm.getNodeMemory( betaNode );
            }
           
            Object[] behaviorContext = ( Object[]  ) betaMemory.getBehaviorContext();
           
            int i = _timer.getBehavior().getBehaviorIndex();
            SlidingTimeWindowContext stwCtx = ( SlidingTimeWindowContext ) behaviorContext[i];
                      
            updateNextExpiration( ( RightTuple) stwCtx.queue.peek(),
                                  inCtx.wm,
                                  (SlidingTimeWindow) betaNode.getBehaviors()[i],
                                  stwCtx );
        }
View Full Code Here

            this.context = context;
        }

        public BehaviorExpireWMAction(MarshallerReaderContext inCtx) throws IOException {
            int sinkId = inCtx.readInt();
            BetaNode betaNode = (BetaNode) inCtx.sinks.get( sinkId );
           
            BetaMemory betaMemory = null;      
            if ( betaNode instanceof AccumulateNode ) {
                betaMemory = (( AccumulateMemory ) inCtx.wm.getNodeMemory( betaNode )).betaMemory;
            } else {
                betaMemory = ( BetaMemory ) inCtx.wm.getNodeMemory( betaNode );
            }
           
            Object[] behaviorContext = ( Object[]  ) betaMemory.getBehaviorContext();
           
            int i = inCtx.readInt();
           
            this.behavior = (SlidingTimeWindow) betaNode.getBehaviors()[i];
            this.context =  ( SlidingTimeWindowContext ) behaviorContext[i];          
        }
View Full Code Here

        }
       
        public BehaviorExpireWMAction(MarshallerReaderContext context,
                                      Action _action) {
            int sinkId =_action.getBehaviorExpire().getNodeId();
            BetaNode betaNode = (BetaNode) context.sinks.get( sinkId );
           
            BetaMemory betaMemory = null;      
            if ( betaNode instanceof AccumulateNode ) {
                betaMemory = (( AccumulateMemory ) context.wm.getNodeMemory( betaNode )).betaMemory;
            } else {
                betaMemory = ( BetaMemory ) context.wm.getNodeMemory( betaNode );
            }
           
            Object[] behaviorContext = ( Object[]  ) betaMemory.getBehaviorContext();
           
            int i = 0; //  <==== this needs fixing
           
            this.behavior = (SlidingTimeWindow) betaNode.getBehaviors()[i];
            this.context =  ( SlidingTimeWindowContext ) behaviorContext[i];          
        }
View Full Code Here

            SlidingTimeWindowContext slCtx = ( SlidingTimeWindowContext ) context;
 
            RightTuple rightTuple = slCtx.getQueue().peek();
            //outputCtx.writeInt( rightTuple.getFactHandle().getId() );
           
            BetaNode node = (BetaNode) rightTuple.getRightTupleSink();
            outputCtx.writeInt( node.getId() );
           
            Behavior[] behaviors = node.getBehaviors();
            int i = 0;
            for ( ; i < behaviors.length; i++ ) {    
                if ( behaviors[i] == behavior ) {
                    break;
                }
View Full Code Here

TOP

Related Classes of org.drools.reteoo.BetaNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.