Package com.mobixess.jodb.core.index

Examples of com.mobixess.jodb.core.index.IndexDataIterator


        }else{
            sortDataCache.clearAll();
            sortDataCache = null;
        }
        JODBOperationContext context = new JODBOperationContext(_session,ticket,sortDataCache,null,null,excludedObjects,true);
        IndexDataIterator indexIterator = null;
        boolean skipConventionalSorting = false;

        FieldRecord indexDataIteratorFieldRecord = null;//used for iteraion through indexed data
        QueryNode indexedNode = null;
        TypeConstraint typeConstraint = null;
        try{
           
            Vector<ConstraintBase> vectorOfConstraints = _constraints._constraints;
            for (int i = 0; i < vectorOfConstraints.size(); i++) {
                ConstraintBase nextCandidate = vectorOfConstraints.elementAt(i);
                if(nextCandidate instanceof TypeConstraint){
                    if(typeConstraint == null){
                        typeConstraint = (TypeConstraint) nextCandidate;
                    }else{
                        typeConstraint = null;//multiple type constraints
                        break;
                    }
                }
            }
           
            if(typeConstraint != null){
                //boolean useIndexDataFromIterator = false;
                JODBIndexingRootAgent indexingRootAgent = _session.getIndexingRootAgent();
                ClassDescriptor classDescriptor = _session.getDescriptorForClass((Class)typeConstraint.getObject());
                JODBIndexingAgent indexingAgent = null;
                if(sortDataCache!=null){
                    //lookup indexing data to optimize query
                    SortNodeRecord[] sortRecords = sortDataCache.getSortNodes();
                    int fieldId = classDescriptor.getFieldIDForName(sortRecords[0]._fullPath);
                    if(fieldId!=-1){
                        indexingAgent = indexingRootAgent.getIndexingAgent(fieldId, base);
                        if(indexingAgent!=null){
                            indexIterator = indexingAgent.getIndexIterator(sortRecords[0]._orderAscending);
                            indexedNode = _descendants.get(sortRecords[0]._fullPath);
                            skipConventionalSorting = sortRecords.length == 1;
                        }
                    }
                }
                if(indexIterator == null){
                    //search first index
                    Iterator<String> descendants = _descendants.keySet().iterator();
                    while (descendants.hasNext() && indexIterator == null) {
                        String next = descendants.next();
                        Field field = classDescriptor.getFieldForName(next);
                        if(field==null){
                            continue;
                        }
                        indexingAgent = indexingRootAgent.getIndexingAgent(field, base);
                        if(indexingAgent!=null){
                            indexIterator = indexingAgent.getIndexIterator(true);
                            indexedNode = _descendants.get(next);
                        }
                    }
                }
                if(indexingAgent!=null && indexedNode != null){
                    Field field = classDescriptor.getFieldForID(indexingAgent.getFieldId(), null);
                    Class fieldType = field.getType();                       
                    if(fieldType.isPrimitive()){
                        indexDataIteratorFieldRecord = new FieldRecord();
                        indexDataIteratorFieldRecord._fieldID = indexingAgent.getFieldId();
                        indexDataIteratorFieldRecord._category = FIELD_CATEGORIES.PRIMITIVE;
                        indexDataIteratorFieldRecord._fieldTypeID = base.getClassTypeSubstitutionID(fieldType.getName());
                    }
                }
            }
            if(indexIterator==null){
                indexIterator = new LArrayIndexIterator(base.getForAllObjects(ticket));
            }

            LArrayChunkedBuffer acceptedIds = new LArrayChunkedBuffer();

            while (indexIterator.hasNext()) {
                resetStateOfConstraints();
                CONSTRAINT_EVALUATION_STATUS status = CONSTRAINT_EVALUATION_STATUS.UNKNOWN;
                long nextObjectId;
                if(indexDataIteratorFieldRecord!=null){
                    indexDataIteratorFieldRecord._primitiveRawDataBuffer.clear();
                    nextObjectId = indexIterator.next(indexDataIteratorFieldRecord._primitiveRawDataBuffer);
                    if(excludedObjects!=null && excludedObjects.binarySearch(nextObjectId)>=0){
                        continue;
                    }
                    if(_session.getObjectFromCache(nextObjectId) == null){
                        //do not analize active objects
                        indexDataIteratorFieldRecord._primitiveRawDataBuffer.flip();
                        if(sortDataCache!=null){
                            sortDataCache.setCandidateID(nextObjectId);
                        }
                        indexedNode.analize(-1, indexDataIteratorFieldRecord, context);
                        typeConstraint.setStatus(CONSTRAINT_EVALUATION_STATUS.ACCEPTED);
                        _constraints.markExistanceConstrantAsAccepted();
                        indexedNode._constraints.markExistanceConstrantAsAccepted();
                        status = getCumulativeStatus();
                    }
                }else{
                    nextObjectId = indexIterator.next();
                    if(excludedObjects!=null && excludedObjects.binarySearch(nextObjectId)>=0){
                        continue;
                    }
                }
                if(status == CONSTRAINT_EVALUATION_STATUS.UNKNOWN){
View Full Code Here


            while (predicateSubjectAccessedFields.hasNext() && indexingAgent == null) {
                indexingAgent = indexingRootAgent.getIndexingAgent(predicateSubjectAccessedFields.next(), session.getBase());
            }
            ByteBuffer indexDataBuffer = null;
            int indexField = -1;
            IndexDataIterator indexIterator = null;
            if(indexingAgent!=null){
                indexField = indexingAgent.getFieldId();
                indexDataBuffer = ByteBuffer.allocate(16);
                indexIterator = indexingAgent.getIndexIterator(true);
            }
           
            if(indexIterator==null){
                indexIterator = new LArrayIndexIterator(base.getForAllObjects(ticket));
            }

            SyntheticSubject syntheticSubjectPrev = null;
            COMPARISON_STATE comparison_state= COMPARISON_STATE.UNKNOWN;
            LArrayChunkedBuffer acceptedIdsBuffer = new LArrayChunkedBuffer();
            while (indexIterator.hasNext()) {
                if(indexDataBuffer != null){
                    indexDataBuffer.clear();
                }
                long nextObjectId = indexIterator.next(indexDataBuffer);

                if(!syntheticSubject.setObjectData(nextObjectId, indexField, indexDataBuffer)){
                    continue;
                }
View Full Code Here

                        indexingAgent = indexingRootAgent.getIndexingAgent(fieldId, session.getBase());
                    }
                }
            }

            IndexDataIterator indexIterator = null;
            if(indexingAgent!=null){
                indexIterator = indexingAgent.getIndexIterator(true);
            }
           
            if(indexIterator==null){
                indexIterator = new LArrayIndexIterator(base.getForAllObjects(ticket));
            }

            COMPARISON_STATE comparison_state= COMPARISON_STATE.UNKNOWN;
            LArrayChunkedBuffer acceptedIdsBuffer = new LArrayChunkedBuffer();
            Object previous = null;
            while (indexIterator.hasNext()) {

                long nextObjectId = indexIterator.next(null);
               
                Object obj = session.getObjectForOffset(nextObjectId, JODBConfig.getDefaultActivationDepth());
                //TODO make configurable upon analysis
               
                if(!obj.getClass().isAssignableFrom(predicateSubjectClass)){
View Full Code Here

TOP

Related Classes of com.mobixess.jodb.core.index.IndexDataIterator

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.