Package org.apache.derby.impl.store.raw.data

Examples of org.apache.derby.impl.store.raw.data.BasePage


                int[] createArgs,
                long pageOffset,
                boolean reuse,
                boolean overflow) throws StandardException
  {
    BasePage page = null;

    boolean releasePage = true;

    try
    {
      if (reuse)        //  read the page in first
      {
        // Cannot go thru the container handle because all read pages are blocked. 
        // do it underneath the handle and directly to the cache. 
        // Nobody can get thru becuase getPage will block at getting the alloc page.

        if (SanityManager.DEBUG)
                {
                    if (SanityManager.DEBUG_ON(SPACE_TRACE))
                    {
                        SanityManager.DEBUG(
                            SPACE_TRACE, "reusing page " + pkey);
                    }
                }

        page = (BasePage)pageCache.find(pkey);
        if (page == null// hmmm?
                {
          throw StandardException.newException(
                            SQLState.FILE_REUSE_PAGE_NOT_FOUND, pkey);
                }
      }
      else
      {
        if (SanityManager.DEBUG)
                {
                    if (SanityManager.DEBUG_ON(SPACE_TRACE))
                    {
                        SanityManager.DEBUG(
                            SPACE_TRACE, "allocation new page " + pkey);
                    }
                }

        // a brand new page, initialize and a new page in cache
        page = (BasePage) pageCache.create(pkey, createArgs);

        if (SanityManager.DEBUG)
          SanityManager.ASSERT(page != null, "page Cache create return a null page");
      }
      releasePage = false;
            page = latchPage(allochandle, page, true /* may need to wait, track3822 */);

      if (page == null)
            {
        throw StandardException.newException(
                        SQLState.FILE_NEW_PAGE_NOT_LATCHED, pkey);
            }    

      // page is either brand new or is read from disk, in either case,
      // it knows how to get itself initialized.
      int initPageFlag = 0;
      if (reuse) initPageFlag |= BasePage.INIT_PAGE_REUSE;
      if (overflow) initPageFlag |= BasePage.INIT_PAGE_OVERFLOW;
      if (reuse && isReusableRecordId())
        initPageFlag |= BasePage.INIT_PAGE_REUSE_RECORDID;

      page.initPage(initPageFlag, pageOffset);
      page.setContainerRowCount(estimatedRowCount);

    }
    finally
    {
      if (releasePage && page != null)
View Full Code Here


    }

    // RESOLVE: no translation!

    PageKey pageSearch = new PageKey(identity, pageNumber);
    BasePage page = (BasePage)pageCache.find(pageSearch);

    if (page == null)
    {
      return page;
    }

        // latch the page
        if (latchPage(handle,page,wait) == null)
        {
      // page was already released from cache
            return null;
        }

    // double check for overflow and deallocated page
    // a page that was valid before maybe invalid by now if it was
    // deallocated in the interum.
    // a page that is invalid can also become valid in the interim, but
    // we do not handle that.  The client must supply other locking
    // mechanism to prevent that (an allocatino happenning where there are
    // readers) if that is needed
    if ((page.isOverflowPage() && !overflowOK) ||
      (page.getPageStatus() != BasePage.VALID_PAGE))
    {
      // unlatch releases page from cache, see StoredPage.releaseExclusive()
            page.unlatch();
      page = null;
    }

    return page;
  }
View Full Code Here

    {
      allocCache.invalidate();
    }
   
    PageKey pageSearch = new PageKey(identity, pageNumber);
    BasePage page = (BasePage) pageCache.find(pageSearch);

    return page;
  }
View Full Code Here

        SanityManager.DEBUG_PRINT("Trace", "recreating page " + pkey + " for load tran");

    // Can't just call initPage because that wants to log an initPage
    // operation, whereas we are here because of an initPage operation in
    // the log already.
    BasePage page = null;
    boolean releasePage = true;
    try
    {
      // a brand new page, initialize and a new page in cache
      page = (BasePage) pageCache.create(pkey, reCreatePageArgs);
View Full Code Here

  {
    if (getCommittedDropState()) // committed and dropped, cannot get a page
      return null;

    PageKey pageSearch = new PageKey(identity, pageNumber);
    BasePage page = (BasePage) pageCache.find(pageSearch);

    if (SanityManager.DEBUG)
    {
      if (page == null)
        SanityManager.THROWASSERT(
View Full Code Here

      if (nextNumber == ContainerHandle.INVALID_PAGE_NUMBER)
        return null;

      // optimistically go for the next page
      BasePage p = getUserPage(handle, nextNumber,
                false /* no overflow page*/, wait);
      if (p != null)
        return p;

      pageNumber = nextNumber;
View Full Code Here

     throws StandardException
  {
    if (pageNumber == ContainerHandle.INVALID_PAGE_NUMBER)
      return null;

    BasePage p = getUserPage(handle, pageNumber, overflowOK, wait);
    if (p != null)
    {
            // make sure the page is not too full
            if (!p.allowInsert())
            {
                p.unlatch();
                p = null;

                // it is too full, make sure we are tracking it so we won't
                // see it again.
                allocCache.trackUnfilledPage(pageNumber, false);
View Full Code Here

   */
  protected BasePage getPageForInsert(BaseContainerHandle handle,
                    int flag)
     throws StandardException
  {
    BasePage p = null;
    boolean getLastInserted = (flag & ContainerHandle.GET_PAGE_UNFILLED) == 0;

    if (getLastInserted)
    {
      // There is nothing protecting lastInsertePage from being changed
View Full Code Here

    throws StandardException {

    if (foundPage == null)
      return null;

    BasePage ret = super.latchPage(handle, foundPage, wait);
    if (ret == null) {
      // page is still cached
      pageCache.release((Cacheable) foundPage);
    }
    return ret;
View Full Code Here

    StoredRecordHeader recordHeader = getHeaderAtSlot(slot);

    if (!recordHeader.hasOverflow())
      return super.fetchNumFieldsAtSlot(slot);

    BasePage overflowPage = getOverflowPage(recordHeader.getOverflowPage());
    int count = overflowPage.fetchNumFieldsAtSlot(getOverflowSlot(overflowPage, recordHeader));
    overflowPage.unlatch();
    return count;
  }
View Full Code Here

TOP

Related Classes of org.apache.derby.impl.store.raw.data.BasePage

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.