Documentation of 'org.apache.derby.impl.io.vfmem.BlockedByteArray' Java class
BlockedByteArray
org.apache.derby.impl.io.vfmem

Class BlockedByteArray



  • public class BlockedByteArray
    extends java.lang.Object
    Stores data in blocks, and supports reading/writing data from/into these blocks.

    The blocked array is expanded and shrunk as required.

    • Constructor Summary

      Constructors 
      Constructor and Description
      BlockedByteArray()
      Creates a new blocked byte array with the default number of slots to hold byte arrays (blocks).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      long length()
      Returns the number of bytes allocated.
      int read(long pos)
      Returns the byte at the given position.
      int read(long pos, byte[] buf, int offset, int len)
      Reads up to len bytes.
      void setLength(long newLength)
      Changes the allocated length of the data.
      int writeByte(long pos, byte b)
      Writes the given byte into the blocked byte array.
      int writeBytes(long pos, byte[] buf, int offset, int len)
      Writes the given bytes into the blocked byte array.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BlockedByteArray

        public BlockedByteArray()
        Creates a new blocked byte array with the default number of slots to hold byte arrays (blocks).

        No blocks are pre-allocated.

        See Also:
        INITIAL_BLOCK_HOLDER_SIZE
    • Method Detail

      • read

        public int read(long pos)
        Returns the byte at the given position.
        Parameters:
        pos - position to read from
        Returns:
        A single byte.
      • read

        public int read(long pos,
                        byte[] buf,
                        int offset,
                        int len)
        Reads up to len bytes.
        Parameters:
        pos - the position to start reading at
        buf - the destination buffer
        offset - offset into the destination buffer
        len - the number of bytes to read
        Returns:
        The number of bytes read.
      • length

        public long length()
        Returns the number of bytes allocated.
        Returns:
        Bytes allocated.
      • setLength

        public void setLength(long newLength)
        Changes the allocated length of the data.

        If the new length is larger than the current length, the blocked byte array will be extended with new blocks. If the new length is smaller, existing (allocated) blocks will be removed if possible.

        Parameters:
        newLength - the new length of the allocated data in bytes
      • writeBytes

        public int writeBytes(long pos,
                              byte[] buf,
                              int offset,
                              int len)
        Writes the given bytes into the blocked byte array.
        Parameters:
        pos - the position to start writing at
        buf - the source buffer
        offset - the offset into the source buffer
        len - the number of bytes to write
        Returns:
        The number of bytes written.
      • writeByte

        public int writeByte(long pos,
                             byte b)
        Writes the given byte into the blocked byte array.
        Parameters:
        pos - the position to write the byte at
        b - the byte to write
        Returns:
        1, which is the number of bytes written.

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.