Examples of InternalReadAccessor


Examples of org.drools.spi.InternalReadAccessor

            String readMethod = declaration.getNativeReadMethodName();
            boolean isObject = readMethod.equals("getValue");
            String returnedType = isObject ? "Ljava/lang/Object;" : typeDescr(declarationType);
            mv.visitMethodInsn(INVOKEVIRTUAL, "org/drools/rule/Declaration", readMethod, "(Lorg/drools/common/InternalWorkingMemory;Ljava/lang/Object;)" + returnedType);
            if (isObject) {
                InternalReadAccessor extractor = declaration.getExtractor();
                if (extractor != null) {
                    cast(extractor.getExtractToClass());
                }
            }
            return store(registry, declarationType);
        }
View Full Code Here

Examples of org.drools.spi.InternalReadAccessor

                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 MVELClassFieldReader )) {
                    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() ) {
View Full Code Here

Examples of org.drools.spi.InternalReadAccessor

                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 MVELClassFieldReader )) {
                    final InternalReadAccessor fieldAccessor = indexableConstraint.getFieldExtractor();
                    final int index = fieldAccessor.getIndex();
                    final FieldIndex fieldIndex = unregisterFieldIndex( index );

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

Examples of org.drools.spi.InternalReadAccessor

        if ( this.hashedSinkMap == null ) {
            this.hashedSinkMap = new ObjectHashMap();
        }

        final int index = fieldIndex.getIndex();
        final InternalReadAccessor fieldReader = fieldIndex.getFieldExtractor();

        ObjectSinkNode currentSink = this.hashableSinks.getFirst();

        while ( currentSink != null ) {
            final AlphaNode alphaNode = (AlphaNode) currentSink;
View Full Code Here

Examples of org.drools.spi.InternalReadAccessor

                                                                                              Collections.EMPTY_MAP,
                                                                                              Collections.EMPTY_MAP,
                                                                                              type.getTypeClass() ) );

            if ( results != null ) {
                InternalReadAccessor reader = pkg.getClassFieldAccessorStore().getMVELReader( ClassUtils.getPackage(type.getTypeClass()),
                                                                                              type.getTypeClass().getName(),
                                                                                              timestamp,
                                                                                              type.isTypesafe(),
                                                                                              results.getReturnType() );

                MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData( "mvel" );
                data.addCompileable( (MVELCompileable) reader );
                ( (MVELCompileable) reader ).compile( data );
                type.setTimestampExtractor( reader );
            } else {
                this.results.add( new TypeDeclarationError( typeDescr,
                                                            "Error creating field accessors for timestamp field '" + timestamp +
                                                            "' for type '" +
                                                            type.getTypeName() +
                                                            "'" ) );
            }
        }

        annotationDescr = typeDescr.getAnnotation( TypeDeclaration.ATTR_DURATION );
        String duration = ( annotationDescr != null ) ? annotationDescr.getSingleValue() : null;
        if (duration != null) {
            type.setDurationAttribute( duration );
            Package pkg = pkgRegistry.getPackage();
           
            MVELDialect dialect = ( MVELDialect ) pkgRegistry.getDialectCompiletimeRegistry().getDialect( "mvel" );           
            PackageBuildContext context = new PackageBuildContext();           
            context.init( this, pkg, typeDescr, pkgRegistry.getDialectCompiletimeRegistry(), dialect, null );
            if ( !type.isTypesafe() ) {
                context.setTypesafe( false );
            }
           
            MVELAnalysisResult results = ( MVELAnalysisResult )
                                context.getDialect().analyzeExpression( context,
                                                                        typeDescr,
                                                                        duration,
                                                                        new BoundIdentifiers( Collections.EMPTY_MAP,
                                                                                              Collections.EMPTY_MAP,
                                                                                              Collections.EMPTY_MAP,
                                                                                              type.getTypeClass() ) );           

            if (results != null) {
                InternalReadAccessor reader = pkg.getClassFieldAccessorStore().getMVELReader( ClassUtils.getPackage( type.getTypeClass() ),
                                                                                              type.getTypeClass().getName(),
                                                                                              duration,
                                                                                              type.isTypesafe(),
                                                                                              results.getReturnType()  );
View Full Code Here

Examples of org.drools.spi.InternalReadAccessor

        Accumulator[] accumulators;
        List<AccumulateFunctionCallDescr> functions = accumDescr.getFunctions();

        accumulators = new Accumulator[functions.size()];
        // creating the custom array reader
        InternalReadAccessor arrayReader = new SelfReferenceClassFieldReader( Object[].class,
                                                                              "this" );

        int index = 0;
        Pattern pattern = (Pattern) context.getBuildStack().peek();
        for ( AccumulateFunctionCallDescr func : functions ) {
View Full Code Here

Examples of org.drools.spi.InternalReadAccessor

        // set of required previous declarations
        Set<Declaration> requiredDecl = new HashSet<Declaration>();

        // creating the custom array reader
        InternalReadAccessor arrayReader = new SelfReferenceClassFieldReader( Object[].class,
                                                                              "this" );

        int index = 0;
        Pattern pattern = (Pattern) context.getBuildStack().peek();
        for ( AccumulateFunctionCallDescr fc : funcCalls ) {
View Full Code Here

Examples of org.drools.spi.InternalReadAccessor

           
            ClassFieldAccessorStore store = (ClassFieldAccessorStore) context.get( "ClassFieldAccessorStore" );
           
           

            InternalReadAccessor extractor = null;
            if ( field.startsWith( "[" ) ) {
                extractor = store.getReader( ArrayElements.class,
                                             "elements",
                                             getClass().getClassLoader() );
               
View Full Code Here

Examples of org.drools.spi.InternalReadAccessor

                          ValueType.OBJECT_TYPE );
    }

    private void runEvaluatorTest(final Object[][] data,
                                  final ValueType valueType) {
        final InternalReadAccessor extractor = new MockExtractor();
        for ( int i = 0; i < data.length; i++ ) {
            final Object[] row = data[i];
            boolean isNegated = ((String) row[1]).startsWith( "not " );
            // System.out.println((String) row[1]);
            String evaluatorStr = isNegated ? ((String) row[1]).substring( 4 ) : (String) row[1];
View Full Code Here

Examples of org.drools.spi.InternalReadAccessor

        store.setEagerWire( true );
    }

    @Test
    public void testSingleEntry() throws Exception {
        final InternalReadAccessor extractor = store.getReader( Cheese.class,
                                                                "type",
                                                                getClass().getClassLoader() );

        final Pattern pattern = new Pattern( 0,
                                             new ClassObjectType( Cheese.class ) );
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.