Package org.drools.util

Examples of org.drools.util.FactHashTable


        final Tuple tuple0 = (Tuple) ((Object[]) asserted.get( 0 ))[0];
        assertSame( string1,
                    workingMemory.getObject( tuple0.get( 0 ) ) );

        // check node memory
        final FactHashTable table = (FactHashTable) workingMemory.getNodeMemory( liaNode );
        assertEquals( 1,
                      table.size() );
        assertTrue( table.contains( f0 ) );

        // check memory works with multiple handles
        final DefaultFactHandle f1 = (DefaultFactHandle) workingMemory.insert( "test1" );
        liaNode.assertObject( f1,
                              context,
                              workingMemory );

        assertLength( 2,
                      asserted );
        final Tuple tuple1 = (Tuple) ((Object[]) asserted.get( 1 ))[0];

        assertEquals( 2,
                      table.size() );
        assertTrue( table.contains( f1 ) );

        assertNotSame( tuple0,
                       tuple1 );

    }
View Full Code Here


                              context,
                              workingMemory );

        final Tuple tuple = (Tuple) ((Object[]) sink.getAsserted().get( 0 ))[0];

        final FactHashTable map = (FactHashTable) workingMemory.getNodeMemory( liaNode );
        assertTrue( map.contains( f0 ) );

        liaNode.retractObject( f0,
                               context,
                               workingMemory );

        assertFalse( map.contains( f0 ) );

        assertNotSame( tuple,
                       ((Object[]) sink.getRetracted().get( 0 ))[0] );

    }
View Full Code Here

                      asserted );
        assertSame( string1,
                    workingMemory.getObject( (DefaultFactHandle) ((Object[]) asserted.get( 0 ))[0] ) );

        // check asserted object was added to memory
        final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( objectTypeNode );
        assertEquals( 1,
                      memory.size() );
        assertTrue( memory.contains( handle1 ) );
    }
View Full Code Here

                      asserted );
        assertSame( string1,
                    workingMemory.getObject( (DefaultFactHandle) ((Object[]) asserted.get( 0 ))[0] ) );

        // it's sequential, so check the asserted object was not added to the node memory
        final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( objectTypeNode );
        assertEquals( 0,
                      memory.size() );
    }
View Full Code Here

        final ObjectTypeNode objectTypeNode = new ObjectTypeNode( idGenerator.getNextId(),
                                                                  new ClassObjectType( String.class ),
                                                                  buildContext );

        final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( objectTypeNode );

        assertNotNull( memory );
    }
View Full Code Here

        /* should assert as ObjectType matches */
        objectTypeNode.assertObject( handle1,
                                     context,
                                     workingMemory );
        /* check asserted object was added to memory */
        final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( objectTypeNode );
        assertEquals( 1,
                      memory.size() );

        /* should retract as ObjectType matches */
        objectTypeNode.retractObject( handle1,
                                      context,
                                      workingMemory );
        /* check asserted object was removed from memory */
        assertEquals( 0,
                      memory.size() );

        /* make sure its just the handle1 for string1 that was propagated */
        final List retracted = sink.getRetracted();
        assertLength( 1,
                      retracted );
View Full Code Here

        assertTrue( ((InternalFactHandle) ((Object[]) asserted.get( 0 ))[0]).getObject() instanceof ShadowProxy );
        assertEquals( cheese,
                      ((InternalFactHandle) ((Object[]) asserted.get( 0 ))[0]).getObject() );

        // check asserted object was added to memory
        final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( objectTypeNode );
        assertEquals( 1,
                      memory.size() );
        assertTrue( memory.contains( handle1 ) );
    }
View Full Code Here

        assertTrue( ((InternalFactHandle) ((Object[]) asserted.get( 0 ))[0]).getObject() instanceof ShadowProxy );
        assertEquals( ((InternalFactHandle) ((Object[]) asserted.get( 0 ))[0]).getObject(),
                      person );

        // check asserted object was added to memory
        final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( objectTypeNode );
        assertEquals( 1,
                      memory.size() );
        assertTrue( memory.contains( handle1 ) );
    }
View Full Code Here

            FactHandleMemory factHandleMemory;
            if ( config.isIndexRightBetaMemory() ) {
                factHandleMemory = new FactHandleIndexHashTable( indexes );
            } else {
                factHandleMemory = config.isSequential() ? (FactHandleMemory) new FactList() : (FactHandleMemory) new FactHashTable();
            }
            memory = new BetaMemory( config.isSequential() ? null : tupleMemory,
                                     factHandleMemory );
        } else {
            memory = new BetaMemory( config.isSequential() ? null : new TupleHashTable(),
                                     config.isSequential() ? (FactHandleMemory) new FactList() : (FactHandleMemory) new FactHashTable() );
        }

        return memory;
    }
View Full Code Here

            FactHandleMemory factHandleMemory;
            if ( conf.isIndexRightBetaMemory() ) {
                factHandleMemory = new FactHandleIndexHashTable( indexes );
            } else {
                factHandleMemory = conf.isSequential() ? (FactHandleMemory) new FactList() : (FactHandleMemory) new FactHashTable();
            }
            memory = new BetaMemory( conf.isSequential() ? null : tupleMemory,
                                     factHandleMemory );
        } else {
            memory = new BetaMemory( conf.isSequential() ? null : new TupleHashTable(),
                                     conf.isSequential() ? (FactHandleMemory) new FactList() : (FactHandleMemory) new FactHashTable() );
        }

        return memory;
    }
View Full Code Here

TOP

Related Classes of org.drools.util.FactHashTable

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.