Package krati.core.segment

Examples of krati.core.segment.AddressFormat


        long sizeLimit = segTarget.getInitialSize();
        long bytesTransferred = 0;
        boolean succ = true;
       
        try {
            AddressFormat addrFormat = _dataArray._addressFormat;
           
            for(int index = 0, cnt = _dataArray.length(); index < cnt; index++) {
                long oldAddress = _dataArray.getAddress(index);
                int oldSegPos = addrFormat.getOffset(oldAddress);
                int oldSegInd = addrFormat.getSegment(oldAddress);
                int length = addrFormat.getDataSize(oldAddress);
               
                if (oldSegInd == segSourceId && oldSegPos >= Segment.dataStartPosition) {
                    if(length == 0) length = segSource.readInt(oldSegPos);
                    int byteCnt = 4 + length;
                    long newSegPos = segTarget.getAppendPosition();
                    long newAddress = addrFormat.composeAddress((int)newSegPos, segTargetId, length);
                   
                    if(segTarget.getAppendPosition() + byteCnt >= sizeLimit) {
                        succ = false;
                        break;
                    }
View Full Code Here


        long sizeLimit = segTarget.getInitialSize();
        long bytesTransferred = 0;
        boolean succ = true;
       
        try {
            AddressFormat addrFormat = _dataArray._addressFormat;
            SegmentIndexBuffer.IndexOffset reuse = new SegmentIndexBuffer.IndexOffset();
           
            for(int i = 0, cnt = sibSource.size(); i < cnt; i++) {
                sibSource.get(i, reuse);
                int index = reuse.getIndex();
                int sibSegPos = reuse.getOffset();
                long oldAddress = _dataArray.getAddress(index);
                int oldSegPos = addrFormat.getOffset(oldAddress);
               
                if(sibSegPos != oldSegPos) continue;
               
                int oldSegInd = addrFormat.getSegment(oldAddress);
                int length = addrFormat.getDataSize(oldAddress);
               
                if (oldSegInd == segSourceId && oldSegPos >= Segment.dataStartPosition) {
                    if(length == 0) length = segSource.readInt(oldSegPos);
                    int byteCnt = 4 + length;
                    long newSegPos = segTarget.getAppendPosition();
                    long newAddress = addrFormat.composeAddress((int)newSegPos, segTargetId, length);
                   
                    if(segTarget.getAppendPosition() + byteCnt >= sizeLimit) {
                        succ = false;
                        break;
                    }
View Full Code Here

                           SegmentManager segmentManager,
                           double segmentCompactFactor) {
        this._addressArray = addressArray;
        this._segmentManager = segmentManager;
        this._segmentCompactFactor = segmentCompactFactor;
        this._addressFormat = new AddressFormat();
       
        // Add segment persist listener
        addressArray.setPersistListener(new SegmentPersistListener());
       
        // Start segment data compactor
View Full Code Here

        super(TestAddressFormat.class.getSimpleName());
    }
   
    public void testAddressFormat() {
        int offset, segment, dataSize;
        AddressFormat af = new AddressFormat();
       
        // Test 1
        offset = 12345;
        segment = 24;
        dataSize = (1 << DynamicConstants.SUB_ARRAY_BITS) - 1;
        check(af, offset, segment, dataSize);
       
        // Test 2
        offset = 12345;
        segment = 24;
        dataSize = (1 << DynamicConstants.SUB_ARRAY_BITS);
        check(af, offset, segment, dataSize);
       
        // Test 3
        offset = 12345;
        segment = 24;
        dataSize = 0;
        check(af, offset, segment, dataSize);
       
        // Test 4
        offset = Integer.MAX_VALUE;
        segment = 24;
        dataSize = 1023;
        check(af, offset, segment, dataSize);
       
        // Test 5
        offset = 0;
        segment = 24;
        dataSize = 1023;
        check(af, offset, segment, dataSize);
       
        // Test 6
        offset = 0;
        segment = 24;
        dataSize = af.getMaxDataSize();
        check(af, offset, segment, dataSize);
    }
View Full Code Here

TOP

Related Classes of krati.core.segment.AddressFormat

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.