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

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


    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
View Full Code Here


    // container to be removed.

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

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

    if (callbackWithRowLocation)
      rowlocation = new HeapRowLocation();
    else
View Full Code Here

        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;

        // Open the btree to associate the open contain handle, thus the
        // current xact with all subsequent operations during undo.


        try
        {

            // Need Conglomerate to create templates - get from the root page.
            root = ControlRow.Get(container, BTree.ROOTPAGEID);

            if (SanityManager.DEBUG)
                SanityManager.ASSERT(root.getPage().isLatched());

            btree = (B2I) root.getConglom(B2I.FORMAT_NUMBER);

            if (SanityManager.DEBUG)
                SanityManager.ASSERT(btree instanceof B2I);

            // create a template for the logged index row from the conglomerate.
            logged_index_row_template = btree.createTemplate();

            // create a template for the page index row from the conglomerate.
            template                  = btree.createTemplate();
        }
        finally
        {
            if (root != null)
                root.release();
        }

        // Get logged row from record.
        pageOp.restoreLoggedRow(logged_index_row_template, in);

        // RESOLVE (mikem) - currently restoreLoggedRow() may latch and unlatch
        // a page in the container (see ST059).
        // Now get the page where the record used to be.

        ok_exit = false;
        try
        {
            // "open" the btree, using recovery's already opened container
            OpenBTree open_btree = new OpenBTree();

            open_btree.init(
                (TransactionManager) null,  // current user xact - not needed
                (TransactionManager) null,  // current xact      - not needed
                pageOp.getContainer(),      // recovery already opened container
                rawtran,
                false,
                ContainerHandle.MODE_FORUPDATE,
                                            // open_mode not used - container is
                                            // already opened.
                TransactionManager.MODE_NONE,
                (BTreeLockingPolicy) null,  // don't get locks during undo
                btree,                      
                (LogicalUndo) null,         // no logical undo necessary, as
                                            // this code only does read.
                (DynamicCompiledOpenConglomInfo) null);

            // System.out.println(
              //   "calling logical undo, recordhandle = " + rechandle);
            // System.out.println("calling logical undo, record= " +
              //    logged_index_row_template);

            // Get the page where the record was originally, before splits
            // could have possibly moved it.
            control_row = ControlRow.Get(open_btree, rechandle.getPageNumber());

            // init compare_result, if record doesn't exist do the search
            compare_result = 1;

            if (control_row.getPage().recordExists(rechandle, true))
            {

                if (SanityManager.DEBUG)
                {
                    SanityManager.ASSERT(
                        control_row.getPage().fetchNumFields(rechandle) ==
                        logged_index_row_template.length);
                }

                // create template for the page index row from the conglomerate.
                RecordHandle ret_rechandle =
                    control_row.getPage().fetchFromSlot(
                        (RecordHandle) null,
                        control_row.getPage().getSlotNumber(rechandle),
                        template,
                        (FetchDescriptor) null,
                        true);

                // compare the 2 rows, and if they are the same then the raw
                // store has the right page and record and there is no work to
                // be done (this is usual case).
                compare_result = ControlRow.CompareIndexRowToKey(
                    template, logged_index_row_template,
                    logged_index_row_template.length, 1,
                    open_btree.getColumnSortOrderInfo());
            }

            if (compare_result == 0)
            {
                ret_page = control_row.getPage();
            }
            else
            {
                // if the 2 don't compare equal, search the btree from the root
                // for the logged row, find the leaf, reset the row for the raw
                // store, and return the new page latched.
               
                // Create the objects needed for the insert.
                SearchParameters sp = new SearchParameters(
                        logged_index_row_template, ScanController.GE,
                        template, open_btree, false);

                control_row.release();
                control_row = null;
                control_row =
                    ControlRow.Get(open_btree, BTree.ROOTPAGEID).search(sp);

                if (!sp.resultExact)
                {
                    if (SanityManager.DEBUG)
                    {
                        SanityManager.THROWASSERT(
                            "B2IUndo - could not find key being searched for:" +
                            ";key = " +
                                RowUtil.toString(logged_index_row_template) +
                            ";sp = " + sp +
                            "control_row = " + control_row +
                            "control_row.debugPage() = " +
                                control_row.debugPage(open_btree) +
                            "control_row.getPage() = " +
                                control_row.getPage());
                    }

                    throw StandardException.newException(
                            SQLState.BTREE_ROW_NOT_FOUND_DURING_UNDO);
                }
                else
                {
                    RecordHandle rh =
                        control_row.getPage().fetchFromSlot(
                            (RecordHandle) null,
                            sp.resultSlot, new DataValueDescriptor[0],
                            (FetchDescriptor) null,
                            true);
View Full Code Here

            }


            // Do a fetch just to get the RecordHandle for the delete call,
            // don't fetch any columns.
            RecordHandle delete_rh =
                scan_position.current_leaf.page.fetchFromSlot(
                    (RecordHandle) null, scan_position.current_slot,
                    RowUtil.EMPTY_ROW, (FetchDescriptor) null, true);

            ret_val =
View Full Code Here


                        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,
View Full Code Here

                    scan_position.current_rh.getPageNumber())
            {
                scan_position.current_positionKey =
                    runtime_mem.get_row_for_export();

                RecordHandle rh =
                    page.fetchFromSlot(
                        (RecordHandle) null,
                        page.getSlotNumber(scan_position.current_rh),
                        scan_position.current_positionKey,
                        (FetchDescriptor) null,
View Full Code Here

    BTreeRowPosition        pos,
    DataValueDescriptor[]   fetch_row)
        throws StandardException
  {
        int                 ret_row_count     = 0;
        RecordHandle        max_rh            = null;

        // we need to scan until we hit the end of the table or until we
        // run into a null.  Use this template to probe the "next" row so
        // that if we need to finish, fetch_row will have the right value.
        DataValueDescriptor[] check_row_template = new DataValueDescriptor[1];
        check_row_template[0] = fetch_row[0].getClone();
        FetchDescriptor check_row_desc = RowUtil.getFetchDescriptorConstant(1);

        // reopen the scan for reading from the beginning of the table.
        reopenScan(
            (DataValueDescriptor[]) null,
            ScanController.NA,
            (Qualifier[][]) null,
            (DataValueDescriptor[]) null,
            ScanController.NA);

        positionAtStartForForwardScan(pos);

        // At this point:
        // current_page is latched.  current_slot is the slot on current_page
        // just before the "next" record this routine should process.

        // loop through successive leaf pages and successive slots on those
        // leaf pages.  Stop when either the last leaf is reached. At any
        // time in the scan fetch_row will contain "last" non-deleted row
        // seen.

        boolean nulls_not_reached = true;
    while ((pos.current_leaf != null) && nulls_not_reached)
    {
      while ((pos.current_slot + 1) < pos.current_leaf.page.recordCount())
      {
                // unlock the previous row if doing read.
                if (pos.current_rh != null)
                {
                    this.getLockingPolicy().unlockScanRecordAfterRead(
                        pos, init_forUpdate);

                    // current_rh is used to track which row we need to unlock,
                    // at this point no row needs to be unlocked.
                    pos.current_rh = null;
                }

                // move scan current position forward.
                pos.current_slot++;
                this.stat_numrows_visited++;

                // get current record handle for positioning but don't read
                // data until we verify it is not deleted.  rh is needed
                // for repositioning if we lose the latch.
                RecordHandle rh =
                    pos.current_leaf.page.fetchFromSlot(
                        (RecordHandle) null,
                        pos.current_slot,
                        check_row_template,
                        null,
View Full Code Here

                this.stat_numrows_visited++;

                // get current record handle for positioning but don't read
                // data until we verify it is not deleted.  rh is needed
                // for repositioning if we lose the latch.
                RecordHandle rh =
                    pos.current_leaf.page.fetchFromSlot(
                        (RecordHandle) null,
                        pos.current_slot, fetch_row, init_fetchDesc,
                        true);
View Full Code Here

                    open_conglom.getContainer().getId(),
                    new Long(scan_position.current_rh.getId()));
        }

        // RESOLVE (mikem) - should this call apply the qualifiers again?
        RecordHandle rh =
            scan_position.current_page.fetchFromSlot(
                scan_position.current_rh,
                scan_position.current_slot,
                row,
                qualify ? init_fetchDesc : null,
View Full Code Here

                {
                    int numrows   = page.recordCount();

                    for (int slot_no = start_slot; slot_no < numrows; slot_no++)
                    {
                        RecordHandle rh =
                            page.fetchFromSlot(
                               (RecordHandle) null, slot_no, template,
                               (FetchDescriptor) null,
                               true);

                        // pre-pend either "D:" if deleted, or " :" if not.
                        string.append(
                            page.isDeletedAtSlot(slot_no) ? "D:" : " :");

                        // row[slot,id]:
                        string.append("row[");
                        string.append(slot_no);
                        string.append("](id:");
                        string.append(rh.getId());
                        string.append("):\t");

                        // long record handle:
                        //   Record id=78 Page(31,Container(0, 919707766934))
                        if (full_rh)
                        {
                            string.append("[");
                            string.append(rh.toString());
                            string.append("]:");
                        }

                        // row:
                        string.append(RowUtil.toString(template));
View Full Code Here

TOP

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

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.