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

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


    TransactionManager      xact_mgr,
    ContainerKey            container_key)
    throws StandardException
    {
        ContainerHandle         container   = null;
        Page                    page        = null;
        DataValueDescriptor[]   control_row = new DataValueDescriptor[1];

        try
        {
            // open container to read the Heap object out of it's control row.
            container =
                xact_mgr.getRawStoreXact().openContainer(
                    container_key, (LockingPolicy) null, 0);

            if (container == null)
            {
                throw StandardException.newException(
                    SQLState.STORE_CONGLOMERATE_DOES_NOT_EXIST,
                    new Long(container_key.getContainerId()));
            }

            // row in slot 0 of heap page 1 which is just a single column with
            // the heap entry.
            control_row[0]       = new Heap();

            page = container.getPage(ContainerHandle.FIRST_PAGE_NUMBER);

            RecordHandle rh =
                page.fetchFromSlot(
                   (RecordHandle) null, 0, control_row,
                   (FetchDescriptor) null,
                   true);

            if (SanityManager.DEBUG)
            {
                SanityManager.ASSERT(rh != null);

                // for now the control row is always the first id assigned on
                // page 1.
                SanityManager.ASSERT(rh.getId() == 6);
            }
        }
        finally
        {
            if (page != null)
                page.unlatch();

            if (container != null)
                container.close();
        }
View Full Code Here


            // get a template.

            DataValueDescriptor[] row = runtime_mem.get_row_for_export();

            // Print pages of the heap.
            Page page = container.getFirstPage();

            while (page != null)
            {
                SanityManager.DEBUG_PRINT(
                    "p_heap", ConglomerateUtil.debugPage(page, 0, false, row));

                long pageid = page.getPageNumber();
                page.unlatch();
                page = container.getNextPage(pageid);
            }
        }

        return;
