Package org.drools.core.common

Examples of org.drools.core.common.BetaConstraints


                               LeftTupleSets trgLeftTuples,
                               LeftTupleSets stagedLeftTuples) {
        RightTupleMemory rtm = bm.getRightTupleMemory();
        LeftTupleMemory ltm = bm.getLeftTupleMemory();
        ContextEntry[] contextEntry = bm.getContext();
        BetaConstraints constraints = existsNode.getRawConstraints();

        for (RightTuple rightTuple = srcRightTuples.getDeleteFirst(); rightTuple != null; ) {
            RightTuple next = rightTuple.getStagedNext();

            FastIterator it = existsNode.getRightIterator(rtm);

            boolean useComparisonIndex = rtm.getIndexType().isComparison();
            RightTuple rootBlocker = useComparisonIndex ? null : (RightTuple) it.next(rightTuple);

            if (rightTuple.getMemory() != null) {
                // it may have been staged and never actually added
                rtm.remove(rightTuple);
            }

            if (rightTuple.getBlocked() != null) {

                for (LeftTuple leftTuple = rightTuple.getBlocked(); leftTuple != null; ) {
                    LeftTuple temp = leftTuple.getBlockedNext();

                    leftTuple.clearBlocker();

                    if (leftTuple.getStagedType() == LeftTuple.UPDATE) {
                        // ignore, as it will get processed via left iteration. Children cannot be processed twice
                        leftTuple = temp;
                        continue;
                    }

                    constraints.updateFromTuple(contextEntry,
                                                wm,
                                                leftTuple);

                    if (useComparisonIndex) {
                        rootBlocker = rtm.getFirst(leftTuple, null, it);
                    }

                    // we know that older tuples have been checked so continue previously
                    for (RightTuple newBlocker = rootBlocker; newBlocker != null; newBlocker = (RightTuple) it.next(newBlocker)) {
                        if (constraints.isAllowedCachedLeft(contextEntry,
                                                            newBlocker.getFactHandle())) {
                            leftTuple.setBlocker(newBlocker);
                            newBlocker.addBlocked(leftTuple);

                            break;
View Full Code Here


                } catch ( IntrospectionException e ) {
                    throw new IllegalArgumentException();
                }
            }
           
            BetaConstraints constraints;
            switch ( list.size() ) {
                case 0:
                    constraints = new EmptyBetaConstraints();
                    break;
                case 1:
View Full Code Here

                } catch ( IntrospectionException e ) {
                    throw new IllegalArgumentException();
                }
            }
           
            BetaConstraints constraints;
            switch ( list.size() ) {
                case 0:
                    constraints = new EmptyBetaConstraints();
                    break;
                case 1:
View Full Code Here

                                                            e );
                    }
                }
            }
           
            BetaConstraints betaSourceConstraints;
            switch ( list.size() ) {
                case 0:
                    betaSourceConstraints = new EmptyBetaConstraints();
                    break;
                case 1:
View Full Code Here

                } catch ( IntrospectionException e ) {
                    throw new IllegalArgumentException();
                }
            }
           
            BetaConstraints constraints;
            switch ( list.size() ) {
                case 0:
                    constraints = new EmptyBetaConstraints();
                    break;
                case 1:
View Full Code Here

                                                             Foo.class );
        BetaNodeFieldConstraint[] constraints = new BetaNodeFieldConstraint[]{constraint0};

        RuleBaseConfiguration config = new RuleBaseConfiguration();

        BetaConstraints betaConstraints = null;

        betaConstraints = new SingleBetaConstraints( constraints,
                                                     config );

        BetaMemory betaMemory = betaConstraints.createBetaMemory( config, NodeTypeEnums.JoinNode );

        RuleBase rb = RuleBaseFactory.newRuleBase();
        StatefulSession ss = rb.newStatefulSession();

        InternalFactHandle fh1 = (InternalFactHandle) ss.insert( new Foo( "brie",
View Full Code Here

                              LeftTupleSets srcLeftTuples,
                              LeftTupleSets trgLeftTuples) {
        LeftTupleMemory ltm = bm.getLeftTupleMemory();
        RightTupleMemory rtm = bm.getRightTupleMemory();
        ContextEntry[] contextEntry = bm.getContext();
        BetaConstraints constraints = joinNode.getRawConstraints();

        for (LeftTuple leftTuple = srcLeftTuples.getInsertFirst(); leftTuple != null; ) {
            LeftTuple next = leftTuple.getStagedNext();

            boolean useLeftMemory = RuleNetworkEvaluator.useLeftMemory(joinNode, leftTuple);

            if (useLeftMemory) {
                ltm.add(leftTuple);
            }

            FastIterator it = joinNode.getRightIterator(rtm);
            PropagationContext context = leftTuple.getPropagationContext();

            constraints.updateFromTuple(contextEntry,
                                        wm,
                                        leftTuple);

            for (RightTuple rightTuple = joinNode.getFirstRightTuple(leftTuple,
                                                                     rtm,
                                                                     null,
                                                                     it); rightTuple != null; rightTuple = (RightTuple) it.next(rightTuple)) {
                if (constraints.isAllowedCachedLeft(contextEntry,
                                                    rightTuple.getFactHandle())) {
                    trgLeftTuples.addInsert(sink.createLeftTuple(leftTuple,
                                                                 rightTuple,
                                                                 null,
                                                                 null,
                                                                 sink,
                                                                 useLeftMemory));
                }

            }
            leftTuple.clearStaged();
            leftTuple = next;
        }
        constraints.resetTuple(contextEntry);
    }
View Full Code Here

                               RightTupleSets srcRightTuples,
                               LeftTupleSets trgLeftTuples) {
        LeftTupleMemory ltm = bm.getLeftTupleMemory();
        RightTupleMemory rtm = bm.getRightTupleMemory();
        ContextEntry[] contextEntry = bm.getContext();
        BetaConstraints constraints = joinNode.getRawConstraints();

        for (RightTuple rightTuple = srcRightTuples.getInsertFirst(); rightTuple != null; ) {
            RightTuple next = rightTuple.getStagedNext();

            rtm.add(rightTuple);
            if ( ltm == null || ltm.size() == 0 ) {
                // do nothing here, as no left memory
                rightTuple.clearStaged();
                rightTuple = next;
                continue;
            }

            FastIterator it = joinNode.getLeftIterator(ltm);
            PropagationContext context = rightTuple.getPropagationContext();

            constraints.updateFromFactHandle(contextEntry,
                                             wm,
                                             rightTuple.getFactHandle());

            for (LeftTuple leftTuple = joinNode.getFirstLeftTuple(rightTuple, ltm, context, it); leftTuple != null; leftTuple = (LeftTuple) it.next(leftTuple)) {
                if (leftTuple.getStagedType() == LeftTuple.UPDATE) {
                    // ignore, as it will get processed via left iteration. Children cannot be processed twice
                    continue;
                }

                if (constraints.isAllowedCachedRight(contextEntry,
                                                     leftTuple)) {
                    trgLeftTuples.addInsert(sink.createLeftTuple(leftTuple,
                                                                 rightTuple,
                                                                 null,
                                                                 null,
                                                                 sink,
                                                                 true));
                }
            }
            rightTuple.clearStaged();
            rightTuple = next;
        }
        constraints.resetFactHandle(contextEntry);
    }
