Package org.apache.derby.iapi.services.io

Examples of org.apache.derby.iapi.services.io.ArrayInputStream


     **/
  private void readPageHeader()
        throws IOException
  {
    // these reads are always against the page array
    ArrayInputStream lrdi = rawDataIn;

    lrdi.setPosition(PAGE_HEADER_OFFSET);
    long spare;

    isOverflowPage  =  lrdi.readBoolean();
    setPageStatus    (lrdi.readByte());
    setPageVersion    (lrdi.readLong());
    slotsInUse      =  lrdi.readUnsignedShort();
    nextId          =  lrdi.readInt();
    generation      =  lrdi.readInt();     // page generation (Future Use)
    prevGeneration  =  lrdi.readInt();     // previous generation (Future Use)
    bipLocation     =  lrdi.readLong()// BIPage location (Future Use)

    // number of deleted rows on page, we start to store this release 2.0.
    // for upgrade reasons, a 0 on disk means -1, so, we subtract one here.
    deletedRowCount =  lrdi.readUnsignedShort() - 1;

        // the next 4 (total 22 bytes) are reserved for future
    spare           =   lrdi.readUnsignedShort()
    spare           =   lrdi.readInt();     // used by encryption
    spare           =   lrdi.readLong();
    spare           =   lrdi.readLong();
  }
