Examples of FieldIndexEntry


Examples of org.drools.util.FactHandleIndexHashTable.FieldIndexEntry

        final Cheese stilton3 = new Cheese( "stilton",
                                            89 );
        final InternalFactHandle stiltonHandle3 = new DefaultFactHandle( 4,
                                                                         stilton2 );

        final FieldIndexEntry stiltonEntry = map.get( new ReteTuple( stiltonHandle3 ) );
        assertSame( stiltonHandle2,
                    stiltonEntry.getFirst().getFactHandle() );
        assertSame( stiltonHandle1,
                    ((FactEntryImpl) stiltonEntry.getFirst().getNext()).getFactHandle() );
    }
View Full Code Here

Examples of org.drools.util.FactHandleIndexHashTable.FieldIndexEntry

        // however both are in the same table bucket
        assertEquals( 1,
                      tablePopulationSize( map ) );

        // this table bucket will have two FieldIndexEntries, as they are actually two different values
        final FieldIndexEntry entry = (FieldIndexEntry) getEntries( map )[0];

    }
View Full Code Here

Examples of org.drools.util.FactHandleIndexHashTable.FieldIndexEntry

                                                      null,
                                                      StringFactory.getInstance().getEvaluator( Operator.EQUAL ) );
        final SingleIndex singleIndex = new SingleIndex( new FieldIndex[]{fieldIndex},
                                                         1 );

        final FieldIndexEntry index = new FieldIndexEntry( singleIndex,
                                                           "stilton".hashCode() );

        // Test initial construction
        assertNull( index.getFirst() );
        assertEquals( "stilton".hashCode(),
                      index.hashCode() );

        final Cheese stilton1 = new Cheese( "stilton",
                                            35 );
        final InternalFactHandle h1 = new DefaultFactHandle( 1,
                                                             stilton1 );

        // test add
        index.add( h1 );

        final FactEntryImpl entry1 = index.getFirst();
        assertSame( h1,
                    entry1.getFactHandle() );
        assertNull( entry1.getNext() );
        assertSame( entry1,
                    index.get( h1 ) );

        // test get
        final FactEntryImpl entry2 = index.get( h1 );
        assertSame( entry1,
                    entry2 );

        // test remove
        index.remove( h1 );
        assertNull( index.getFirst() );
    }
View Full Code Here

Examples of org.drools.util.FactHandleIndexHashTable.FieldIndexEntry

                                                      null,
                                                      StringFactory.getInstance().getEvaluator( Operator.EQUAL ) );
        final SingleIndex singleIndex = new SingleIndex( new FieldIndex[]{fieldIndex},
                                                         1 );

        final FieldIndexEntry index = new FieldIndexEntry( singleIndex,
                                                           "stilton".hashCode() );

        final Cheese stilton1 = new Cheese( "stilton",
                                            35 );
        final InternalFactHandle h1 = new DefaultFactHandle( 1,
                                                             stilton1 );
        final Cheese stilton2 = new Cheese( "stilton",
                                            59 );
        final InternalFactHandle h2 = new DefaultFactHandle( 2,
                                                             stilton2 );

        // test add
        index.add( h1 );
        index.add( h2 );
        assertEquals( h2,
                      index.getFirst().getFactHandle() );
        assertEquals( h1,
                      ((FactEntryImpl) index.getFirst().getNext()).getFactHandle() );

        // test get
        assertEquals( h1,
                      index.get( h1 ).getFactHandle() );
        assertEquals( h2,
                      index.get( h2 ).getFactHandle() );

        // test removal for combinations
        // remove first
        index.remove( h2 );
        assertEquals( h1,
                      index.getFirst().getFactHandle() );

        // remove second
        index.add( h2 );
        index.remove( h1 );
        assertEquals( h2,
                      index.getFirst().getFactHandle() );

        // check index type does not change, as this fact is removed
        stilton1.setType( "cheddar" );
    }
View Full Code Here

