Package org.drools.core.util.index

Examples of org.drools.core.util.index.RightTupleList$TupleHashTableIterator


        int factCount = 0;
        int bucketCount = 0;
        FastIterator it = LinkedList.fastIterator;
        for ( int i = 0, length = entries.length; i < length; i++ ) {
            if ( entries[i] != null ) {
                RightTupleList rightTupleList = (RightTupleList) entries[i];
                while ( rightTupleList != null ) {
                    if ( rightTupleList.first != null ) {
                        Entry entry = rightTupleList.first;
                        while ( entry != null ) {
                            entry = it.next( entry );
                            factCount++;
                        }
                    } else {
                        logger.info( "error : fieldIndexHashTable cannot have empty FieldIndexEntry objects" );
                    }
                    rightTupleList = (RightTupleList) rightTupleList.getNext();
                    bucketCount++;
                }
            }
        }
View Full Code Here


                                                                         rightTuple,
                                                                         true, // this must always be true, otherwise we can't
                                                                               // find the child tuples to iterate for evaluating the query results
                                                                         query.isOpen() );

            RightTupleList rightTuples = query.getResultInsertRightTupleList();
            if ( rightTuples == null ) {
                rightTuples = new RightTupleList();
                query.setResultInsertRightTupleList( rightTuples );
                QueryResultInsertAction evalAction = new QueryResultInsertAction( context,
                                                                                  this.factHandle,
                                                                                  leftTuple,
                                                                                  this.node );
                context.getQueue2().addFirst( evalAction );
            }

            rightTuples.add( rightTuple );
        }
View Full Code Here

            rightTuple.setLeftTuple( null );
            resultLeftTuple.setObject( null );

            DroolsQuery query = (DroolsQuery) this.factHandle.getObject();

            RightTupleList rightTuples = query.getResultRetractRightTupleList();
            if ( rightTuples == null ) {
                rightTuples = new RightTupleList();
                query.setResultRetractRightTupleList( rightTuples );
                QueryResultRetractAction retractAction = new QueryResultRetractAction( context,
                                                                                       this.factHandle,
                                                                                       leftTuple,
                                                                                       this.node );
                context.getQueue2().addFirst( retractAction );
            }
            if ( rightTuple.getMemory() != null ) {
                throw new RuntimeException();
            }
            rightTuples.add( rightTuple );
        }
View Full Code Here

                resultLeftTuple.setObject( rightTuple );
            }

            // Don't need to recreate child links, as they will already be there form the first "add"

            RightTupleList rightTuples = query.getResultUpdateRightTupleList();
            if ( rightTuples == null ) {
                rightTuples = new RightTupleList();
                query.setResultUpdateRightTupleList( rightTuples );
                QueryResultUpdateAction updateAction = new QueryResultUpdateAction( context,
                                                                                    this.factHandle,
                                                                                    leftTuple,
                                                                                    this.node );
                context.getQueue2().addFirst( updateAction );
            }
            rightTuples.add( rightTuple );
        }
View Full Code Here

        void add(final RightTuple rightTuple,
                 int hashCode,
                 Object object) {
            lock();
            try {
                final RightTupleList entry = getOrCreate( hashCode,
                                                          object );
                entry.add( rightTuple );
                this.tupleCount++;
            } finally {
                unlock();
            }
        }
View Full Code Here

            try {
                int c = keyCount - 1;

                RightTupleList[] tab = table;
                int index = hashCode & (tab.length - 1);
                RightTupleList first = tab[index];
                RightTupleList e = first;
                while ( e != null ) {
                    if ( e.matches( object,
                                    hashCode ) ) {
                        break;
                    }
                    e = (RightTupleList) e.next;
                }

                e.remove( rightTuple );
                tupleCount--;

                if ( e.getFirst( ) == null ) {
                    // list is empty, so remove it
                    RightTupleList newFirst = (RightTupleList) e.getNext();
                    for ( RightTupleList p = first; p != e; p = (RightTupleList) p.getNext() ) {
                        newFirst = new RightTupleList( p.getIndex(),
                                                       hashCode,
                                                       newFirst );
                    }
                    keyCount = c; // write-volatile
                }
View Full Code Here

            //this.index.setCachedValue( tuple );
            lock();
            try {
                RightTupleList[] tab = table;
                int index = hashCode & (tab.length - 1);
                RightTupleList first = tab[index];
                RightTupleList entry = first;

                while ( entry != null ) {
                    if ( entry.matches( tuple,
                                        hashCode ,
                                        factHandle ) ) {
                        return entry;
                    }
                    entry = (RightTupleList) entry.getNext();
                }

                return entry;
            } finally {
                unlock();
View Full Code Here

                                           final Object object) {
            int c = keyCount;

            RightTupleList[] tab = table;
            int index = hashCode & (tab.length - 1);
            RightTupleList first = tab[index];
            RightTupleList e = first;
            while ( e != null ) {
                if ( e.matches( object,
                                hashCode ) ) {
                    return e;
                }
                e = (RightTupleList) e.next;
            }

            if ( e == null ) {
                if ( c++ > threshold ) // ensure capacity
                    rehash();
                ++modCount;
                e = new RightTupleList( this.index,
                                        hashCode,
                                        first );
                tab[index] = e;
                keyCount = c; // write-volatile
            }
View Full Code Here

            threshold = (int) (newTable.length * loadFactor);
            int sizeMask = newTable.length - 1;
            for ( int i = 0; i < oldCapacity; i++ ) {
                // We need to guarantee that any existing reads of old Map can
                //  proceed. So we cannot yet null out each bin.
                RightTupleList e = oldTable[i];

                if ( e != null ) {
                    RightTupleList next = (RightTupleList) e.getNext();
                    int idx = e.hashCode() & sizeMask;

                    //  Single node on list
                    if ( next == null ) newTable[idx] = e;

                    else {
                        // Reuse trailing consecutive sequence at same slot
                        RightTupleList lastRun = e;
                        int lastIdx = idx;
                        for ( RightTupleList last = next; last != null; last = (RightTupleList) last.getNext() ) {
                            int k = last.hashCode() & sizeMask;
                            if ( k != lastIdx ) {
                                lastIdx = k;
                                lastRun = last;
                            }
                        }
                        newTable[lastIdx] = lastRun;

                        // Clone all remaining nodes
                        for ( RightTupleList p = e; p != lastRun; p = (RightTupleList) p.getNext() ) {
                            int k = p.hashCode() & sizeMask;
                            RightTupleList n = newTable[k];
                            newTable[k] = new RightTupleList( p, n );
                        }
                    }
                }
            }
            table = newTable;
View Full Code Here

            // now process existing blocks, we only process existing and not new from above loop
            FastIterator rightIt = getRightIterator( rightTupleMemory );
            RightTuple rootBlocker = useComparisonIndex ? null : (RightTuple) rightIt.next(rightTuple);
         
            RightTupleList list = rightTuple.getMemory();
           
            // we must do this after we have the next in memory
            // We add to the end to give an opportunity to re-match if in same bucket
            rightTupleMemory.removeAdd( rightTuple );
View Full Code Here

TOP

Related Classes of org.drools.core.util.index.RightTupleList$TupleHashTableIterator

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.