Package org.apache.derby.iapi.store.raw

Examples of org.apache.derby.iapi.store.raw.Page


        prop.put(Page.DIAG_ROWSIZE,          "");
        prop.put(Page.DIAG_MINROWSIZE,       "");
        prop.put(Page.DIAG_MAXROWSIZE,       "");

        // scan all pages in the heap gathering summary stats in stat
        Page page = container.getFirstPage();

        while (page != null)
        {
            D_HeapController.diag_page(page, prop, stat);
            pageid = page.getPageNumber();
            page.unlatch();
            page = container.getNextPage(pageid);
        }

        return(D_HeapController.diag_tabulate(prop, stat));
    }
View Full Code Here


    // create the first alloc page and the first user page,
    // if this fails for any reason the transaction
    // will roll back and the container will be dropped (removed)
    ContainerHandle containerHdl = null;
    Page            firstPage    = null;

    try
        {
      // if opening a temporary container with IS_KEPT flag set,
      // make sure to open it with IS_KEPT too.
      if (tmpContainer &&
        ((temporaryFlag & TransactionController.IS_KEPT) ==
                     TransactionController.IS_KEPT))
            {

        mode |= ContainerHandle.MODE_TEMP_IS_KEPT;
      }

      // open no-locking as we already have the container locked
      containerHdl =
                t.openContainer(
                    identity, null, (ContainerHandle.MODE_FORUPDATE | mode));

      // we just added it, containerHdl should not be null
            if (SanityManager.DEBUG)
                SanityManager.ASSERT(containerHdl != null);

      if (!tmpContainer)
            {
        // make it persistent (in concept if not in reality)
        RawContainerHandle rch = (RawContainerHandle)containerHdl;

        ContainerOperation lop =
          new ContainerOperation(rch, ContainerOperation.CREATE);

        // mark the container as pre-dirtied so that if a checkpoint
        // happens after the log record is sent to the log stream, the
        // cache cleaning will wait for this change.
        rch.preDirty(true);
        try
        {
          t.logAndDo(lop);

          // flush the log to reduce the window between where
          // the container is created & synced and the log record
          // for it makes it to disk. If we fail in this
          // window we will leave a stranded container file.
          flush(t.getLastLogInstant());
        }
        finally
        {
          // in case logAndDo fail, make sure the container is not
          // stuck in preDirty state.
          rch.preDirty(false);
        }
      }

      firstPage = containerHdl.addPage();

    }
        finally
        {

      if (firstPage != null)
            {
        firstPage.unlatch();
        firstPage = null;
      }
     
      containerCache.release(container);
View Full Code Here

  public void restoreLoggedRow(
    Object[]   row,
    LimitObjectInput        in)
    throws StandardException, IOException
  {
    Page p = null;

    try {
      // the optional data is written by the page in the same format it
      // stores record on the page,
      // only a page knows how to restore a logged row back to a storable row
      // first get the page where the insert went even though the row may no
      // longer be there
      p = getContainer().getPage(getPageId().getPageNumber());


      ((BasePage)p).restoreRecordFromStream(in, row);

    } finally {

      if (p != null) {
        p.unlatch();
        p = null;
      }
    }
  }
View Full Code Here

    // create the first alloc page and the first user page,
    // if this fails for any reason the transaction
    // will roll back and the container will be dropped (removed)
    ContainerHandle containerHdl = null;
    Page            firstPage    = null;

    try
        {
      // if opening a temporary container with IS_KEPT flag set,
      // make sure to open it with IS_KEPT too.
      if (tmpContainer &&
        ((temporaryFlag & TransactionController.IS_KEPT) ==
                     TransactionController.IS_KEPT))
            {

        mode |= ContainerHandle.MODE_TEMP_IS_KEPT;
      }

      // open no-locking as we already have the container locked
      containerHdl =
                t.openContainer(
                    identity, null, (ContainerHandle.MODE_FORUPDATE | mode));

      // we just added it, containerHdl should not be null
            if (SanityManager.DEBUG)
                SanityManager.ASSERT(containerHdl != null);

      if (!tmpContainer)
            {
        // make it persistent (in concept if not in reality)
        RawContainerHandle rch = (RawContainerHandle)containerHdl;

        ContainerOperation lop =
          new ContainerOperation(rch, ContainerOperation.CREATE);

        // mark the container as pre-dirtied so that if a checkpoint
        // happens after the log record is sent to the log stream, the
        // cache cleaning will wait for this change.
        rch.preDirty(true);
        try
        {
          t.logAndDo(lop);

          // flush the log to reduce the window between where
          // the container is created & synced and the log record
          // for it makes it to disk. If we fail in this
          // window we will leave a stranded container file.
          flush(t.getLastLogInstant());
        }
        finally
        {
          // in case logAndDo fail, make sure the container is not
          // stuck in preDirty state.
          rch.preDirty(false);
        }
      }

      firstPage = containerHdl.addPage();

    }
        finally
        {

      if (firstPage != null)
            {
        firstPage.unlatch();
        firstPage = null;
      }
     
      containerCache.release(container);
View Full Code Here

        // Remember the time stamp on the first page of the column
        // chain.  This is to prevent the case where the post commit
        // work gets fired twice, in that case, the second time it is
        // fired, this overflow page may not part of this row chain
        // that is being updated.
        Page firstPageOnColumnChain = getOverflowPage(overflowPage);
        PageTimeStamp ts = firstPageOnColumnChain.currentTimeStamp();
        firstPageOnColumnChain.unlatch();

        RawTransaction rxact = (RawTransaction)owner.getTransaction();

        ReclaimSpace work =
          new ReclaimSpace(ReclaimSpace.COLUMN_CHAIN,
View Full Code Here

  */
  public void restoreLoggedRow(Object[] row, LimitObjectInput in)
    throws StandardException, IOException

  {
    Page p = null;

    try {
      // the optional data is written by the page in the same format it
      // stores record on the page,
      // only a page knows how to restore a logged row back to a storable row
      // first get the page where the insert went even though the row may no
      // longer be there
      p = getContainer().getPage(getPageId().getPageNumber());

      ((BasePage)p).restoreRecordFromStream(in, row);

    } finally {

      if (p != null) {
        p.unlatch();
        p = null;
      }
    }
  }
View Full Code Here

      // Reclaiming a page - called by undo of insert which purged the
      // last row off an overflow page. It is safe to reclaim the page
      // without first locking the head row because unlike post commit
      // work, this is post abort work.  Abort is guarenteed to happen
      // and to happen only once, if at all.
      Page p = containerHdl.getPageNoWait(work.getPageId().getPageNumber());
      if (p != null)
        containerHdl.removePage(p);

      tran.commit();
      return Serviceable.DONE;
View Full Code Here

            lastInsertedPage = new long[4];
            lastInsertedPage[0] = last;

            for (int i = 3; i > 0; i--)
            {
                Page page = addPage(handle, false);
                lastInsertedPage[i] = page.getPageNumber();
                page.unlatch();
            }
        }
    }
View Full Code Here

  */
  public Page addPage() throws StandardException
    {
    checkUpdateOpen();

    Page page = container.addPage(this, false /* not an overflow page */);
     
    return page;
  }
View Full Code Here

        // somehow the page requested no longer exists.
 
  //resolve - what will happen if the user page doesnt exist 

        // wait to get the latch on the page
        Page page = heap_control.getUserPageWait(pageno);
        boolean purgingDone = false;

        if (page != null)
        {
            try
            {
                // The number records that can be reclaimed is:
                // total recs - recs_not_deleted
                int num_possible_commit_delete =
                    page.recordCount() - page.nonDeletedRecordCount();

                if (num_possible_commit_delete > 0)
                {
                    // loop backward so that purges which affect the slot table
                    // don't affect the loop (ie. they only move records we
                    // have already looked at).
                    for (int slot_no = page.recordCount() - 1;
                         slot_no >= 0;
                         slot_no--)
                    {
                        boolean row_is_committed_delete =
                            page.isDeletedAtSlot(slot_no);

                        if (row_is_committed_delete)
                        {
                            // At this point we only know that the row is
                            // deleted, not whether it is committed.

                            // see if we can purge the row, by getting an
                            // exclusive lock on the row.  If it is marked
                            // deleted and we can get this lock, then it
                            // must be a committed delete and we can purge
                            // it.

                            RecordHandle rh =
                                page.fetchFromSlot(
                                    (RecordHandle) null,
                                    slot_no,
                                    RowUtil.EMPTY_ROW,
                                    RowUtil.EMPTY_ROW_FETCH_DESCRIPTOR,
                                    true);

                            row_is_committed_delete =
                                heap_control.lockRowAtSlotNoWaitExclusive(rh);

                            if (row_is_committed_delete)
                            {
                                purgingDone = true;

                                page.purgeAtSlot(slot_no, 1, false);

                                if (SanityManager.DEBUG)
                                {
                                    if (SanityManager.DEBUG_ON(
                                            "verbose_heap_post_commit"))
                                    {
                                        SanityManager.DEBUG_PRINT(
                                            "HeapPostCommit",
                                            "Purging row[" + slot_no + "]" +
                                            "on page:" + pageno + ".\n");
                                    }
                                }
                            }
                        }
                    }
                }
                if (page.recordCount() == 0)
                {
                    purgingDone = true;

                    // Deallocate the current page with 0 rows on it.
                    heap_control.removePage(page);

                    // removePage guarantees to unlatch the page even if an
                    // exception is thrown. The page is protected against reuse
                    // because removePage locks it with a dealloc lock, so it
                    // is OK to release the latch even after a purgeAtSlot is
                    // called.
                    // @see ContainerHandle#removePage

                    if (SanityManager.DEBUG)
                    {
                        if (SanityManager.DEBUG_ON("verbose_heap_post_commit"))
                        {
                            SanityManager.DEBUG_PRINT(
                                "HeapPostCommit",
                                "Calling Heap removePage().; pagenumber="+pageno+"\n");
                        }
                    }
                }
            }
            finally
            {
                // If no purge happened on the page and the page is not
                // removed, feel free to unlatch it.  Otherwise, let
                // transaction commit take care of it.
        if (!purgingDone)
                {
                    page.unlatch();
                    page = null;
                }
            }
        }
        else
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.store.raw.Page

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.