View Full Code Here

                              LeftTupleSets srcLeftTuples,
                              LeftTupleSets trgLeftTuples,
                              LeftTupleSets stagedLeftTuples) {
        RightTupleMemory rtm = bm.getRightTupleMemory();
        ContextEntry[] contextEntry = bm.getContext();
        BetaConstraints constraints = joinNode.getRawConstraints();

        for (LeftTuple leftTuple = srcLeftTuples.getUpdateFirst(); leftTuple != null; ) {
            LeftTuple next = leftTuple.getStagedNext();

            PropagationContext context = leftTuple.getPropagationContext();

            constraints.updateFromTuple(contextEntry,
                                        wm,
                                        leftTuple);

            FastIterator it = joinNode.getRightIterator(rtm);
            RightTuple rightTuple = joinNode.getFirstRightTuple(leftTuple,
                                                                rtm,
                                                                null,
                                                                it);

            LeftTuple childLeftTuple = leftTuple.getFirstChild();

            // first check our index (for indexed nodes only) hasn't changed and we are returning the same bucket
            // if rightTuple is null, we assume there was a bucket change and that bucket is empty
            if (childLeftTuple != null && rtm.isIndexed() && !it.isFullIterator() && (rightTuple == null || (rightTuple.getMemory() != childLeftTuple.getRightParent().getMemory()))) {
                // our index has changed, so delete all the previous propagations
                while (childLeftTuple != null) {
                    childLeftTuple = RuleNetworkEvaluator.deleteLeftChild(childLeftTuple, trgLeftTuples, stagedLeftTuples);
                }
                // childLeftTuple is now null, so the next check will attempt matches for new bucket
            }

            // we can't do anything if RightTupleMemory is empty
            if (rightTuple != null) {
                doLeftUpdatesProcessChildren(childLeftTuple, leftTuple, rightTuple, stagedLeftTuples, contextEntry, constraints, sink, it, trgLeftTuples);
            }
            leftTuple.clearStaged();
            leftTuple = next;
        }
        constraints.resetTuple(contextEntry);
    }
