Package org.drools.core.util

Examples of org.drools.core.util.LinkedList


   
   
    public void setUnificationJoin() {
        // If this join uses a indexed, ==, constraint on a query parameter then set indexedUnificationJoin to true
        // This ensure we get the correct iterator
        LinkedList list = this.constraints.getConstraints();
        if ( !list.isEmpty() ) {
            BetaNodeFieldConstraint c = ( BetaNodeFieldConstraint ) ((LinkedListEntry) list.getFirst()).getObject();
            if ( DefaultBetaConstraints.isIndexable( c ) && ((VariableConstraint) c).getRestriction() instanceof UnificationRestriction) {
                if ( this.constraints instanceof SingleBetaConstraints ) {
                    this.constraints = new SingleNonIndexSkipBetaConstraints( ( SingleBetaConstraints ) this.constraints );
                }else if ( this.constraints instanceof DoubleBetaConstraints ) {
                    this.constraints = new DoubleNonIndexSkipBetaConstraints( ( DoubleBetaConstraints ) this.constraints );


            return (RightTuple) it.next( null );
        }
    }

    public BetaNodeFieldConstraint[] getConstraints() {
        final LinkedList constraints = this.constraints.getConstraints();

        final BetaNodeFieldConstraint[] array = new BetaNodeFieldConstraint[constraints.size()];
        int i = 0;
        for ( LinkedListEntry entry = (LinkedListEntry) constraints.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) {
            array[i++] = (BetaNodeFieldConstraint) entry.getObject();
        }
        return array;
    }

    public DefaultBetaConstraints(final BetaNodeFieldConstraint[] constraints,
                                  final RuleBaseConfiguration conf,
                                  final boolean disableIndexing) {
        this.indexed = -1;
        this.constraints = new LinkedList();
        int depth = conf.getCompositeKeyDepth();
       
        if ( !compositeAllowed(constraints) ) {
            // UnificationRestrictions cannot be allowed in composite indexes
            // We also ensure that if there is a mixture that standard restriction is first

    }
   
    public QuadroupleNonIndexSkipBetaConstraints(QuadroupleBetaConstraints constraints) {
        this.constraints = constraints;
        LinkedList list = constraints.getConstraints();
        this.constraint0 = (BetaNodeFieldConstraint) ((LinkedListEntry)list.getFirst()).getObject();
        this.constraint1 = (BetaNodeFieldConstraint) ((LinkedListEntry)list.getFirst().getNext()).getObject();
        this.constraint2 = (BetaNodeFieldConstraint) ((LinkedListEntry)list.getFirst().getNext().getNext()).getObject();
        this.constraint3 = (BetaNodeFieldConstraint) ((LinkedListEntry)list.getFirst().getNext().getNext().getNext()).getObject();
    }

    /* (non-Javadoc)
     * @see org.drools.common.BetaNodeConstraints#getConstraints()
     */
    public LinkedList getConstraints() {
        final LinkedList list = new LinkedList();
        list.add( new LinkedListEntry( this.constraint0 ) );
        list.add( new LinkedListEntry( this.constraint1 ) );
        return list;
    }

    public DefaultBetaConstraints(final BetaNodeFieldConstraint[] constraints,
                                  final RuleBaseConfiguration conf,
                                  final boolean disableIndexing) {
        this.indexed = -1;
        this.constraints = new LinkedList();
        final int depth = conf.getCompositeKeyDepth();

        // First create a LinkedList of constraints, with the indexed constraints first.
        for ( int i = 0, length = constraints.length; i < length; i++ ) {
            // Determine  if this constraint is indexable

        if ( seq > this.lastIndex ) {
            this.lastIndex = seq;
        }

        LinkedList list = this.array[seq];
        if ( list == null ) {
            list = new LinkedList();
            this.array[item.getSequenence()] = list;
        }

        list.add( new LinkedListEntry( activation ) );
    }

    }

    public Activation getNext() {
        Activation activation = null;
        while ( this.index <= lastIndex ) {
            LinkedList list = this.array[this.index];
            if ( list != null ) {
                activation = (Activation) ((LinkedListEntry)list.removeFirst()).getObject();
                if ( list.isEmpty()) {
                    this.array[this.index++] = null;
                }
                this.size--;
                break;
            }

    public Activation[] getActivations() {
        Activation[] activations = new Activation[this.size];
        int j = 0;
        for ( int i = 0; i < this.array.length; i++ ) {;
            LinkedList list = this.array[i];
            if ( list != null ) {
                Iterator it = list.iterator();
                Activation activation = ( Activation ) ((LinkedListEntry)it.next()).getObject();
                while ( activation != null) {
                    activations[j++] = activation;
                    activation = ( Activation ) it.next();
                }

    /* (non-Javadoc)
     * @see org.drools.common.BetaNodeConstraints#getConstraints()
     */
    public LinkedList getConstraints() {
        final LinkedList list = new LinkedList();
        list.add( new LinkedListEntry( this.constraint ) );
        return list;
    }

TOP

Related Classes of org.drools.core.util.LinkedList

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.