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

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


    TransactionManager  xact_manager,
    ContainerKey        container_key)
    throws StandardException
    {
        Conglomerate    btree      = null;
        ContainerHandle container  = null;
        ControlRow      root       = null;

        try
        {
            // open readonly, with no locks.  Dirty read is ok as it is the
            // responsibility of client code to make sure this data is not
            // changing while being read.  The only changes that currently
            // happen to this data is creation and deletion - no updates
            // ever happen to btree conglomerates.
            container =
                (xact_manager.getRawStoreXact()).openContainer(
                    container_key,
                    (LockingPolicy) null,
                    ContainerHandle.MODE_READONLY);

            if (container == null)
            {
                // thrown a "known" error if the conglomerate does not exist
                // which is checked for explicitly by callers of the store
                // interface.

                throw StandardException.newException(
                    SQLState.STORE_CONGLOMERATE_DOES_NOT_EXIST,
                    new Long(container_key.getContainerId()));
            }

            // The conglomerate is located in the control row on the root page.
            root = ControlRow.get(container, BTree.ROOTPAGEID);

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

            // read the Conglomerate from it's entry in the control row.
            btree = (B2I) root.getConglom(B2I.FORMAT_NUMBER);

            if (SanityManager.DEBUG)
                SanityManager.ASSERT(btree instanceof B2I);
        }
        finally
        {

            if (root != null)
                root.release();

            if (container != null)
                container.close();
        }

        // if any error, just return null - meaning can't access the container.

        return(btree);
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

    Storable            template_column)
        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

    OpenConglomerate    open_conglom)
        throws StandardException
    {
        super.init(open_conglom);

        ContainerHandle container = open_conglom.getContainer();

        // look up costs from raw store.
        num_rows  = container.getEstimatedRowCount(/*unused flag*/ 0);

        // Don't use 0 rows (use 1 instead), as 0 rows often leads the
        // optimizer to produce plans which don't use indexes because of the 0
        // row edge case.
        //
        // Eventually the plan is recompiled when rows are added, but we
        // have seen multiple customer cases of deadlocks and timeouts
        // because of these 0 row based plans. 
        if (num_rows == 0)
            num_rows = 1;

        // eliminate the allocation page from the count.
        num_pages = container.getEstimatedPageCount(/* unused flag */ 0);

        Properties prop = new Properties();
        prop.put(Property.PAGE_SIZE_PARAMETER, "");
        container.getContainerProperties(prop);
        page_size =
            Integer.parseInt(prop.getProperty(Property.PAGE_SIZE_PARAMETER));

        row_size = (num_pages * page_size / num_rows);

View Full Code Here

        {
            SanityManager.DEBUG_PRINT("", "reclaimPrepareLocks().");
            SanityManager.ASSERT(getRecordHandle() != null);
        }

        ContainerHandle ch = t.openContainer(
            getPageId().getContainerId(), locking_policy,
            (ContainerHandle.MODE_FORUPDATE          |
             ContainerHandle.MODE_OPEN_FOR_LOCK_ONLY |
             ContainerHandle.MODE_LOCK_NOWAIT));

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

        if (ch != null)
            ch.close();

        /*
        // get the intent lock on the container.
        boolean lock_granted =
            locking_policy.lockContainer(
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

        hasCollatedTypes = hasCollatedColumns(collation_ids);

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

    int                 collation_id)
        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();

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

            // add the new column's collation id.
            collation_ids[old_collation_ids.length] =  collation_id;
          
            // 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

     **/
    public String diag()
        throws StandardException
    {
        long pageid;
        ContainerHandle container =
            ((HeapController) this.diag_object).getOpenConglom().getContainer();

        TableStats stat = new TableStats();

        // ask page to provide diag info:
        Properties prop = new Properties();
        prop.put(Page.DIAG_PAGE_SIZE,        "");
        prop.put(Page.DIAG_BYTES_FREE,       "");
        prop.put(Page.DIAG_BYTES_RESERVED,   "");
        prop.put(Page.DIAG_RESERVED_SPACE,   "");
        prop.put(Page.DIAG_MINIMUM_REC_SIZE, "");
        prop.put(Page.DIAG_NUMOVERFLOWED,    "");
        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

    public Conglomerate readConglomerate(
    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();
        }

        return((Conglomerate) control_row[0]);
    }
View Full Code Here

TOP

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

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.