Package org.drools.rule

Examples of org.drools.rule.Accumulate


        final boolean readLocalsFromTuple = PackageBuilderUtil.isReadLocalsFromTuple( accumDescr, source );
       
        Map<String, Declaration> declsInScope = context.getDeclarationResolver().getDeclarations( context.getRule() );
        Map<String, Class< ? >> declCls = DeclarationScopeResolver.getDeclarationClasses( declsInScope );

        Accumulate accumulate;
        if ( accumDescr.isExternalFunction() ) {
            // if it uses 1+ external function, build methods for them
            accumulate = buildExternalFunctionCall( context,
                                                    accumDescr,
                                                    source,
View Full Code Here


                                                                      usedIdentifiers,
                                                                      previousDeclarations,
                                                                      readLocalsFromTuple );
        }

        return new Accumulate(source,
                requiredDecl.toArray(new Declaration[requiredDecl.size()]),
                accumulators,
                accumDescr.isMultiFunction());
    }
View Full Code Here

        }

        map.put( "hashCode",
                actionCode.hashCode());

        Accumulate accumulate = new Accumulate(source, declarations);

        generateTemplates("accumulateInnerClass",
                "accumulateInvoker",
                context,
                className,
View Full Code Here

                                               reverse,
                                               result );

        }

        final Accumulate accumulate = new Accumulate( source,
                                                      declarations,
                                                      sourceDeclArr,
                                                      accumulator );
        return accumulate;
    }
View Full Code Here

     * @inheritDoc
     */
    public void build(final BuildContext context,
                      final BuildUtils utils,
                      final RuleConditionElement rce) {
        final Accumulate accumulate = (Accumulate) rce;
        boolean existSubNetwort = false;

        final List resultBetaConstraints = context.getBetaconstraints();
        final List resultAlphaConstraints = context.getAlphaConstraints();

        final Pattern sourcePattern = accumulate.getSourcePattern();

        // get builder for the pattern
        final ReteooComponentBuilder builder = utils.getBuilderFor( sourcePattern );

        // save tuple source and current pattern offset for later if needed
View Full Code Here

     * @inheritDoc
     */
    public void build(final BuildContext context,
                      final BuildUtils utils,
                      final RuleConditionElement rce) {
        final Accumulate accumulate = (Accumulate) rce;
        boolean existSubNetwort = false;
        context.pushRuleComponent( accumulate );

        final List resultBetaConstraints = context.getBetaconstraints();
        final List resultAlphaConstraints = context.getAlphaConstraints();
        final List resultBehaviors = context.getBehaviors();

        RuleConditionElement source = accumulate.getSource();
        if( source instanceof GroupElement ) {
            GroupElement ge = (GroupElement) source;
            if( ge.isAnd() && ge.getChildren().size() == 1 ) {
                source = (RuleConditionElement) ge.getChildren().get( 0 );
            }
View Full Code Here

            if ( srcLeftTuples.getInsertFirst() != null ) {
                doLeftInserts( accNode, sink, am, wm, srcLeftTuples, tempLeftTuples );
            }
           
            Accumulate accumulate = accNode.getAccumulate();
            // we do not need collect retracts. RightTuple retracts end up as updates for lefttuples.
            // LeftTuple retracts are already on the trgLeftTuples
            for ( LeftTuple leftTuple = tempLeftTuples.getInsertFirst(); leftTuple != null; ) {
                LeftTuple next = leftTuple.getStagedNext();
                evaluateResultConstraints( accNode, sink, accumulate, leftTuple, leftTuple.getPropagationContext(),
View Full Code Here

                                  LeftTupleSets srcLeftTuples,
                                  LeftTupleSets trgLeftTuples) {
            boolean tupleMemory = true;
            boolean tupleMemoryEnabled = true;

            Accumulate accumulate = accNode.getAccumulate();           
            BetaMemory bm = am.getBetaMemory();
            LeftTupleMemory ltm = bm.getLeftTupleMemory();
            RightTupleMemory rtm = bm.getRightTupleMemory();
            ContextEntry[] contextEntry = bm.getContext();
            BetaConstraints constraints = accNode.getRawConstraints();
            FastIterator it = accNode.getRightIterator( rtm );

            for ( LeftTuple leftTuple = srcLeftTuples.getInsertFirst(); leftTuple != null; ) {
                LeftTuple next = leftTuple.getStagedNext();
                PropagationContext context = leftTuple.getPropagationContext();
               
                AccumulateContext accresult = new AccumulateContext();

                boolean useLeftMemory = true;
                if ( !tupleMemoryEnabled ) {
                    // This is a hack, to not add closed DroolsQuery objects
                    Object object = ((InternalFactHandle) leftTuple.get( 0 )).getObject();
                    if ( !(object instanceof DroolsQuery) || !((DroolsQuery) object).isOpen() ) {
                        useLeftMemory = false;
                    }
                }

                if ( useLeftMemory ) {
                    ltm.add( leftTuple );
                    leftTuple.setObject( accresult );
                }        
               
                accresult.context = accumulate.createContext();

                accumulate.init( am.workingMemoryContext,
                                 accresult.context,
                                 leftTuple,
                                 wm );

                constraints.updateFromTuple( contextEntry,
View Full Code Here

                                   LeftTupleSets trgLeftTuples) {
            boolean tupleMemory = true;
            boolean tupleMemoryEnabled = true;


            Accumulate accumulate = accNode.getAccumulate();           

            BetaMemory bm = am.getBetaMemory();
            LeftTupleMemory ltm = bm.getLeftTupleMemory();
            RightTupleMemory rtm = bm.getRightTupleMemory();
            ContextEntry[] contextEntry = bm.getContext();
View Full Code Here

                                  LeftTupleSets trgLeftTuples) {
            boolean tupleMemory = true;
           
            BetaMemory bm = am.getBetaMemory();
            RightTupleMemory rtm = bm.getRightTupleMemory();           
            Accumulate accumulate = accNode.getAccumulate();                       
            ContextEntry[] contextEntry = bm.getContext();
            BetaConstraints constraints = accNode.getRawConstraints();
            FastIterator rightIt = accNode.getRightIterator( rtm );

            for ( LeftTuple leftTuple = srcLeftTuples.getUpdateFirst(); leftTuple != null; ) {
View Full Code Here

TOP

Related Classes of org.drools.rule.Accumulate

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.