Package com.mobixess.jodb.core.index

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


           
            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());
                    }
                }
            }
View Full Code Here


                Vector<IndexingRecord> indexingRecords = tHandle.getIndexes();
                if (indexingRecords != null) {
                    for (int i = 0; i < indexingRecords.size(); i++) {
                        IndexingRecord record = indexingRecords.elementAt(i);
                        ByteBuffer currentValue = record.getPersistedDataBuffer();
                        JODBIndexingAgent indexingAgent = record.getIndexingAgent();
                        if (currentValue.limit() != 0 && !indexingAgent.removeIndex(offsetId, currentValue, null)) {
                            throw new JodbIOException("Illegal index state: can't remove index");
                        }
                        ByteBuffer pendingValue = record.getPendingDataBuffer();
                        if (pendingValue.limit() == 0) {
                            throw new JodbIOException(
                                    "indexing value unavailable for " + offsetId);
                        }
                        indexingAgent.insertIndex(offsetId, pendingValue, context);
                        if(!_agentsTransactionObjects.containsKey(indexingAgent)){
                            try {
                                set(indexingAgent, Integer.MAX_VALUE);
                            } catch (Exception e) {
                                throw new JodbIOException(e);
View Full Code Here

                if(ascending){
                    if( prev.getVal2() > current.getVal2() ){
                        throw new RuntimeException();
                    }
                }else if(prev.getVal2() < current.getVal2() ){
                    JODBIndexingAgent indexingAgent = sessionContainer.getIndexingAgent(ObjectA.class.getDeclaredField("_val2") );
                    long prevID = sessionContainer.getPersistenceStatistics(prev).getObjectID();
                    long currentID = sessionContainer.getPersistenceStatistics(current).getObjectID();
                    int prevPosition = indexingAgent.linearIdSearch(prevID);
                    int currentPosition = indexingAgent.linearIdSearch(currentID);
                    throw new RuntimeException(""+prevID+"  "+prevPosition+"  "+ currentID+"  "+currentPosition);
                }
            }
            prev = current;
        }
       
       
        //System.err.println("_________________________________________________________");
        //sessionContainer.printFileMap();
       
        list = sessionContainer.getAllObjects();
       
        int total = list.size();
        for (int i = 0; i < total; i++) {
            ObjectA nextObj = (ObjectA) list.get(i);
            nextObj.setVal2((short) i);
            sessionContainer.set(nextObj);
        }
       
        sessionContainer.commit();
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
       
        query = sessionContainer.query();
        query.constrain(ObjectA.class);
        if(ascending){
            query.descend("_val2").orderAscending();
        }else{
            query.descend("_val2").orderDescending();
        }
       
        list = (JODBQueryList) query.execute();
        if(list.size() == 0){
            throw new RuntimeException();
        }
       
        prev = null;
        for (int i = 0; i < list.size(); i++) {
            //System.err.println("Indexing Random test iter1 #="+i);
            ObjectA current = (ObjectA) list.get(i);
            if(prev!=null){
                if(ascending){
                    if( prev.getVal2() > current.getVal2() ){
                        throw new RuntimeException();
                    }
                }else if(prev.getVal2() < current.getVal2() ){
                    JODBIndexingAgent indexingAgent = sessionContainer.getIndexingAgent(ObjectA.class.getDeclaredField("_val2") );
                    long prevID = sessionContainer.getPersistenceStatistics(prev).getObjectID();
                    long currentID = sessionContainer.getPersistenceStatistics(current).getObjectID();
                    int prevPosition = indexingAgent.linearIdSearch(prevID);
                    int currentPosition = indexingAgent.linearIdSearch(currentID);
                    throw new RuntimeException(" i="+i+" -->"+prevID+"  "+prevPosition+"  "+prev.getVal2()+" "+ currentID+"  "+currentPosition+" "+current.getVal2());
                }
            }
            prev = current;
        }
View Full Code Here

        }

        public void onCommitStarted(Object objectToBeCommited, JODBSession session) {
            try {
                JODBIndexingRootAgent agent = session.getIndexingRootAgent();
                JODBIndexingAgent indexingAgent = agent.getIndexingAgent(_indexingField, session.getBase());
               
                System.err.println("Commit started for object ");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
View Full Code Here

    public void configureIndex(Field field, boolean enable) throws IOException{
        if(!_transactionContainer.isEmpty()){
            throw new IllegalStateException("Cannot create index with transaction in progress");
        }
        JODBIndexingRootAgent indexingRootAgent = _session.getIndexingRootAgent();
        JODBIndexingAgent indexingAgent = indexingRootAgent.getIndexingAgent(field, _base);
        if((indexingAgent!=null && enable)|| (indexingAgent == null && !enable) ){
            return;
        }
       
        IOTicket writeTicket = _base.getIOTicket(true, true);
View Full Code Here

                //(Comparator) session.getDescriptorForClass(syntheticComparatorClass).newInstance();
            }
           
            //int[] predicateSubjectFields = loader.getPredicateSubjectFields();
            JODBIndexingRootAgent indexingRootAgent = session.getIndexingRootAgent();
            JODBIndexingAgent indexingAgent = null;
            Iterator<Integer> predicateSubjectAccessedFields = loader.getAccessedPredicateSubjectFields();
            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));
            }
View Full Code Here

           
            Class predicateSubjectClass = loader.getPredicateSubjectClass();

            JODBIndexingRootAgent indexingRootAgent = session.getIndexingRootAgent();
            JODBIndexingAgent indexingAgent = null;
            Iterator<Integer> predicateSubjectAccessedFields = loader.getAccessedPredicateSubjectFields();
            if(predicateSubjectAccessedFields != null){
                while (predicateSubjectAccessedFields.hasNext() && indexingAgent == null) {//TODO may be useless if analysis incomplete
                    Integer fieldId = predicateSubjectAccessedFields.next();
                    if(fieldId!=null){
                        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));
            }
View Full Code Here

TOP

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

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.