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

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


                // Need to get an exclusive scan lock on the page before we can
                // do any sort of purges, otherwise other concurrent scans would
                // not work.  If we can't get the lock NOWAIT, just give up on
                // purging rows and do the split without reclaiming rows.

                Page page   = leaf.page;


                // RowLocation column is in last column of template.
                FetchDescriptor lock_fetch_desc =
                    RowUtil.getFetchDescriptorConstant(
                        scratch_template.length - 1);

                // 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))
                    {
                        // try to get an exclusive lock on the row, if we can
                        // then the row is a committed deleted row and it is
                        // safe to purge it.
                        if (btree_locking_policy.lockScanCommittedDeletedRow(
                                open_btree, leaf, scratch_template,
                                lock_fetch_desc, slot_no))
                        {
                            // the row is a committed deleted row, purge it.
                            page.purgeAtSlot(slot_no, 1, true);

                            purged_at_least_one_row = true;
                        }
                    }
                }
View Full Code Here


        // need to open the container and insert the row.  Since we are
        // creating it no need to bother with locking since no one can get
        // to it until after we have created it and returned it's id.
        ContainerHandle container = null;
        Page            page      = null;

        try
        {
            container =
                rawtran.openContainer(
                    id, (LockingPolicy) null,
                    ContainerHandle.MODE_FORUPDATE |
                        (isTemporary() ? ContainerHandle.MODE_TEMP_IS_KEPT : 0));

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

            page =
                container.getPage(ContainerHandle.FIRST_PAGE_NUMBER);

            page.insertAtSlot(
                Page.FIRST_SLOT_NUMBER,
                control_row,
                (FormatableBitSet) null,
                (LogicalUndo) null,
                Page.INSERT_OVERFLOW,
                AccessFactoryGlobals.HEAP_OVERFLOW_THRESHOLD);
            page.unlatch();
            page = null;

            // Don't include the control row in the estimated row count.
            container.setEstimatedRowCount(0, /* unused flag */ 0);
        }
        finally
        {
            if (container != null)
                container.close();
            if (page !=null)
                page.unlatch();
        }
  }
View Full Code Here

        throws StandardException
    {
        // need to open the container and update the row containing the
        // serialized format of the heap. 
        ContainerHandle container = null;
        Page            page      = null;
        Transaction     rawtran   = xact_manager.getRawStoreXact();

        try
        {
            container =
                rawtran.openContainer(
                    id,
                    rawtran.newLockingPolicy(
                        LockingPolicy.MODE_CONTAINER,
                        TransactionController.ISOLATION_SERIALIZABLE, true),
                    ContainerHandle.MODE_FORUPDATE |
                        (isTemporary() ? ContainerHandle.MODE_TEMP_IS_KEPT : 0));

            if (column_id != format_ids.length)
            {
                if (SanityManager.DEBUG)
                    SanityManager.THROWASSERT(
                        "column_id = " + column_id +
                        "format_ids.length = " + format_ids.length +
                        "format_ids = " + format_ids);

                throw(StandardException.newException(
                        SQLState.HEAP_TEMPLATE_MISMATCH,
                        new Long(column_id),
                        new Long(this.format_ids.length)));
            }

            // create a new array, and copy old values to it.
            int[] old_format_ids = format_ids;
            format_ids              = new int[old_format_ids.length + 1];
            System.arraycopy(
                old_format_ids, 0, format_ids, 0, old_format_ids.length);

            // add the new column
            format_ids[old_format_ids.length] =
                template_column.getTypeFormatId();

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

            page =
                container.getPage(ContainerHandle.FIRST_PAGE_NUMBER);

            page.updateAtSlot(
                Page.FIRST_SLOT_NUMBER,
                control_row,
                (FormatableBitSet) null);

            page.unlatch();
            page = null;
        }
        finally
        {
            if (container != null)
                container.close();
            if (page !=null)
                page.unlatch();
        }

        return;
    }
