Package org.drools.rule

Examples of org.drools.rule.IndexableConstraint


        if ( sink.getType() ==  NodeTypeEnums.AlphaNode ) {
            final AlphaNode alphaNode = (AlphaNode) sink;
            final AlphaNodeFieldConstraint fieldConstraint = alphaNode.getConstraint();

            if ( fieldConstraint instanceof IndexableConstraint) {
                final IndexableConstraint indexableConstraint = (IndexableConstraint) fieldConstraint;

                if ( indexableConstraint.isIndexable(NodeTypeEnums.AlphaNode) && indexableConstraint.getField() != null &&
                        indexableConstraint.getFieldExtractor().getValueType() != ValueType.OBJECT_TYPE &&
                        // our current implementation does not support hashing of deeply nested properties
                        !( indexableConstraint.getFieldExtractor() instanceof MVELObjectClassFieldReader )) {
                    final InternalReadAccessor readAccessor = indexableConstraint.getFieldExtractor();
                    final int index = readAccessor.getIndex();
                    final FieldIndex fieldIndex = registerFieldIndex( index,
                                                                      readAccessor );

                    if ( fieldIndex.getCount() >= this.alphaNodeHashingThreshold && this.alphaNodeHashingThreshold != 0 ) {
                        if ( !fieldIndex.isHashed() ) {
                            hashSinks( fieldIndex );
                        }
                        final FieldValue value = indexableConstraint.getField();
                        // no need to check, we know  the sink  does not exist
                        this.hashedSinkMap.put( new HashKey( index,
                                                             value,
                                                             fieldIndex.getFieldExtractor() ),
                                                alphaNode,
View Full Code Here


        if ( sink.getType() ==  NodeTypeEnums.AlphaNode ) {
            final AlphaNode alphaNode = (AlphaNode) sink;
            final AlphaNodeFieldConstraint fieldConstraint = alphaNode.getConstraint();

            if ( fieldConstraint instanceof IndexableConstraint ) {
                final IndexableConstraint indexableConstraint = (IndexableConstraint) fieldConstraint;
                final FieldValue value = indexableConstraint.getField();

                if ( indexableConstraint.isIndexable(NodeTypeEnums.AlphaNode) && indexableConstraint.getField() != null &&
                        indexableConstraint.getFieldExtractor().getValueType() != ValueType.OBJECT_TYPE &&
                        // our current implementation does not support hashing of deeply nested properties
                        !( indexableConstraint.getFieldExtractor() instanceof MVELObjectClassFieldReader )) {
                    final InternalReadAccessor fieldAccessor = indexableConstraint.getFieldExtractor();
                    final int index = fieldAccessor.getIndex();
                    final FieldIndex fieldIndex = unregisterFieldIndex( index );

                    if ( fieldIndex.isHashed() ) {
                        HashKey hashKey = new HashKey( index,
View Full Code Here

        ObjectSinkNode currentSink = this.hashableSinks.getFirst();

        while ( currentSink != null ) {
            final AlphaNode alphaNode = (AlphaNode) currentSink;
            final AlphaNodeFieldConstraint fieldConstraint = alphaNode.getConstraint();
            final IndexableConstraint indexableConstraint = (IndexableConstraintfieldConstraint;

            // position to the next sink now because alphaNode may be removed if the index is equal. If we were to do this
            // afterwards, currentSink.nextNode would be null
            currentSink = currentSink.getNextObjectSinkNode();

            // only alpha nodes that have an Operator.EQUAL are in hashableSinks, so only check if it is
            // the right field index
            if ( index == indexableConstraint.getFieldExtractor().getIndex() ) {
                final FieldValue value = indexableConstraint.getField();
                this.hashedSinkMap.put( new HashKey( index,
                                                     value,
                                                     fieldReader ),
                                        alphaNode );
View Full Code Here

        final Iterator iter = this.hashedSinkMap.newIterator();
        ObjectHashMap.ObjectEntry entry = (ObjectHashMap.ObjectEntry) iter.next();

        while ( entry != null ) {
            final AlphaNode alphaNode = (AlphaNode) entry.getValue();
            final IndexableConstraint indexableConstraint = (IndexableConstraint) alphaNode.getConstraint();

            // only alpha nodes that have an Operator.EQUAL are in sinks, so only check if it is
            // the right field index
            if ( index == indexableConstraint.getFieldExtractor().getIndex() ) {
                final FieldValue value = indexableConstraint.getField();
                if ( this.hashableSinks == null ) {
                    this.hashableSinks = new ObjectSinkNodeList();
                }
                this.hashableSinks.add( alphaNode );
View Full Code Here

    public BetaMemory createBetaMemory(final RuleBaseConfiguration config) {
        BetaMemory memory;

        final List list = new ArrayList( 2 );
        if ( this.indexed0 ) {
            final IndexableConstraint indexableConstraint = (IndexableConstraint) this.constraint0;
            final FieldIndex index = new FieldIndex( indexableConstraint.getFieldExtractor(),
                                                     indexableConstraint.getIndexingDeclaration(),
                                                     indexableConstraint.getIndexEvaluator() );
            list.add( index );

        }

        if ( this.indexed1 ) {
            final IndexableConstraint indexableConstraint = (IndexableConstraint) this.constraint1;
            final FieldIndex index = new FieldIndex( indexableConstraint.getFieldExtractor(),
                                                     indexableConstraint.getIndexingDeclaration(),
                                                     indexableConstraint.getIndexEvaluator() );
            list.add( index );
        }

        if ( !list.isEmpty() ) {
            final FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
View Full Code Here

            LinkedListEntry entry = (LinkedListEntry) this.constraints.getFirst();
            final List list = new ArrayList();

            for ( int pos = 0; pos <= this.indexed; pos++ ) {
                final Constraint constraint = (Constraint) entry.getObject();
                final IndexableConstraint indexableConstraint = (IndexableConstraint) constraint;
                final FieldIndex index = new FieldIndex( indexableConstraint.getFieldExtractor(),
                                                         indexableConstraint.getIndexingDeclaration(),
                                                         indexableConstraint.getIndexEvaluator() );
                list.add( index );
                entry = (LinkedListEntry) entry.getNext();
            }

            final FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
View Full Code Here

        BetaMemory memory;

        final List list = new ArrayList( 2 );
        if ( this.indexed0 ) {
            final IndexableConstraint indexableConstraint = (IndexableConstraint) this.constraint0;
            final FieldIndex index = new FieldIndex( indexableConstraint.getFieldExtractor(),
                                                     indexableConstraint.getIndexingDeclaration(),
                                                     indexableConstraint.getIndexEvaluator() );
            list.add( index );

        }

        if ( this.indexed1 ) {
            final IndexableConstraint indexableConstraint = (IndexableConstraint) this.constraint1;
            final FieldIndex index = new FieldIndex( indexableConstraint.getFieldExtractor(),
                                                     indexableConstraint.getIndexingDeclaration(),
                                                     indexableConstraint.getIndexEvaluator() );
            list.add( index );
        }

        if ( this.indexed2 ) {
            final IndexableConstraint indexableConstraint = (IndexableConstraint) this.constraint2;
            final FieldIndex index = new FieldIndex( indexableConstraint.getFieldExtractor(),
                                                     indexableConstraint.getIndexingDeclaration(),
                                                     indexableConstraint.getIndexEvaluator() );
            list.add( index );
        }

        if ( !list.isEmpty() ) {
            final FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
View Full Code Here

    }

    public BetaMemory createBetaMemory(final RuleBaseConfiguration config) {
        BetaMemory memory;
        if ( this.indexed ) {
            final IndexableConstraint indexableConstraint = (IndexableConstraint) this.constraint;
            final FieldIndex index = new FieldIndex( indexableConstraint.getFieldExtractor(),
                                                     indexableConstraint.getIndexingDeclaration(),
                                                     indexableConstraint.getIndexEvaluator() );
            LeftTupleMemory tupleMemory;
            if ( this.conf.isIndexLeftBetaMemory() ) {
                tupleMemory = new LeftTupleIndexHashTable( new FieldIndex[]{index} );
            } else {
                tupleMemory = new LeftTupleList();
View Full Code Here

        BetaMemory memory;

        final List list = new ArrayList( 2 );
        if ( this.indexed0 ) {
            final IndexableConstraint indexableConstraint = (IndexableConstraint) this.constraint0;
            final FieldIndex index = new FieldIndex( indexableConstraint.getFieldExtractor(),
                                                     indexableConstraint.getIndexingDeclaration(),
                                                     indexableConstraint.getIndexEvaluator() );
            list.add( index );

        }

        if ( this.indexed1 ) {
            final IndexableConstraint indexableConstraint = (IndexableConstraint) this.constraint1;
            final FieldIndex index = new FieldIndex( indexableConstraint.getFieldExtractor(),
                                                     indexableConstraint.getIndexingDeclaration(),
                                                     indexableConstraint.getIndexEvaluator() );
            list.add( index );
        }

        if ( this.indexed2 ) {
            final IndexableConstraint indexableConstraint = (IndexableConstraint) this.constraint2;
            final FieldIndex index = new FieldIndex( indexableConstraint.getFieldExtractor(),
                                                     indexableConstraint.getIndexingDeclaration(),
                                                     indexableConstraint.getIndexEvaluator() );
            list.add( index );
        }

        if ( this.indexed3 ) {
            final IndexableConstraint indexableConstraint = (IndexableConstraint) this.constraint3;
            final FieldIndex index = new FieldIndex( indexableConstraint.getFieldExtractor(),
                                                     indexableConstraint.getIndexingDeclaration(),
                                                     indexableConstraint.getIndexEvaluator() );
            list.add( index );
        }

        if ( !list.isEmpty() ) {
            final FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
View Full Code Here

            private int determineTypeWithEqualityPriority(short nodeType, BetaNodeFieldConstraint[] constraints) {
                int indexedConstraintPos = 0;
                for (int i = 0; i < constraints.length; i++) {
                    if (constraints[i] instanceof IndexableConstraint) {
                        IndexableConstraint indexableConstraint = (IndexableConstraint) constraints[i];
                        ConstraintType type = indexableConstraint.getConstraintType();
                        if (type == ConstraintType.EQUAL) {
                            constraintType = type;
                            return i;
                        } else if (constraintType == ConstraintType.UNKNOWN && type.isIndexableForNode(nodeType)) {
                            constraintType = type;
View Full Code Here

TOP

Related Classes of org.drools.rule.IndexableConstraint

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.