View Full Code Here

        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)
        {
            this.diag_page(page, prop, stat);
            pageid = page.getPageNumber();
            page.unlatch();
            page = container.getNextPage(pageid);
        }

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

   * @exception  StandardException  Standard exception policy.
     **/
  private RecordHandle doInsert(DataValueDescriptor[] row)
    throws StandardException
  {
    Page page = null;
        byte  insert_mode;
   
        RecordHandle rh;

        if (SanityManager.DEBUG)
        {
            Heap heap = (Heap) open_conglom.getConglomerate();
            // Make sure valid columns are in the list.  The RowUtil
            // call is too expensive to make in a released system for
            // every insert.

            int invalidColumn =
                RowUtil.columnOutOfRange(
                    row, null, heap.format_ids.length);

            if (invalidColumn >= 0)
            {
                throw(StandardException.newException(
                        SQLState.HEAP_TEMPLATE_MISMATCH,
                        new Long(invalidColumn),
                        new Long(heap.format_ids.length)));
            }
        }

        // Get the last page that was returned for insert or the last page
        // that was allocated.
        page = open_conglom.getContainer().getPageForInsert(0);

        if (page != null) {

            // if there are 0 rows on the page allow the insert to overflow.
            insert_mode =
                (page.recordCount() == 0) ?
                    Page.INSERT_OVERFLOW : Page.INSERT_DEFAULT;

            // Check to see if there is enough space on the page
            // for the row.
            rh = page.insert(row, null, insert_mode,
        AccessFactoryGlobals.HEAP_OVERFLOW_THRESHOLD);
            page.unlatch();
            page = null;

            // If we have found a page with enough space for the row,
            // insert it and release exclusive access to the page.
            if (rh != null)
            {
                return rh;

            }
        }

        // If the last inserted page is now full, or RawStore have
        // forgotten what it was, or the row cannot fit on the last
        // inserted page, try to have rawStore get a relatively unfilled
        // page.

        page =
            open_conglom.getContainer().getPageForInsert(
                ContainerHandle.GET_PAGE_UNFILLED);

        if (page != null)
        {
            // Do the insert all over again hoping that it will fit into
            // this page, and if not, allocate a new page.

            // if there are 0 rows on the page allow the insert to overflow.
            insert_mode =
                (page.recordCount() == 0) ?
                    Page.INSERT_OVERFLOW : Page.INSERT_DEFAULT;
           
            rh = page.insert(row, null, insert_mode,
        AccessFactoryGlobals.HEAP_OVERFLOW_THRESHOLD);

            page.unlatch();
            page = null;

            // If we have found a page with enough space for the row,
            // insert it and release exclusive access to the page.
            if (rh != null)
            {
                return rh;
            }
        }

        page = open_conglom.getContainer().addPage();

        // At this point with long rows the raw store will guarantee
        // that any size row will fit on an empty page.

        rh = page.insert(row, null, Page.INSERT_OVERFLOW,
      AccessFactoryGlobals.HEAP_OVERFLOW_THRESHOLD);
        page.unlatch();
        page = null;

        if (SanityManager.DEBUG)
        {
            // a null will only be returned if this page is not empty
View Full Code Here

    // out these rows if the transaction rolls back.  We are counting on
    // the allocation page rollback to obliterate these rows if the
    // transaction fails, or, in the CREAT_UNLOGGED case, the whole
    // container to be removed.

    Page page = open_conglom.getContainer().addPage();

    boolean callbackWithRowLocation = rowSource.needsRowLocation();
    RecordHandle rh;
    HeapRowLocation rowlocation;

    if (callbackWithRowLocation)
      rowlocation = new HeapRowLocation();
    else
      rowlocation = null;

        FormatableBitSet validColumns = rowSource.getValidColumns();

    try
    {
       // get the next row and its valid columns from the rowSource
      DataValueDescriptor[] row;
            while ((row = rowSource.getNextRowFromRowSource()) != null)
            {
                num_rows_loaded++;

                if (SanityManager.DEBUG)
                {
                    // Make sure valid columns are in the list.  The RowUtil
                    // call is too expensive to make in a released system for
                    // every insert.
                    int invalidColumn =
                        RowUtil.columnOutOfRange(
                            row, validColumns, heap.format_ids.length);

                    if (invalidColumn >= 0)
                    {
                        throw(StandardException.newException(
                                SQLState.HEAP_TEMPLATE_MISMATCH,
                                new Long(invalidColumn),
                                new Long(heap.format_ids.length)));
                    }
                }


        // Insert it onto this page as long as it can fit more rows.
        if ((rh = page.insert(
                        row, validColumns, Page.INSERT_DEFAULT,
            AccessFactoryGlobals.HEAP_OVERFLOW_THRESHOLD))
                                == null)
        {
          // Insert faied, row did not fit.  Get a new page. 

          page.unlatch();
          page = null;

          page = open_conglom.getContainer().addPage();

          // RESOLVE (mikem) - no long rows yet so the following code
          // will get an exception from the raw store for a row that
          // does not fit on a page.
          //
          // Multi-thread considerations aside, the raw store will
                    // guarantee that any size row will fit on an empty page.
          rh = page.insert(
                            row, validColumns, Page.INSERT_OVERFLOW,
              AccessFactoryGlobals.HEAP_OVERFLOW_THRESHOLD);

        }

        // Else, the row fit.  If we are expected to call back with the
        // row location, do so.  All the while keep the page latched
        // and go for the next row.
        if (callbackWithRowLocation)
        {
          rowlocation.setFrom(rh);
          rowSource.rowLocation(rowlocation);
        }
      }
      page.unlatch();
      page = null;

      // Done with the container, now we need to flush it to disk since
      // it is unlogged.
            if (!heap.isTemporary())
View Full Code Here

    {
        ControlRow            root                      = null;
        ControlRow            control_row               = null;
        DataValueDescriptor[] logged_index_row_template = null;
        DataValueDescriptor[] template                  = null;
        Page                  ret_page                  = null;
        ContainerHandle       container                 = pageOp.getContainer();
        RecordHandle          rechandle                 = pageOp.getRecordHandle();
        boolean               ok_exit                   = false;
        int                   compare_result            = 1;
        B2I                   btree                     = null;
View Full Code Here

    ControlRow        leftchild,
    int               level,
    ControlRow        parent)
        throws StandardException
    {
        Page      page      = open_btree.container.addPage();

        // Create a control row for the new page.
        BranchControlRow control_row =
            new BranchControlRow(
                open_btree, page, level,
                parent, false, leftchild.page.getPageNumber());

        // Insert the control row on the page.
    byte insertFlag = Page.INSERT_INITIAL;
    insertFlag |= Page.INSERT_DEFAULT;
        page.insertAtSlot(
            Page.FIRST_SLOT_NUMBER,
            control_row.getRow(),
            (FormatableBitSet) null,
            (LogicalUndo)null,
            insertFlag, AccessFactoryGlobals.BTREE_OVERFLOW_THRESHOLD);
View Full Code Here

            // the post commit work will just skip it.
            control_row = ControlRow.GetNoWait(open_btree, pageno);

            if (control_row != null)
            {
                Page page   = control_row.page;

                // The number records that can be reclaimed is:
                // total recs - control row - recs_not_deleted
                int num_possible_commit_delete =
                    page.recordCount() - 1 - 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--)
                    {
                        if (page.isDeletedAtSlot(slot_no))
                        {

                            if (page.recordCount() == 2)
                            {
                                // About to purge last row from page so
                                // remember the key so we can shrink the
                                // tree.
                                shrink_key = this.getShrinkKey(
                                    open_btree, control_row, slot_no);
                            }

                            page.purgeAtSlot(slot_no, 1, true);

                            if (SanityManager.DEBUG)
                            {
                                if (SanityManager.DEBUG_ON(
                                        "verbose_btree_post_commit"))
                                {
                                    System.out.println(
                                        "Purging row[" + slot_no + "]" +
                                        "on page:" + pageno + ".\n");
                                }
                            }
                        }
                    }
                }

                if (page.recordCount() == 1)
                {
                    if (SanityManager.DEBUG)
                    {
                        if (SanityManager.DEBUG_ON("verbose_btree_post_commit"))
                        {
View Full Code Here

    Properties  prop,
    LevelInfo   level_info[])
        throws StandardException
    {
        LevelInfo li    = level_info[control_row.getLevel()];
        Page      page  = control_row.page;



        li.num_pages++;
        li.num_entries += (page.recordCount() - 1);
        li.num_deleted += (page.recordCount() - page.nonDeletedRecordCount());
        li.max_pageno  = Math.max(li.max_pageno, page.getPageNumber());

        DiagnosticUtil.findDiagnostic(page).diag_detail(prop);


        DiagnosticUtil.findDiagnostic(page).diag_detail(prop);
View Full Code Here

                    {
                        scan_position.current_positionKey =
                            runtime_mem.get_row_for_export();


                        Page page = scan_position.current_leaf.getPage();


                        RecordHandle rh =
                            page.fetchFromSlot(
                                (RecordHandle) null,
                                page.getSlotNumber(scan_position.current_rh),
                                scan_position.current_positionKey,
                                (FetchDescriptor) null,
                                true);

                        if (SanityManager.DEBUG)
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.