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

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


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


  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

            SanityManager.ASSERT(container != null,
                "ControlRow.Get() is being called on a closed container.");
        }

    // Get the page, waiting if necessary.  The page is returned latched.
    Page page = container.getPage(pageNumber);

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

    long            pageNumber)
    throws StandardException
  {
    // Try to get the page without waiting.  If we would have
    // to wait, return null.
    Page page = open_btree.container.getUserPageNoWait(pageNumber);
    if (page == null)
      return null;

    // Got the page without waiting.  Return the corresponding
    // control row.
View Full Code Here

    private static LeafControlRow allocate(
    OpenBTree   btree,
    ControlRow  parent)
        throws StandardException
    {
        Page      page      = btree.container.addPage();

        // Create a control row for the new page.
        LeafControlRow control_row =
            new LeafControlRow(btree, page, parent, false);

        // Insert the control row on the page, in the first slot on the page.
        // This operation is only done as part of a new tree or split, which
        // which both will be undone physically so no logical undo record is
        // needed.
    byte insertFlag = Page.INSERT_INITIAL;
    insertFlag |= Page.INSERT_DEFAULT;
        RecordHandle rh =
            page.insertAtSlot(Page.FIRST_SLOT_NUMBER,
                control_row.getRow(),
                (FormatableBitSet) null,
                (LogicalUndo) null, insertFlag,
        AccessFactoryGlobals.BTREE_OVERFLOW_THRESHOLD);

        if (SanityManager.DEBUG)
        {
            RecordHandle    rh2 = null;

            rh2 = page.fetchFromSlot(
                    (RecordHandle) null, page.FIRST_SLOT_NUMBER,
                    new DataValueDescriptor[0], (FetchDescriptor) null, true);

            SanityManager.ASSERT(rh.getId() == rh2.getId() &&
                                 rh.getPageNumber() == rh2.getPageNumber());
View Full Code Here

     */
    public static void initEmptyBtree(
    OpenBTree   open_btree)
        throws StandardException
    {
        Page page =
            open_btree.container.getPage(ContainerHandle.FIRST_PAGE_NUMBER);

        // create a leaf control row for root page of a single page index //
        LeafControlRow control_row =
            new LeafControlRow(open_btree, page, null, true);

    byte insertFlag = Page.INSERT_INITIAL;
    insertFlag |= Page.INSERT_DEFAULT;
        RecordHandle rh =
            page.insertAtSlot(
                Page.FIRST_SLOT_NUMBER,
                control_row.getRow(),
                (FormatableBitSet) null,
                (LogicalUndo) null, insertFlag,
        AccessFactoryGlobals.BTREE_OVERFLOW_THRESHOLD);

        if (SanityManager.DEBUG)
        {
            RecordHandle    rh2 = null;

            rh2 = page.fetchFromSlot(
                    (RecordHandle) null,
                    Page.FIRST_SLOT_NUMBER,
                    new DataValueDescriptor[0], (FetchDescriptor) null, true);

            SanityManager.ASSERT(rh.getId() == rh2.getId() &&
                                 rh.getPageNumber() == rh2.getPageNumber());
        }

        if (SanityManager.DEBUG)
        {
            if (SanityManager.DEBUG_ON("enableBtreeConsistencyCheck"))
            {
                control_row.checkConsistency(
                    open_btree, (ControlRow) null, true);
            }
        }

        page.unlatch();

        return;
    }
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

            DataValueDescriptor[] row =
                runtime_mem.get_row_for_export(getRawTran());

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

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

    FormatableBitSet                 validColumns)
        throws StandardException
    {
        repositionScanForUpateOper();

        Page page = scan_position.current_page;
        int slot = scan_position.current_slot;

        if (SanityManager.DEBUG) {
            // DERBY-2197: Previously, we would try to get an exclusive row
            // lock here when the container was opened in row locking mode. In
            // most cases, the container is not opened in row locking mode. If
            // it is, and the open conglomerate uses update locks,
            // repositionScanForUpateOper() has already obtained an exclusive
            // row lock. We don't expect this method to be called unless these
            // conditions are satisfied, so now we just assert that no row
            // locking is required at this point.
            SanityManager.ASSERT(
                ((open_conglom.getContainer().getLockingPolicy().getMode() !=
                      LockingPolicy.MODE_RECORD) ||
                          (open_conglom.isUseUpdateLocks())),
                "Current mode of container requires row locking.");

            // make sure current_rh and current_slot are in sync
            SanityManager.ASSERT(
                slot == page.getSlotNumber(scan_position.current_rh));
        }

        boolean ret_val;
        if (page.isDeletedAtSlot(slot)) {
            ret_val = false;
        } else {
            page.updateAtSlot(slot, row, validColumns);
            ret_val = true;
        }

        scan_position.unlatch();
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.