View Full Code Here

                               RightTupleSets srcRightTuples,
                               LeftTupleSets trgLeftTuples,
                               LeftTupleSets stagedLeftTuples) {
        LeftTupleMemory ltm = bm.getLeftTupleMemory();
        ContextEntry[] contextEntry = bm.getContext();
        BetaConstraints constraints = joinNode.getRawConstraints();

        for (RightTuple rightTuple = srcRightTuples.getUpdateFirst(); rightTuple != null; ) {
            RightTuple next = rightTuple.getStagedNext();

            PropagationContext context = rightTuple.getPropagationContext();

            LeftTuple childLeftTuple = rightTuple.getFirstChild();

            FastIterator it = joinNode.getLeftIterator(ltm);
            LeftTuple leftTuple = joinNode.getFirstLeftTuple(rightTuple, ltm, context, it);

            constraints.updateFromFactHandle(contextEntry,
                                             wm,
                                             rightTuple.getFactHandle());

            // first check our index (for indexed nodes only) hasn't changed and we are returning the same bucket
            // We assume a bucket change if leftTuple == null
            if (childLeftTuple != null && ltm.isIndexed() && !it.isFullIterator() && (leftTuple == null || (leftTuple.getMemory() != childLeftTuple.getLeftParent().getMemory()))) {
                // our index has changed, so delete all the previous propagations
                while (childLeftTuple != null) {
                    childLeftTuple.setPropagationContext(rightTuple.getPropagationContext());
                    childLeftTuple = RuleNetworkEvaluator.deleteRightChild(childLeftTuple, trgLeftTuples, stagedLeftTuples);
                }
                // childLeftTuple is now null, so the next check will attempt matches for new bucket
            }

            // we can't do anything if LeftTupleMemory is empty
            if (leftTuple != null) {
                doRightUpdatesProcessChildren(childLeftTuple, leftTuple, rightTuple, stagedLeftTuples, contextEntry, constraints, sink, it, trgLeftTuples);
            }
            rightTuple.clearStaged();
            rightTuple = next;
        }
        constraints.resetFactHandle(contextEntry);
    }
View Full Code Here

TOP

Related Classes of org.drools.core.common.BetaConstraints

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.