Search in sources :

Example 1 with ContainerKey

use of org.apache.derby.iapi.store.raw.ContainerKey in project derby by apache.

the class BaseDataFileFactory method addAndLoadStreamContainer.

/**
 * Add and load a stream container
 *		@exception StandardException Standard Derby error policy
 */
public long addAndLoadStreamContainer(RawTransaction t, long segmentId, Properties tableProperties, RowSource rowSource) throws StandardException {
    long containerId = getNextId();
    ContainerKey identity = new ContainerKey(segmentId, containerId);
    // create and load the stream container
    StreamFileContainer sContainer = new StreamFileContainer(identity, this, tableProperties);
    sContainer.load(rowSource);
    return containerId;
}
Also used : ContainerKey(org.apache.derby.iapi.store.raw.ContainerKey)

Example 2 with ContainerKey

use of org.apache.derby.iapi.store.raw.ContainerKey in project derby by apache.

the class Heap method boot_create.

/**
 * Create a heap conglomerate during the boot process.
 * <p>
 * Manufacture a Heap Conglomerate out of "thin" air, to boot strap
 * the system.  Create an in-memory Heap Conglomerate with the input
 * parameters, The caller will use this to open the conglomerate
 * conglomerate and read the "real" values from disk.  Conglom-conglom
 * is always on segment 0.
 *
 * @param containerid The container id of the conglomerate.
 * @param template    Object array describing the columns of the heap.
 */
public void boot_create(long containerid, DataValueDescriptor[] template) {
    id = new ContainerKey(0, containerid);
    this.format_ids = ConglomerateUtil.createFormatIds(template);
}
Also used : ContainerKey(org.apache.derby.iapi.store.raw.ContainerKey)

Example 3 with ContainerKey

use of org.apache.derby.iapi.store.raw.ContainerKey in project derby by apache.

the class BTree method create.

/**
 *	Do the generic part of creating a b-tree conglomerate.  This method
 *    is called from the concrete subclass (which may also read some properties).
 *    <p>
 *    This method processes all properties which are generic to all BTree's.  It
 *    creates the container for the btree.
 *    <p>
 *
 *    The following properties are generic to a b-tree conglomerate.  :
 *
 *    <UL>
 *    <LI>"allowDuplicates" (boolean).  If set to true the table will allow
 *    rows which are duplicate in key column's 0 through (nUniqueColumns - 1).
 *    Currently only supports "false".
 *    This property is optional, defaults to false.
 *    <LI>"nKeyFields"  (integer) Columns 0 through (nKeyFields - 1) will be
 *    included in key of the conglomerate.
 *    This implementation requires that "nKeyFields" must be the same as the
 *    number of fields in the conglomerate, including the rowLocationColumn.
 *    Other implementations may relax this restriction to allow non-key fields
 *    in the index.
 *    This property is required.
 *    <LI>"nUniqueColumns" (integer) Columns 0 through "nUniqueColumns" will be
 *    used to check for uniqueness.  So for a standard SQL non-unique index
 *    implementation set "nUniqueColumns" to the same value as "nKeyFields"; and
 *    for a unique index set "nUniqueColumns" to "nKeyFields" - 1 (ie. don't
 *    include the rowLocationColumn in the uniqueness check).
 *    This property is required.
 *    <LI>"maintainParentLinks" (boolean)
 *    Whether the b-tree pages maintain the page number of their parent.  Only
 *    used for consistency checking.  It takes a certain amount more effort to
 *    maintain these links, but they're really handy for ensuring that the index
 *    is consistent.
 *    This property is optional, defaults to true.
 *    </UL>
 *
 *    @exception StandardException Thrown by underlying raw store, or thrown by
 *    this routine on an invalid containerid.
 */
public void create(Transaction rawtran, int segmentId, long input_containerid, DataValueDescriptor[] template, Properties properties, int conglom_format_id, int tmpFlag) throws StandardException {
    String result_string;
    if (properties == null) {
        throw (StandardException.newException(SQLState.BTREE_PROPERTY_NOT_FOUND, PROPERTY_NKEYFIELDS));
    }
    // Check input arguments
    allowDuplicates = (Boolean.valueOf(properties.getProperty(PROPERTY_ALLOWDUPLICATES, "false"))).booleanValue();
    result_string = properties.getProperty(PROPERTY_NKEYFIELDS);
    if (result_string == null) {
        throw (StandardException.newException(SQLState.BTREE_PROPERTY_NOT_FOUND, PROPERTY_NKEYFIELDS));
    } else {
        nKeyFields = Integer.parseInt(result_string);
    }
    result_string = properties.getProperty(PROPERTY_NUNIQUECOLUMNS);
    if (result_string == null) {
        throw (StandardException.newException(SQLState.BTREE_PROPERTY_NOT_FOUND, PROPERTY_NUNIQUECOLUMNS));
    } else {
        nUniqueColumns = Integer.parseInt(result_string);
    }
    result_string = properties.getProperty(PROPERTY_UNIQUE_WITH_DUPLICATE_NULLS, "false");
    uniqueWithDuplicateNulls = Boolean.parseBoolean(result_string);
    if (SanityManager.DEBUG) {
        result_string = properties.getProperty(PROPERTY_MAX_ROWS_PER_PAGE_PARAMETER);
        if (result_string != null) {
            maxRowsPerPage = Integer.parseInt(result_string);
        }
    }
    maintainParentLinks = (Boolean.valueOf(properties.getProperty(PROPERTY_PARENTLINKS, "true"))).booleanValue();
    // fields eventually this assert may be wrong.
    if (SanityManager.DEBUG) {
        if (template.length != nKeyFields) {
            SanityManager.THROWASSERT("template.length (" + template.length + ") expected to equal nKeyFields (" + nKeyFields + ")");
        }
        SanityManager.ASSERT((nUniqueColumns == nKeyFields) || (nUniqueColumns == (nKeyFields - 1)));
    }
    // get format id's from each column in template and store it in the
    // conglomerate state.
    format_ids = ConglomerateUtil.createFormatIds(template);
    // copy the format id of the conglomerate.
    this.conglom_format_id = conglom_format_id;
    // Create a container for the b-tree with default page size and
    // fill up pages.
    properties.put(RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER, "0");
    properties.put(RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER, "1");
    properties.put(RawStoreFactory.PAGE_REUSABLE_RECORD_ID, "true");
    long containerid = rawtran.addContainer(segmentId, input_containerid, ContainerHandle.MODE_DEFAULT, properties, tmpFlag);
    // Open segment will get cleaned up when transaction is.
    if (containerid <= 0) {
        throw (StandardException.newException(SQLState.BTREE_CANT_CREATE_CONTAINER));
    }
    if (SanityManager.DEBUG) {
        if (input_containerid != ContainerHandle.DEFAULT_ASSIGN_ID)
            SanityManager.ASSERT(containerid == input_containerid);
    }
    id = new ContainerKey(segmentId, containerid);
}
Also used : ContainerKey(org.apache.derby.iapi.store.raw.ContainerKey)

