Package com.mobixess.jodb.core.io

Examples of com.mobixess.jodb.core.io.IOBase


    public int getNextMasterNodeSortCounter() {
        return _masterNodeSortCounter++;
    }

    public ObjectSet execute() throws IOException, IllegalClassTypeException {
        IOBase base = _session.getBase();
        return base.executeQuery(this);
    }
View Full Code Here


        return runQuery(null,null);
    }
   

    public JODBQueryList runQuery(LongVector excludedObjects, LongVector dynamicLongArray) throws IOException, IllegalClassTypeException{
        IOBase base = _session.getBase();
        IOTicket ticket = base.getIOTicket(true, false);
        SortDataCache sortDataCache = new SortDataCache();
        initSortDataCache(sortDataCache, new StringBuffer());
        if(sortDataCache.getSortNodesCacheSize()>0){
            sortDataCache.setValuesAccumulationMode();
        }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()) {
View Full Code Here

            _constraints.evaluatePersistentCopy(classDescriptor, null, null, context);
            return getCumulativeStatus();
        }
        DataContainersCache dataContainersCache = TransactionUtils.getObjectDataContainerCache();
        ObjectDataContainer dataContainer = dataContainersCache.pullObjectDataContainer();
        IOBase base = _session.getBase();
        IOTicket ticket = base.getIOTicket(true, true);
        try {//TODO need handling for arrays
            dataContainer.readObject(ticket.getRandomAccessBuffer(), base, context.getSession(), objectOffset, true);
            return analize(classDescriptor, dataContainer, context);
        } finally {
            TransactionUtils.getObjectDataContainerCache().pushObjectDataContainer(dataContainer);
View Full Code Here

        if(activeObject!=null){
            readSortData(activeObject, null, sortDataCache, context);
            return;
        }
       
        IOBase base = context.getBase();
        DataContainersCache dataContainersCache = TransactionUtils.getObjectDataContainerCache();
        ObjectDataContainer dataContainer = dataContainersCache.pullObjectDataContainer();
        IOTicket ticket = context.getIoTicket();
        try {
            dataContainer.readObject(ticket.getRandomAccessBuffer(), base, context.getSession(), objectID, true);
View Full Code Here

            FieldsIterator fieldsIterator = dataContainer.getActiveFieldsIterator();
            if(fieldsIterator == null){
                return;//TODO add warning?
            }
            FieldRecord iterratorFieldRecord = dataContainer.getRecordCache();
            IOBase base = context.getBase();
            while(fieldsIterator.hasNext()){
                fieldsIterator.next(iterratorFieldRecord, context.getBase(),false);
                QueryNode descendant = _descendants.get(base.getSimpleFieldNameForID(iterratorFieldRecord._fieldID));
                if(descendant!=null && descendant.hasSortInstructions()){
                    descendant.readSortData(null, iterratorFieldRecord, sortDataCache, context);
                }
                if(sortDataCache.isValuesAccumulationComplete()){
                    return;
View Full Code Here

    public static Object launchObject(JODBSession session, long offset, Object activationInstance, int remainingDepth) throws IOException{
        if(remainingDepth < 0 || offset == 0){
            return null;
        }
        IOBase base = session.getBase();
        boolean delayedActivation = activationInstance != null;
        Object instance;
        if (!delayedActivation) {//this is user's requested activation call, instance already exist
            instance = session.getObjectFromCache(offset);
            if (instance != null) {
                return instance;
            }
        }else{
            instance = activationInstance;
        }
        OperationContextTicketCache contextTicketCache = _threadLocalTicketCacheHolder.get();
        IOTicket ioTicket = contextTicketCache.getTicketForRead(base);//base.getIOTicket(true, false);
        try{
            ioTicket.lock(false);
            DataContainersCache dataContainersCache = getObjectDataContainerCache();
            ObjectDataContainer objectDataContainer = dataContainersCache.pullObjectDataContainer();
            FieldsIterator fieldsIterator = objectDataContainer.readObject(ioTicket.getRandomAccessBuffer(),base, session, offset, true);
            ClassDescriptor classDescriptor = objectDataContainer.getClassDescriptorForPersistedObject();
            if (classDescriptor == null || fieldsIterator == null) {
                // basically same as >>objectDataContainer.isDeleted()<< or no class available for persistent copy
                return null;
            }
            IClassProcessor processor;
            if (!delayedActivation) {
                int classTypeId = objectDataContainer.getOriginalClassType();
                String className = base.getClassTypeForID(classTypeId);
                Class clazz;
                try {
                    clazz = session.resolveClassForName(className);
                } catch (ClassNotFoundException e) {
                    return null;
View Full Code Here

        tContainer.fireOnCommitStarted(rootObject, context.getSession());
        if(tHandle.is_DELETE_Transaction()){
            deleteObject(ioTicket, session, tHandle, tContainer);
            return -1;
        }
        IOBase base = ioTicket.getBase();
       
       
        IClassProcessor classProcessor = JODBPluginRegistry.getInstance().getClassProcessor(rootObject.getClass());
       
        Object objectToPersist = classProcessor.translate(rootObject);
       
        ClassDescriptor classDescr = session.getDescriptorForClass(objectToPersist.getClass());
        FieldAndIDRecord[] fields = classDescr.getAllFields();
       
        Vector<IndexingRecord> indexes = null;
       
        Class rootObjectType = rootObject.getClass();
        int rootObjectClassID;
        if(rootObjectType.isArray()){
            rootObjectClassID = base.getOrSetClassTypeSubstitutionID(rootObjectType.getComponentType().getName());
        }else{
            rootObjectClassID = base.getOrSetClassTypeSubstitutionID(rootObjectType.getName());
            indexes = TransactionUtils.getObjectDataContainerCache().pullVector();
            JODBIndexingRootAgent indexingAgent = context.getIndexingRootAgent();
            indexingAgent.getAgentsForClassId(indexes, rootObjectClassID);
            if(indexes.size() == 0){
                //no indexes for this class
                TransactionUtils.getObjectDataContainerCache().pushVector(indexes);
                indexes = null;
            }
        }
        tHandle.setIndexes(indexes);
        //String[] classTypes = classDescr.getTypes();
       
        if( checkActiveObjectUnchanged(classProcessor, context, objectToPersist, tHandle, persistentCopyObjectDataContainer, indexes) ){//should not happen in recursive sub call
            tHandle.setIndexes(null);//reset indexes info in handle to prevent post processing
            long offset = tHandle.getHandle().getObjectEntryOffset();//JODBIOUtils.addAbsoluteOffsetIdentifierBit(tHandle.getHandle().getObjectEntryOffset());
            tHandle.setTransactionOffset(offset);
            if( classDescr.isArray()){
                if(classDescr.isPrimitiveArray()){
                    return offset;
                }
                int arrayLen = Array.getLength(objectToPersist);
                for (int i = 0; i < arrayLen; i++) {
                    Object childObj = Array.get(objectToPersist, i);
                    if(childObj == null || transactionObjects.get(childObj) == null){
                        continue;
                    }
                    assembleTransactionDataForObject(context, childObj, tContainer);
                }
            } else {
                try {
                    for (int i = 0; i < fields.length; i++) {
                        Field field = fields[i]._field;
                        if (field.getType().isPrimitive()) {
                            continue;
                        }
                        Object childObj = field.get(objectToPersist);
                        if (childObj == null || transactionObjects.get(childObj) == null){
                            continue;
                        }
                        assembleTransactionDataForObject(context, childObj, tContainer);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new JodbIOException(e);
                }
            }           
            return offset;
        }
       
        IRandomAccessDataBuffer transactionFile = tContainer.getTransactionNewDataFile();
        transactionFile.resetToEnd();
       
        Vector<ObjectFieldRecord> fieldsWithAbsoluteAddr = new Vector<ObjectFieldRecord>();
        Vector<ObjectFieldRecord> fieldsWithRelativeAddr = new Vector<ObjectFieldRecord>();
        Vector<Field> primitiveFields = new Vector<Field>();
       
        if(!classDescr.isArray()){
            classifyFields(objectToPersist, classDescr, transactionObjects, fieldsWithAbsoluteAddr, fieldsWithRelativeAddr, primitiveFields);
        }
       
       
        long objectIDOffset = transactionFile.getCursorOffset();
       
        tHandle.setTransactionOffset(objectIDOffset);

        if(JODBConfig.DEBUG){
            _logger.info(" >>> Transaction: Object "+rootObject.getClass()+" "+rootObject+" start offset ="+objectIDOffset);
        }
       
        boolean translated = rootObject!=objectToPersist;
        byte arrayElementSize = 0;
        long lengthEstimate;
        if(!classDescr.isArray()){
            lengthEstimate = estimateObjectLength(tHandle, fieldsWithAbsoluteAddr.size(), fieldsWithRelativeAddr.size(), classDescr, translated);
        }else{
            ByteHolder byteHolder = new ByteHolder();
            lengthEstimate = estimateArrayObjectLength(context, tHandle, objectToPersist, classDescr, byteHolder, translated);
            arrayElementSize = byteHolder._value;
        }
       
        int objId = composeEntryID( JODBIOBase.ENTRY_OBJECT_ID, lengthEstimate);
        int objIdWithRedirectionBit = tHandle.isNewObject()? objId : JODBIOBase.addRedirectedObjectModifier(objId);
        transactionFile.writeShort(objIdWithRedirectionBit);
        writeEntryLenForID(objId,0,transactionFile);//reserve space for length
       
        long objectBodyOffset = transactionFile.getCursorOffset();
       
//        if(JODBConfig.DEBUG){
//            _logger.info("Transaction: Object "+rootObject.getClass()+" "+rootObject+" header len ="+headerLen);
//        }
       
        int primaryMask = formPrimaryObjectMask(0, fieldsWithAbsoluteAddr.size()>0, fieldsWithRelativeAddr.size()>0, primitiveFields.size()>0, translated, tHandle, classDescr);;
       
        transactionFile.writeByte(primaryMask);
       
        int secondaryMask = formSecondaryObjectMask(0, tHandle);
       
        transactionFile.writeByte(secondaryMask);
       
        short newCyclicCounter =  (short) (tHandle.getCyclicalVersionCounter()+1);
       
        if(newCyclicCounter == 256){
            newCyclicCounter = 0;
        }
        tHandle.setCyclicalVersionCounter(newCyclicCounter);
       
        transactionFile.writeByte(newCyclicCounter);
       
        tHandle.setTranslatedObjectDataMask((byte) primaryMask);
       
        //
        if(tHandle.generateUID()){
            Random random = new Random();
            transactionFile.writeLong(random.nextLong());
        }
        long time = System.currentTimeMillis();
        if(tHandle.generateCreationTS()){
            transactionFile.writeLong(time);
        }
        if(tHandle.generateModificationTS()){
            transactionFile.writeLong(time);
        }
       
        //
        transactionFile.writeShort(rootObjectClassID);
       
        if(translated){
            int translatedObjectClassID = base.getOrSetClassTypeSubstitutionID(classDescr.getTypes()[0]);// base.getOrSetClassTypeSubstitutionID( objectToPersist.getClass().getName());
            transactionFile.writeShort(translatedObjectClassID);
        }
       
//        transactionFile.writeShort(classTypes.length);
//       
//        for (int i = 0; i < classTypes.length; i++) {
//            int id = base.getOrSetClassTypeSubstitutionID(classTypes[i]);
//            transactionFile.writeShort(id);
//        }

        if(fieldsWithAbsoluteAddr.size()>0){//with absolute offsets
            transactionFile.writeShort(fieldsWithAbsoluteAddr.size());
            for (int i = 0; i < fieldsWithAbsoluteAddr.size(); i++) {//writing links of unchanged objects
                ObjectFieldRecord next = fieldsWithAbsoluteAddr.elementAt(i);
                int id = base.getOrSetFieldSubstitutionID(next._field);
                transactionFile.writeShort(id);
                TransactionHandle valueHandle = transactionObjects.get(next._value);
                transactionFile.writeLong(valueHandle.getHandle().getObjectEntryOffset());
            }
        }
       
        long objectsWithRelativeAddrStartOffsetShift = -1;
        if(fieldsWithRelativeAddr.size()>0){//with relative offsets
            transactionFile.writeShort(fieldsWithRelativeAddr.size());
            objectsWithRelativeAddrStartOffsetShift = transactionFile.getCursorOffset() - objectIDOffset;
            transactionFile.setLength(transactionFile.length()+ fieldsWithRelativeAddr.size()*(2+4));
            transactionFile.seek(transactionFile.length());
        }
       
        if(primitiveFields.size()>0){
            transactionFile.writeShort(primitiveFields.size());
        }
        for (int i = 0; i < primitiveFields.size(); i++) {
            Field next = primitiveFields.elementAt(i);
            int id = base.getOrSetFieldSubstitutionID(next);
            transactionFile.writeShort(id);
            IndexingRecord record = IndexingRecord.findIndexingRecord(id, indexes);
            if(record!=null){
                //ByteBuffer currentlyPersistedValue = record.getPersistedDataBuffer();
                ByteBuffer pendingValue = record.getPendingDataBuffer();
                pendingValue.clear();
                PrimitiveJavaTypesUtil.primitiveToByteBuffer(objectToPersist, next, pendingValue);
                pendingValue.flip();
                transactionFile.getChannel().write(pendingValue);
                pendingValue.rewind();
            }else {
                try {
                    Utils.writePrimitive(objectToPersist, next,transactionFile);
                } catch (Exception e) {
                    throw new JodbIOException(e);
                }
            }           
        }
       
        long arrayDataShift = 0;
        if(classDescr.isArray()){
            int arrayLength = Array.getLength(objectToPersist);
            transactionFile.writeInt(arrayLength);
            transactionFile.writeByte(arrayElementSize);//write length of each element in array
            arrayDataShift = transactionFile.getCursorOffset() - objectIDOffset;
            boolean primitive = classDescr.isPrimitiveArray();
            if(primitive){//completely write primitive array
                try {
                    Utils.writePrimitiveArray(objectToPersist, classDescr.getArrayType(), 0, arrayLength, transactionFile);
                } catch (Exception e) {
                    _logger.log(Level.SEVERE,"",e);
                    throw new JodbIOException(e);
                }
            }else{//reserve space for references
                long spaceToReserve = arrayElementSize*arrayLength;
                long slotMasksTotal = arrayLength/8;
                if( slotMasksTotal*8 != arrayLength){
                    slotMasksTotal++;//trailing mask entry for slot <8
                }
                spaceToReserve+=slotMasksTotal;
                if(transactionFile.getCursorOffset() + spaceToReserve > transactionFile.length()  ){
                    transactionFile.setLength(transactionFile.getCursorOffset() + spaceToReserve );
                }
                transactionFile.skip(spaceToReserve);
               
            }
        }
       
        if(JODBConfig.DEBUG){
            _logger.info(" <<< Transaction: Object "+rootObject.getClass()+" "+rootObject+" end offset ="+transactionFile.getCursorOffset());
        }
       
        long objectEndOffset = transactionFile.getCursorOffset();
        long objectBodyLength = objectEndOffset - objectBodyOffset;
        if(lengthEstimate < objectBodyLength){
            throw new JodbIOException("Object length estimate error");
        }
        //long targetObjectBodyLength = objectBodyLength;
       
        if(!tHandle.isNewObject()){
            DataContainersCache dataContainersCache = TransactionUtils.getObjectDataContainerCache();
            ObjectDataContainer existingObjectHeaderData =  dataContainersCache.pullObjectDataContainer();// tContainer.getTempObjectDataContainer();

            //ioTicket.getRandomAccessBuffer().seek(tHandle.getHandle().getObjectEntryOffset());
            //JODBIOUtils.readObjectHeader(ioTicket, existingObjectHeaderData, false);
            existingObjectHeaderData.readHeader(ioTicket.getRandomAccessBuffer(),tHandle.getHandle().getObjectEntryOffset(), false);
            tHandle.setTransactionOffset(existingObjectHeaderData.getOffset());//JODBIOUtils.addAbsoluteOffsetIdentifierBit(existingObjectHeaderData.getOffset()));//if object already existed than alvays point to initial object position
            long redirectorOffset = existingObjectHeaderData.isRedirection()?existingObjectHeaderData.getOffset():-1;
            if(objectBodyLength > existingObjectHeaderData.getBodyLength() || fieldsWithRelativeAddr.size() > 0 ){
                if( existingObjectHeaderData.isRedirection() ){
                    //redirection entry space is too small, let see what is under redirection offset
                    //ioTicket.getRandomAccessBuffer().seek(existingObjectHeaderData.getRedirectionOffset());
                    long existingObjectRedirectionOffset = existingObjectHeaderData.getRedirectionOffset();
                    existingObjectHeaderData.reset();
                    existingObjectHeaderData.readHeader(ioTicket.getRandomAccessBuffer(), existingObjectRedirectionOffset, true);
                    //JODBIOUtils.readObjectHeader(ioTicket, existingObjectHeaderData, true);
                }
            }

            if(objectBodyLength <= existingObjectHeaderData.getBodyLength() && fieldsWithRelativeAddr.size() == 0){
                boolean isRedirection = existingObjectHeaderData.isRedirection();
                long redirectionOffset = existingObjectHeaderData.getRedirectionOffset();
                //long targetObjectBodyLength = existingObjectHeaderData.getBodyLength();//length for new object's header
               
                //object id(length bits) may change as we fit to maybe bigger space
                objId = JODBIOBase.ENTRY_OBJECT_ID | existingObjectHeaderData.getLengthModifierFromID();// composeEntryID( JODBIOBase.ENTRY_OBJECT_ID, targetObjectBodyLength);
               
                if(existingObjectHeaderData.isRedirectedObject()){
                    objIdWithRedirectionBit = JODBIOBase.addRedirectedObjectModifier(objId);//this is redirected entry
                }else{
                    objIdWithRedirectionBit = objId;
                }
               
                if( isRedirection ){//if we fit into redirection record than delete record under redirection offset
                    deleteObject(ioTicket, session, redirectionOffset, tContainer);//delete/backup record under redirection offset
                }
               
               
                //object can fit to old spot, write it to replacements file insteard of transaction file
                IRandomAccessDataBuffer replacementsFile = tContainer.getTransactionReplacementsDataFile();
                replacementsFile.resetToEnd();
                replacementsFile.writeByte(TRANSACTION_REPLACEMENT_ENTRY_TYPE_STATIC);
                replacementsFile.writeLong(existingObjectHeaderData.getOffset());
                long replacementLengthEntryOffset = replacementsFile.getCursorOffset();
                replacementsFile.writeLong(0);//reserve space for replacement length entry. //TODO skip faster?
                long newObjectIDOffset = replacementsFile.getCursorOffset();
               
                replacementsFile.writeShort(objIdWithRedirectionBit);//write new ID to replacements file
                writeEntryLenForID(objId,objectBodyLength,replacementsFile);//write length of replacements file, could be bigger than actual object's data occupies
               
                long newObjectBodyOffset = replacementsFile.getCursorOffset();
                //return to write actual length of replacement entry
                replacementsFile.seek(replacementLengthEntryOffset);
                replacementsFile.writeLong(newObjectBodyOffset-newObjectIDOffset+objectBodyLength);
                replacementsFile.seek(newObjectBodyOffset);//back to the header end
               
                transactionFile.transferTo(objectBodyOffset, objectBodyLength, replacementsFile.getChannel());
                transactionFile.seek(objectIDOffset);//return position in transaction file to the start of object(like it wasn't here)
                transactionFile.setLength(objectIDOffset);//truncate "new data" file
                objectIDOffset = newObjectIDOffset;//this now offset in replacements file
                objectBodyOffset = newObjectBodyOffset;
                objectBodyLength = existingObjectHeaderData.getBodyLength();//length for new object
                transactionFile = replacementsFile;
                replacementsFile.resetToEnd();//replacements file to the end
                objectEndOffset = replacementsFile.getCursorOffset();
            }else{
                if(redirectorOffset!=-1){
                    //this is record under redirection offset
                    deleteObject(ioTicket, session, existingObjectHeaderData.getOffset(), tContainer);
                }
                IRandomAccessDataBuffer replacementsFile = tContainer.getTransactionReplacementsDataFile();
                long offset = tHandle.getHandle().getObjectEntryOffset();//offset of record that will be replaced with redirector
                //backupObject(ioTicket, offset, tContainer);
                //write redirector entry with relative offset
                replacementsFile.writeByte(TRANSACTION_REPLACEMENT_ENTRY_TYPE_REDIRECTOR);
                replacementsFile.writeLong(offset);
                replacementsFile.writeLong(objectIDOffset);//relative offset in new data transaction file
            }
            dataContainersCache.pushObjectDataContainer(existingObjectHeaderData);
        }
       
        for (int i = 0; i < fieldsWithRelativeAddr.size(); i++) {
            ObjectFieldRecord next = fieldsWithRelativeAddr.elementAt(i);
            next._offset = assembleTransactionDataForObject(context, next._value , tContainer);
//            if(JODBIOUtils.isAbsoluteOffset(next._offset)){
//                throw new IOException("internal transaction error");
//            }
        }
       
        if(classDescr.isArray() && !classDescr.isPrimitiveArray()){
            int arrayLength = Array.getLength(objectToPersist);
            for (int i = 0; i < arrayLength; i++) {
                Object value = Array.get(objectToPersist, i);
                if (value == null) {
                    continue;
                }
                TransactionHandle transactionHandle = transactionObjects.get(value);
                if(transactionHandle == null || transactionHandle.isTranslated()){
                    continue;
                }
                if(transactionHandle.isNewObject()){//only write new objects as we need relative offset, the offset for existing objects already known
                    assembleTransactionDataForObject(context, value , tContainer);
                }
            }
        }
       
        transactionFile.seek(objectIDOffset+2);
       
        writeEntryLenForID(objId,objectBodyLength,transactionFile);//TODO make sure the same size estimate is used

       
        if(fieldsWithRelativeAddr.size() > 0){
            transactionFile.seek(objectIDOffset+objectsWithRelativeAddrStartOffsetShift);
//            if(JODBConfig.DEBUG){
//                _logger.info("Transaction: Object "+rootObject.getClass()+" "+rootObject+" fields with relative pos ="+transactionFile.getCursorOffset());
//            }
        }
        for (int i = 0; i < fieldsWithRelativeAddr.size(); i++) {
            ObjectFieldRecord next = fieldsWithRelativeAddr.elementAt(i);
            int id = base.getOrSetFieldSubstitutionID(next._field);
            transactionFile.writeShort(id);
            transactionFile.writeInt((int)(next._offset - transactionFile.getCursorOffset()-4));//4 bytes to assume the position after offset entry
        }
       
       
View Full Code Here

    public synchronized JODBIndexingAgent enableIndex(Field field, JODBOperationContext context) throws IOException{
        TransactionContainer transactionContainer = context.getTransactionContainer();
        transactionContainer.enableAgentMode();
        try{
            JODBIndexingAgent agent = addAgent(field, context);
            IOBase base = context.getBase();
            int classId = base.getOrSetClassTypeSubstitutionID(field.getDeclaringClass());
            int fieldId = base.getOrSetFieldSubstitutionID(field);
            long[] allOffsets = base.getForAllObjects(context.getIoTicket());
            DataContainersCache dataContainersCache = TransactionUtils.getObjectDataContainerCache();
            ObjectDataContainer dataContainer = dataContainersCache.pullObjectDataContainer();
            try{
                for (int i = 0; i < allOffsets.length; i++) {
                    processIndexForObjectId(allOffsets[i], classId, fieldId, field.getType(), dataContainer, agent, context);
View Full Code Here

            }
            if(dataContainer.getOriginalClassType() != dataContainer.getTranslatedClassType()){
                throw new IllegalArgumentException("No indexing for translated classes");
            }
            FieldRecord fieldRecord = dataContainer.getRecordCache();
            IOBase base = context.getBase();
            while (fieldsIterator.hasNext()) {
                fieldsIterator.next(fieldRecord, base,false);
                if(fieldRecord._category != FIELD_CATEGORIES.PRIMITIVE){//TODO optimize to skip none primitive fields
                    continue;
                }
View Full Code Here


    private static void fillObject(JODBSession session, boolean delayedActivation, ObjectDataContainer objectDataContainer,  Object instance, int remainingDepth) throws IOException{
        ClassDescriptor classDescriptor = session.getDescriptorForClass(instance.getClass());

        IOBase base = session.getBase();
        FieldsIterator fieldsIterator = objectDataContainer.getActiveFieldsIterator();
        if(fieldsIterator == null){
            return;
        }
        BitSet processedFieldMask = new BitSet();
View Full Code Here

TOP

Related Classes of com.mobixess.jodb.core.io.IOBase

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.