View Full Code Here


    @exception IOException error in reading the header from file
  */
  private void readHeaderFromArray(byte[] a)
     throws StandardException, IOException
  {
    ArrayInputStream inStream = new ArrayInputStream(a);

    inStream.setLimit(CONTAINER_INFO_SIZE);
    int fid = inStream.readInt();
    if (fid != formatIdInteger)
        {
      throw StandardException.newException(
                SQLState.DATA_UNKNOWN_CONTAINER_FORMAT, getIdentity(),
                new Long(fid));
        }

    int status = inStream.readInt();
    pageSize = inStream.readInt();
    spareSpace = inStream.readInt();
    minimumRecordSize = inStream.readInt();
    initialPages = inStream.readShort();
    PreAllocSize = inStream.readShort();
    firstAllocPageNumber = inStream.readLong();
    firstAllocPageOffset = inStream.readLong();
    containerVersion = inStream.readLong();
    estimatedRowCount = inStream.readLong();
    reusableRecordIdSequenceNumber = inStream.readLong();
    lastLogInstant = null;

    if (PreAllocSize == 0// pre 2.0, we don't store this.
      PreAllocSize = DEFAULT_PRE_ALLOC_SIZE;

    long spare3 = inStream.readLong()// read spare long

    // upgrade - if this is a container that was created before
    // initialPages was stored, it will have a zero value.  Set it to the
    // default of 1.
    if (initialPages == 0
      initialPages = 1;

    // container read in from disk, reset preAllocation values
    PreAllocThreshold = PRE_ALLOC_THRESHOLD;

    // validate checksum
    long onDiskChecksum = inStream.readLong();
    checksum.reset();
    checksum.update(a, 0, CONTAINER_INFO_SIZE - CHECKSUM_SIZE);

    if (onDiskChecksum != checksum.getValue())
    {
View Full Code Here

    byte[] array = byteArray.getArray();
   
    // now extract the relavent information from array - basically
    // duplicate the code in readHeaderFromArray
    ArrayInputStream inStream = new ArrayInputStream(array);

    int status = 0;

    try
    {     
      inStream.setLimit(CONTAINER_INFO_SIZE);

      int fid = inStream.readInt();
      if (fid != formatIdInteger)
      {
        // RESOLVE: do something about this when we have > 1 container format
        throw StandardException.newException(
                    SQLState.DATA_UNKNOWN_CONTAINER_FORMAT,
                    getIdentity(), new Long(fid));
      }

      status = inStream.readInt();
      pageSize = inStream.readInt();
      spareSpace = inStream.readInt();
      minimumRecordSize = inStream.readInt();
      initialPages = inStream.readShort();

    }
    catch (IOException ioe)
    {
      throw StandardException.newException(
View Full Code Here

    @exception IOException error in reading the header from file
  */
  private void readHeaderFromArray(byte[] a)
     throws StandardException, IOException
  {
    ArrayInputStream inStream = new ArrayInputStream(a);

    inStream.setLimit(0, CONTAINER_INFO_SIZE);
    int fid = inStream.readInt();
    if (fid != formatIdInteger)
        {
      throw StandardException.newException(
                SQLState.DATA_UNKNOWN_CONTAINER_FORMAT, getIdentity(),
                new Long(fid));
        }

    int status = inStream.readInt();
    pageSize = inStream.readInt();
    spareSpace = inStream.readInt();
    minimumRecordSize = inStream.readInt();
    initialPages = inStream.readShort();
    PreAllocSize = inStream.readShort();
    firstAllocPageNumber = inStream.readLong();
    firstAllocPageOffset = inStream.readLong();
    containerVersion = inStream.readLong();
    estimatedRowCount = inStream.readLong();
    lastLogInstant = null;

    if (PreAllocSize == 0// pre 2.0, we don't store this.
      PreAllocSize = DEFAULT_PRE_ALLOC_SIZE;

    long spare2 = inStream.readLong()// read spare long
    long spare3 = inStream.readLong()// read spare long

    // upgrade - if this is a container that was created before
    // initialPages was stored, it will have a zero value.  Set it to the
    // default of 1.
    if (initialPages == 0
      initialPages = 1;

    // container read in from disk, reset preAllocation values
    PreAllocThreshold = PRE_ALLOC_THRESHOLD;

    // validate checksum
    long onDiskChecksum = inStream.readLong();
    checksum.reset();
    checksum.update(a, 0, CONTAINER_INFO_SIZE - CHECKSUM_SIZE);

    if (onDiskChecksum != checksum.getValue())
    {
View Full Code Here

    byte[] array = byteArray.getArray();
   
    // now extract the relavent information from array - basically
    // duplicate the code in readHeaderFromArray
    ArrayInputStream inStream = new ArrayInputStream(array);

    int status = 0;

    try
    {     
      inStream.setLimit(0, CONTAINER_INFO_SIZE);

      int fid = inStream.readInt();
      if (fid != formatIdInteger)
      {
        // RESOLVE: do something about this when we have > 1 container format
        throw StandardException.newException(
                    SQLState.DATA_UNKNOWN_CONTAINER_FORMAT,
                    getIdentity(), new Long(fid));
      }

      status = inStream.readInt();
      pageSize = inStream.readInt();
      spareSpace = inStream.readInt();
      minimumRecordSize = inStream.readInt();
      initialPages = inStream.readShort();

    }
    catch (IOException ioe)
    {
      throw StandardException.newException(
View Full Code Here

  {
    super.initialize();

    if (rawDataIn == null)
        {
      rawDataIn            = new ArrayInputStream();
      checksum             = new CRC32();
    }

    if (pageData != null)
      rawDataIn.setData(pageData);
View Full Code Here

                    "restoreRecordFromSlot called on an overflow page.");
      }

            // position the array reading stream at beginning of row data just
            // past the record header.
      ArrayInputStream lrdi = rawDataIn;
      lrdi.setPosition(offset_to_row_data);

      if (!recordHeader.hasOverflow())
            {
                if (isHeadRow)
                {
                    if (fetchDesc != null &&
                        fetchDesc.getQualifierList() != null)
                    {
                        fetchDesc.reset();

                        if (!qualifyRecordFromSlot(
                                row,
                                offset_to_row_data,
                                fetchDesc,
                                recordHeader,
                                recordToLock))
                        {
                            return(false);
                        }
                        else
                        {
                            // reset position back for subsequent record read.
                            lrdi.setPosition(offset_to_row_data);
                        }
                    }
                }

                // call routine to do the real work.  Note that
View Full Code Here

                }
            }

            // position the array reading stream at beginning of row data
            // just past the record header.
            ArrayInputStream lrdi = rawDataIn;
            lrdi.setPosition(offset_to_row_data);

            if (fetchDesc != null)
            {
                if (fetchDesc.getQualifierList() != null)
                {
View Full Code Here

     **/
  private void readPageHeader()
        throws IOException
  {
    // these reads are always against the page array
    ArrayInputStream lrdi = rawDataIn;

    lrdi.setPosition(PAGE_HEADER_OFFSET);
    long spare;

    isOverflowPage  =  lrdi.readBoolean();
    setPageStatus    (lrdi.readByte());
    setPageVersion    (lrdi.readLong());
    slotsInUse      =  lrdi.readUnsignedShort();
    nextId          =  lrdi.readInt();
    generation      =  lrdi.readInt();     // page generation (Future Use)
    prevGeneration  =  lrdi.readInt();     // previous generation (Future Use)
    bipLocation     =  lrdi.readLong()// BIPage location (Future Use)

    // number of deleted rows on page, we start to store this release 2.0.
    // for upgrade reasons, a 0 on disk means -1, so, we subtract one here.
    deletedRowCount =  lrdi.readUnsignedShort() - 1;

        // the next 4 (total 22 bytes) are reserved for future
    spare           =   lrdi.readUnsignedShort()
    spare           =   lrdi.readInt();     // used by encryption
    spare           =   lrdi.readLong();
    spare           =   lrdi.readLong();
  }
View Full Code Here

        {
      SanityManager.ASSERT(getRecordOffset(slot) != 0);
    }

    // these reads are always against the page array
    ArrayInputStream lrdi = rawDataIn;

    lrdi.setPosition(
            slotTableOffsetToFirstRecordLengthField - (slot * slotEntrySize));

        return(
            (slotFieldSize == SMALL_SLOT_SIZE) ?
                lrdi.readUnsignedShort() : lrdi.readInt());
  }
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.services.io.ArrayInputStream

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.