Examples of ByteRange


Examples of org.xtreemfs.babudb.index.ByteRange

    }
   
    public ByteRange getEntry(int n) {
        assert (offset < buf.limit()) : "offset == " + offset + ", buf.limit == " + buf.limit()
            + ", entrySize == " + entrySize + ", n == " + n;
        return new ByteRange(buf, offset + n * entrySize, offset + (n + 1) * entrySize - 1);
    }
View Full Code Here

Examples of org.xtreemfs.babudb.index.ByteRange

        int offsetEnd = offset;
        offsetEnd += buf.getInt(offsetListStart + n * Integer.SIZE / 8);
       
        assert (offsetEnd > offsetStart);
       
        return new ByteRange(buf, offsetStart, offsetEnd);
    }
View Full Code Here

Examples of org.xtreemfs.babudb.index.ByteRange

       
        if (buf instanceof byte[])
            return ((byte[]) buf)[offset];
       
        else {
            ByteRange range = (ByteRange) buf;
           
            assert (range.getSize() <= offset);
            return range.getBuf().get(range.getStartOffset() + offset);
        }
    }
View Full Code Here

Examples of org.xtreemfs.babudb.index.ByteRange

        int endBlockOffset;
        if (indexPosition == blockIndex.getNumEntries() - 1)
            // the last block in the block index
            endBlockOffset = -1;
        else {
            ByteRange indexPos = getBlockEntry(indexPosition + 1, blockIndex);
            ByteBuffer indexPosBuf = indexPos.getBuf();
            endBlockOffset = getBlockIndexOffset(indexPosBuf, indexPos.getStartOffset());
           
            // is this the last block of the current block file?
            // then the endBlockOffset should be set to the end of the file
            if (getBlockIndexFileId(indexPosBuf, indexPos.getStartOffset()) > fileId)
                endBlockOffset = -1;
           
            // endBlockOffset = getBlockOffset(indexPosition + 1, blockIndex);
        }
       
        // create a view buffer on the target block
        BlockReader targetBlock = null;
        try {
            targetBlock = mmaped ? getBlock(startBlockOffset, endBlockOffset, dbFiles[fileId]) : getBlock(
                startBlockOffset, endBlockOffset, dbFileChannels[fileId]);
        } catch (IOException e) {
            Logging.logError(Logging.LEVEL_ERROR, this, e);
        }
       
        // search for the key in the target block and return the result
        ByteRange val = targetBlock.lookup(key);
        byte[] result = val == null ? null : val.toBuffer();
        targetBlock.free();
       
        return result;
    }
View Full Code Here

Examples of org.xtreemfs.babudb.index.ByteRange

     * @param index
     *            the block index
     * @return the offset
     */
    protected static int getBlockOffset(int indexPosition, BlockReader index) {
        ByteRange range = index.getValues().getEntry(indexPosition);
        return range.getBuf().getInt(range.getStartOffset());
    }
View Full Code Here

Examples of org.xtreemfs.babudb.index.ByteRange

     * @param index
     *            the block index
     * @return the block file id
     */
    protected static short getBlockFileId(int indexPosition, BlockReader index) {
        ByteRange range = index.getValues().getEntry(indexPosition);
        // block file index is after the int indicating the offset in the index
        // file
        return range.getBuf().getShort(range.getStartOffset() + (Integer.SIZE / 8));
    }
View Full Code Here

Examples of org.xtreemfs.babudb.index.ByteRange

        // file
        return range.getBuf().getShort(range.getStartOffset() + (Integer.SIZE / 8));
    }
   
    protected static ByteRange getBlockEntry(int indexPosition, BlockReader index) {
        ByteRange range = index.getValues().getEntry(indexPosition);
        // block file index is after the int indicating the offset in the index
        // file
        return range;
    }
View Full Code Here

Examples of org.xtreemfs.babudb.index.ByteRange

       
        // binary search
        while (low <= high) {
           
            mid = (low + high) >>> 1;
            ByteRange currKey = page.getEntry(mid);
           
            cmp = comp.compare(currKey, entry);
            if (cmp < 0)
                low = mid + 1;
            else if (cmp > 0)
View Full Code Here

Examples of org.xtreemfs.babudb.index.ByteRange

       
        // binary search
        while (low <= high) {
           
            mid = (low + high) >>> 1;
            ByteRange currKey = page.getEntry(mid);
           
            cmp = comp.compare(currKey, entry);
            if (cmp < 0)
                low = mid + 1;
            else if (cmp > 0)
View Full Code Here

Examples of org.xtreemfs.babudb.index.ByteRange

       
        // binary search
        while (low <= high) {
           
            mid = (low + high) >>> 1;
            ByteRange currKey = page.getEntry(mid);
           
            cmp = comp.compare(currKey, entry);
            if (cmp < 0)
                low = mid + 1;
            else if (cmp > 0)
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.