Examples of org.drools.util.FactHandleIndexHashTable.FieldIndexEntry

                                                      null,
                                                      StringFactory.getInstance().getEvaluator( Operator.EQUAL ) );
        final SingleIndex singleIndex = new SingleIndex( new FieldIndex[]{fieldIndex},
                                                         1 );

        final FieldIndexEntry index = new FieldIndexEntry( singleIndex,
                                                           "stilton".hashCode() );

        final Cheese stilton1 = new Cheese( "stilton",
                                            35 );
        final InternalFactHandle h1 = new DefaultFactHandle( 1,
                                                             stilton1 );
        final Cheese stilton2 = new Cheese( "stilton",
                                            59 );
        final InternalFactHandle h2 = new DefaultFactHandle( 2,
                                                             stilton2 );
        final Cheese stilton3 = new Cheese( "stilton",
                                            59 );
        final InternalFactHandle h3 = new DefaultFactHandle( 3,
                                                             stilton3 );

        // test add
        index.add( h1 );
        index.add( h2 );
        index.add( h3 );
        assertEquals( h3,
                      index.getFirst().getFactHandle() );
        assertEquals( h2,
                      ((FactEntryImpl) index.getFirst().getNext()).getFactHandle() );
        assertEquals( h1,
                      ((FactEntryImpl) index.getFirst().getNext().getNext()).getFactHandle() );

        // test get
        assertEquals( h1,
                      index.get( h1 ).getFactHandle() );
        assertEquals( h2,
                      index.get( h2 ).getFactHandle() );
        assertEquals( h3,
                      index.get( h3 ).getFactHandle() );

        // test removal for combinations
        //remove first
        index.remove( h3 );
        assertEquals( h2,
                      index.getFirst().getFactHandle() );
        assertEquals( h1,
                      ((FactEntryImpl) index.getFirst().getNext()).getFactHandle() );

        index.add( h3 );
        index.remove( h2 );
        assertEquals( h3,
                      index.getFirst().getFactHandle() );
        assertEquals( h1,
                      ((FactEntryImpl) index.getFirst().getNext()).getFactHandle() );

        index.add( h2 );
        index.remove( h1 );
        assertEquals( h2,
                      index.getFirst().getFactHandle() );
        assertEquals( h3,
                      ((FactEntryImpl) index.getFirst().getNext()).getFactHandle() );

        index.remove( index.getFirst().getFactHandle() );
        // check index type does not change, as this fact is removed
        stilton2.setType( "cheddar" );
    }
View Full Code Here

Examples of org.drools.util.TupleIndexHashTable.FieldIndexEntry

    public Iterator iterator(final ReteTuple tuple) {
        if ( this.tupleValueIterator == null ) {
            this.tupleValueIterator = new FieldIndexHashTableIterator();
        }
        final FieldIndexEntry entry = get( tuple );
        this.tupleValueIterator.reset( (entry != null) ? entry.first : null );
        return this.tupleValueIterator;
    }
View Full Code Here

Examples of org.drools.util.TupleIndexHashTable.FieldIndexEntry

   
    public Entry[] toArray() {
        Entry[] result = new Entry[this.factSize];
        int index = 0;
        for ( int i = 0; i < this.table.length; i++ ) {
            FieldIndexEntry fieldIndexEntry = (FieldIndexEntry)this.table[i];
            while ( fieldIndexEntry != null ) {
                Entry entry = fieldIndexEntry.getFirst();
                while ( entry != null ) {
                    result[index++] = entry;
                    entry = entry.getNext();
                }      
                fieldIndexEntry  = ( FieldIndexEntry ) fieldIndexEntry.getNext();
            }
        }
        return result;
   
View Full Code Here

Examples of org.drools.util.TupleIndexHashTable.FieldIndexEntry

        }
        return result;
   

    public boolean add(final InternalFactHandle handle) {
        final FieldIndexEntry entry = getOrCreate( handle.getObject() );
        entry.add( handle );
        this.factSize++;
        return true;
    }
View Full Code Here

Examples of org.drools.util.TupleIndexHashTable.FieldIndexEntry

        final int index = indexOf( hashCode,
                                   this.table.length );

        // search the table for  the Entry, we need to track previous  and next, so if the
        // Entry is empty after  its had the FactEntry removed, we must remove  it from the table
        FieldIndexEntry previous = (FieldIndexEntry) this.table[index];
        FieldIndexEntry current = previous;
        while ( current != null ) {
            final FieldIndexEntry next = (FieldIndexEntry) current.next;
            if ( current.matches( object,
                                  hashCode ) ) {
                current.remove( handle );
                this.factSize--;
                // If the FactEntryIndex is empty, then remove it from the hash table
View Full Code Here

Examples of org.drools.util.TupleIndexHashTable.FieldIndexEntry

        final int hashCode = this.index.hashCodeOf( object );

        final int index = indexOf( hashCode,
                                   this.table.length );

        FieldIndexEntry current = (FieldIndexEntry) this.table[index];
        while ( current != null ) {
            if ( current.matches( object,
                                  hashCode ) ) {
                return true;
            }
            current = (FieldIndexEntry) current.next;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.