Examples of FactHashTable


Examples of org.drools.util.FactHashTable

                             final PropagationContext context,
                             final InternalWorkingMemory workingMemory) throws FactException {
        if ( this.constraint.isAllowed( handle.getObject(),
                                        workingMemory ) ) {
            if ( isObjectMemoryEnabled() ) {
                final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
                memory.add( handle,
                            false );
            }

            this.sink.propagateAssertObject( handle,
                                             context,
View Full Code Here

Examples of org.drools.util.FactHashTable

    public void retractObject(final InternalFactHandle handle,
                              final PropagationContext context,
                              final InternalWorkingMemory workingMemory) {
        boolean propagate = true;
        if ( isObjectMemoryEnabled() ) {
            final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
            propagate = memory.remove( handle );
        } else {
            propagate = this.constraint.isAllowed( handle.getObject(),
                                                   workingMemory );
        }
        if ( propagate ) {
View Full Code Here

Examples of org.drools.util.FactHashTable

    }

    public void updateSink(final ObjectSink sink,
                           final PropagationContext context,
                           final InternalWorkingMemory workingMemory) {
        FactHashTable memory = null;

        if ( !isObjectMemoryEnabled() ) {
            // get the objects from the parent
            ObjectSinkUpdateAdapter adapter = new ObjectSinkUpdateAdapter( sink, this.constraint );
            this.objectSource.updateSink( adapter,
                                          context,
                                          workingMemory );
        } else {
            // if already has memory, just iterate and propagate
            memory = (FactHashTable) workingMemory.getNodeMemory( this );
            final Iterator it = memory.iterator();
            for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
                sink.assertObject( entry.getFactHandle(),
                                   context,
                                   workingMemory );
            }
View Full Code Here

Examples of org.drools.util.FactHashTable

    /**
     * Creates a HashSet for the AlphaNode's memory.
     */
    public Object createMemory(final RuleBaseConfiguration config) {
        return new FactHashTable();
    }
View Full Code Here

Examples of org.drools.util.FactHashTable

        for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
            ObjectTypeConf objectTypeConf = (ObjectTypeConf) entry.getValue();
            if ( newObjectType.isAssignableFrom( objectTypeConf.getConcreteObjectTypeNode().getObjectType() ) ) {
                objectTypeConf.resetCache();
                ObjectTypeNode sourceNode = objectTypeConf.getConcreteObjectTypeNode();
                FactHashTable table = (FactHashTable) workingMemory.getNodeMemory( sourceNode );
                Iterator factIter = table.iterator();
                for ( FactEntry factEntry = (FactEntry) factIter.next(); factEntry != null; factEntry = (FactEntry) factIter.next() ) {
                    sink.assertObject( factEntry.getFactHandle(),
                                       context,
                                       workingMemory );
                }
View Full Code Here

Examples of org.drools.util.FactHashTable

            // we do this after the shadowproxy update, just so that its up to date for the future
            return;
        }

        if ( this.objectMemoryEnabled) {
            final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
            memory.add( handle,
                        false );
        }

        this.sink.propagateAssertObject( handle,
                                         context,
View Full Code Here

Examples of org.drools.util.FactHashTable

        if ( context.getType() == PropagationContext.MODIFICATION && this.skipOnModify && context.getDormantActivations() == 0 ) {
            return;
        }

        final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
        memory.remove( handle );

        this.sink.propagateRetractObject( handle,
                                          context,
                                          workingMemory,
                                          true );
View Full Code Here

Examples of org.drools.util.FactHashTable

    }

    public void updateSink(final ObjectSink sink,
                           final PropagationContext context,
                           final InternalWorkingMemory workingMemory) {
        final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
        final Iterator it = memory.iterator();
        for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
            sink.assertObject( entry.getFactHandle(),
                               context,
                               workingMemory );
        }
View Full Code Here

Examples of org.drools.util.FactHashTable

     * Creates memory for the node using PrimitiveLongMap as its optimised for storage and reteivals of Longs.
     * However PrimitiveLongMap is not ideal for spase data. So it should be monitored incase its more optimal
     * to switch back to a standard HashMap.
     */
    public Object createMemory(final RuleBaseConfiguration config) {
        return new FactHashTable();
    }
View Full Code Here

Examples of org.drools.util.FactHashTable

        final DefaultFactHandle f0 = new DefaultFactHandle( 0,
                                                            cheddar );

        // check alpha memory is empty
        final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( alphaNode );
        assertEquals( 0,
                      memory.size() );

        // object should assert as it passes text
        alphaNode.assertObject( f0,
                                context,
                                workingMemory );

        assertEquals( 0,
                      memory.size() );

        final DefaultFactHandle f1 = new DefaultFactHandle( 1,
                                                            new Cheese( "brie",
                                                                        10 ) );

        // object should NOT retract as it doesn't exist
        alphaNode.retractObject( f1,
                                 context,
                                 workingMemory );

        // without memory, it will always propagate a retract
        assertLength( 0,
                      sink.getRetracted() );
        assertEquals( 0,
                      memory.size() );
        assertFalse( "Should not contain 'cheddar handle'",
                     memory.contains( f0 ) );

        // object should retract as it does exist
        alphaNode.retractObject( f0,
                                 context,
                                 workingMemory );

        assertLength( 1,
                      sink.getRetracted() );
        assertEquals( 0,
                      memory.size() );
        final Object[] list = (Object[]) sink.getRetracted().get( 0 );
        assertSame( f0,
                    list[0] );

    }
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.