View Full Code Here

            heapcontroller = new HeapController();

            heapcontroller.init(open_conglom);

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

            boolean purgingDone = false;

            while (page != null)
            {
                long pageno = page.getPageNumber();
                purgingDone = heapcontroller.purgeCommittedDeletes(page);

                if (purgingDone)
                {
                    page = null;

                    // commit xact to free resouurces ASAP, commit will
                    // unlatch the page if it has not already been unlatched
                    // by a remove.
                    open_conglom.getXactMgr().commitNoSync(
                                TransactionController.RELEASE_LOCKS);

                    // the commit closes the underlying container, so let
                    // the heapcontroller know this has happened.  Usually
                    // the transaction takes care of this, but this controller
                    // is internal, so the transaction does not know about it.
                    heapcontroller.closeForEndTransaction(false);
                   
                    // the commit will close the underlying
                    open_conglom.reopen();
                }
                else
                {
                    page.unlatch();
                    page = null;
                }

                page = open_conglom.getContainer().getNextPage(pageno);
            }
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

                    {
                        scan_position.current_positionKey =
                            runtime_mem.get_row_for_export(getRawTran());


                        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

            // 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

            // Reposition to remembered spot on page.

            // Get the page object. If getPage() returns null, the page is
            // not valid (could for instance have been removed by compress
            // table) so we need to reposition by key instead.
            Page page = container.getPage(pos.current_rh.getPageNumber());
            if (page != null) {
                ControlRow row =
                        ControlRow.getControlRowForPage(container, page);
                if (row instanceof LeafControlRow &&
                        !row.page.isRepositionNeeded(pos.versionWhenSaved)) {
View Full Code Here

     */
    void savePositionAndReleasePage(DataValueDescriptor[] partialKey,
                                    int[] vcols)
            throws StandardException {

        final Page page = scan_position.current_leaf.getPage();

        if (SanityManager.DEBUG) {
            SanityManager.ASSERT(page.isLatched(), "Page is not latched");
            SanityManager.ASSERT(scan_position.current_positionKey == null,
                                 "Scan position already saved");

            if (partialKey == null) {
                SanityManager.ASSERT(vcols == null);
            }
            if (vcols != null) {
                SanityManager.ASSERT(partialKey != null);
                SanityManager.ASSERT(vcols.length <= partialKey.length);
            }
        }

        try {
            DataValueDescriptor[] fullKey = scan_position.getKeyTemplate();

            FetchDescriptor fetchDescriptor = null;
            boolean haveAllColumns = false;
            if (partialKey != null) {
                int copiedCols = 0;
                final int partialKeyLength =
                        (vcols == null) ? partialKey.length : vcols.length;
                for (int i = 0; i < partialKeyLength; i++) {
                    if (vcols == null || vcols[i] != 0) {
                        fullKey[i].setValue(partialKey[i]);
                        copiedCols++;
                    }
                }
                if (copiedCols < fullKey.length) {
                    fetchDescriptor =
                            scan_position.getFetchDescriptorForSaveKey(
                            vcols, fullKey.length);
                } else {
                    haveAllColumns = true;
                }
            }

            if (!haveAllColumns) {
                RecordHandle rh = page.fetchFromSlot(
                        (RecordHandle) null,
                        scan_position.current_slot,
                        fullKey,
                        fetchDescriptor,
                        true);

                if (SanityManager.DEBUG) {
                    SanityManager.ASSERT(rh != null, "Row not found");
                }
            }

            scan_position.current_positionKey = fullKey;
            // Don't null out current_rh, we might be able to use it later if
            // no rows are moved off the page.
            //scan_position.current_rh = null;
            scan_position.versionWhenSaved = page.getPageVersion();
            scan_position.current_slot = Page.INVALID_SLOT_NUMBER;

        } finally {
            scan_position.current_leaf.release();
            scan_position.current_leaf = null;
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

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.