Example 4 with ContainerKey

use of org.apache.derby.iapi.store.raw.ContainerKey in project derby by apache.

the class D_DiagnosticUtil method diag_dump_page.

/**
 * Dump raw contents of a page.
 * <p>
 * A utility routine that can be called from an ij session that will
 * dump the raw contents of a page, in the raw store dump format.
 *
 * @param db_name       name of the database
 * @param segmentid     segmentid of the table (usually 0)
 * @param containerid   containerid of the table (not conglomid)
 * @param pagenumber    pagenumber of page to dump.
 */
public static void diag_dump_page(String db_name, long segmentid, long containerid, long pagenumber) {
    Transaction xact = null;
    try {
        Object module = getModuleFromDbName(db_name);
        RawStoreFactory store_module = (RawStoreFactory) findServiceModule(module, RawStoreFactory.MODULE);
        xact = store_module.startInternalTransaction(FileContainer.getContextService().getCurrentContextManager());
        ContainerKey id = new ContainerKey(segmentid, containerid);
        ContainerHandle container = xact.openContainer(id, ContainerHandle.MODE_READONLY);
        Page page = container.getPage(pagenumber);
        if (page != null) {
            System.out.println(page.toString());
            page.unlatch();
        } else {
            System.out.println("page " + pagenumber + " not found");
        }
        xact.abort();
        xact.close();
        xact = null;
    } catch (StandardException se) {
        se.printStackTrace();
    } finally {
        if (xact != null) {
            try {
                xact.abort();
                xact.close();
            } catch (StandardException se) {
            }
        }
    }
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) Transaction(org.apache.derby.iapi.store.raw.Transaction) Page(org.apache.derby.iapi.store.raw.Page) ContainerKey(org.apache.derby.iapi.store.raw.ContainerKey) RawStoreFactory(org.apache.derby.iapi.store.raw.RawStoreFactory) ContainerHandle(org.apache.derby.iapi.store.raw.ContainerHandle)

Example 5 with ContainerKey

use of org.apache.derby.iapi.store.raw.ContainerKey in project derby by apache.

the class D_BaseContainerHandle method diag_detail.

/**
 * Return a set of properties describing the the key used to lock container.
 * <p>
 * Used by debugging code to print the lock table on demand.
 *
 * @exception  StandardException  Standard exception policy.
 */
public void diag_detail(Properties prop) throws StandardException {
    BaseContainerHandle ch = (BaseContainerHandle) diag_object;
    ContainerKey key = ch.getId();
    prop.put(RowLock.DIAG_CONTAINERID, Long.toString(key.getContainerId()));
    prop.put(RowLock.DIAG_SEGMENTID, Long.toString(key.getSegmentId()));
    // The following 2 don't make sense for container locks, just set
    // them to 0 to make it easier for now to tree container locks and
    // row locks similarly.
    prop.put(RowLock.DIAG_PAGENUM, Integer.toString(0));
    prop.put(RowLock.DIAG_RECID, Integer.toString(0));
    return;
}
Also used : ContainerKey(org.apache.derby.iapi.store.raw.ContainerKey)

Aggregations

ContainerKey (org.apache.derby.iapi.store.raw.ContainerKey)16 ContainerHandle (org.apache.derby.iapi.store.raw.ContainerHandle)4 LockingPolicy (org.apache.derby.iapi.store.raw.LockingPolicy)3 Page (org.apache.derby.iapi.store.raw.Page)3 StreamContainerHandle (org.apache.derby.iapi.store.raw.StreamContainerHandle)3 RawContainerHandle (org.apache.derby.iapi.store.raw.data.RawContainerHandle)2 StandardException (org.apache.derby.shared.common.error.StandardException)2 RawStoreFactory (org.apache.derby.iapi.store.raw.RawStoreFactory)1 RecordHandle (org.apache.derby.iapi.store.raw.RecordHandle)1 Transaction (org.apache.derby.iapi.store.raw.Transaction)1 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)1