Search in sources :

Example 1 with ConglomerateFactory

use of org.apache.derby.iapi.store.access.conglomerate.ConglomerateFactory in project derby by apache.

the class RAMTransaction method createConglomerate.

/**
 * Create a new conglomerate.
 * <p>
 * @see TransactionController#createConglomerate
 *
 * @exception  StandardException  Standard exception policy.
 */
public long createConglomerate(String implementation, DataValueDescriptor[] template, ColumnOrdering[] columnOrder, int[] collationIds, Properties properties, int temporaryFlag) throws StandardException {
    // Find the appropriate factory for the desired implementation.
    MethodFactory mfactory;
    mfactory = accessmanager.findMethodFactoryByImpl(implementation);
    if (mfactory == null || !(mfactory instanceof ConglomerateFactory)) {
        throw StandardException.newException(SQLState.AM_NO_SUCH_CONGLOMERATE_TYPE, implementation);
    }
    ConglomerateFactory cfactory = (ConglomerateFactory) mfactory;
    // Create the conglomerate
    // RESOLVE (mikem) - eventually segmentid's will be passed into here
    // in the properties.  For now just use 0.]
    int segment;
    long conglomid;
    if ((temporaryFlag & TransactionController.IS_TEMPORARY) == TransactionController.IS_TEMPORARY) {
        segment = ContainerHandle.TEMPORARY_SEGMENT;
        conglomid = ContainerHandle.DEFAULT_ASSIGN_ID;
    } else {
        // RESOLVE - only using segment 0
        segment = 0;
        conglomid = accessmanager.getNextConglomId(cfactory.getConglomerateFactoryId());
    }
    // call the factory to actually create the conglomerate.
    Conglomerate conglom = cfactory.createConglomerate(this, segment, conglomid, template, columnOrder, collationIds, properties, temporaryFlag);
    long conglomId;
    if ((temporaryFlag & TransactionController.IS_TEMPORARY) == TransactionController.IS_TEMPORARY) {
        conglomId = nextTempConglomId--;
        if (tempCongloms == null)
            tempCongloms = new HashMap<Long, Conglomerate>();
        tempCongloms.put(conglomId, conglom);
    } else {
        conglomId = conglom.getContainerid();
        accessmanager.conglomCacheAddEntry(conglomId, conglom);
    }
    return conglomId;
}
Also used : MethodFactory(org.apache.derby.iapi.store.access.conglomerate.MethodFactory) ConglomerateFactory(org.apache.derby.iapi.store.access.conglomerate.ConglomerateFactory) HashMap(java.util.HashMap) Conglomerate(org.apache.derby.iapi.store.access.conglomerate.Conglomerate)

Example 2 with ConglomerateFactory

use of org.apache.derby.iapi.store.access.conglomerate.ConglomerateFactory in project derby by apache.

the class RAMAccessManager method boot_load_conglom_map.

private void boot_load_conglom_map() throws StandardException {
    // System.out.println("before new code.");
    conglom_map = new ConglomerateFactory[2];
    // Find the appropriate factory for the desired implementation.
    MethodFactory mfactory = findMethodFactoryByImpl("heap");
    if (mfactory == null || !(mfactory instanceof ConglomerateFactory)) {
        throw StandardException.newException(SQLState.AM_NO_SUCH_CONGLOMERATE_TYPE, "heap");
    }
    conglom_map[ConglomerateFactory.HEAP_FACTORY_ID] = (ConglomerateFactory) mfactory;
    // Find the appropriate factory for the desired implementation.
    mfactory = findMethodFactoryByImpl("BTREE");
    if (mfactory == null || !(mfactory instanceof ConglomerateFactory)) {
        throw StandardException.newException(SQLState.AM_NO_SUCH_CONGLOMERATE_TYPE, "BTREE");
    }
    conglom_map[ConglomerateFactory.BTREE_FACTORY_ID] = (ConglomerateFactory) mfactory;
// System.out.println("conglom_map[0] = " + conglom_map[0]);
// System.out.println("conglom_map[1] = " + conglom_map[1]);
}
Also used : MethodFactory(org.apache.derby.iapi.store.access.conglomerate.MethodFactory) ConglomerateFactory(org.apache.derby.iapi.store.access.conglomerate.ConglomerateFactory)

Example 3 with ConglomerateFactory

use of org.apache.derby.iapi.store.access.conglomerate.ConglomerateFactory in project derby by apache.

the class RAMAccessUndoHandler method insertUndoNotify.

/**
 ************************************************************************
 * Private/Protected methods of This class:
 **************************************************************************
 */
/**
 ************************************************************************
 * Public Methods of This class:
 **************************************************************************
 */
/**
 * Interface to be called when an undo of an insert is processed.
 * <p>
 * Implementer of this class provides interface to be called by the raw
 * store when an undo of an insert is processed.  Initial implementation
 * will be by Access layer to queue space reclaiming events if necessary
 * when a rows is logically "deleted" as part of undo of the original
 * insert.  This undo can happen a lot for many applications if they
 * generate expected and handled duplicate key errors.
 * <p>
 * It may be useful at some time to include the recordId of the deleted
 * row, but it is not used currently by those notified.  The post commit
 * work ultimately processes all rows on the table while
 * it has the latch which is more efficient than one row at time per latch.
 * <p>
 * It is expected that notifies only happen for pages that caller
 * is interested in.  Currently only the following aborted inserts
 * cause a notify:
 * o must be on a non overflow page
 * o if all "user" rows on page are deleted a notify happens (page 1
 *   has a system row so on page one notifies happen if all but the first
 *   row is deleted).
 * o if the aborted insert row has either an overflow row or column
 *   component then the notify is executed.
 *
 * @param xact      transaction that is being backed out.
 * @param page_key  key that uniquely identifies page in question, container
 *                  key information is embedded in the PageKey
 *
 * @exception  StandardException  Standard exception policy.
 */
public void insertUndoNotify(Transaction xact, PageKey page_key) throws StandardException {
    // from the container id, get the type of conglomerate (currently
    // Heap or Btree), and then marshal the call to the appropriate
    // conglomerate factory.
    long conglom_id = page_key.getContainerId().getContainerId();
    // casting to get package access to getFactoryFromConglomId,
    ConglomerateFactory conglom_factory = access_factory.getFactoryFromConglomId(conglom_id);
    try {
        conglom_factory.insertUndoNotify(access_factory, xact, page_key);
    } catch (StandardException exception) {
    // errors are likely related to abort of ddl associated
    // with inserts.  Just ignore and don't post try and post
    // a work event.
    // ignore exception
    }
    return;
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) ConglomerateFactory(org.apache.derby.iapi.store.access.conglomerate.ConglomerateFactory)

Aggregations

ConglomerateFactory (org.apache.derby.iapi.store.access.conglomerate.ConglomerateFactory)3 MethodFactory (org.apache.derby.iapi.store.access.conglomerate.MethodFactory)2 HashMap (java.util.HashMap)1 Conglomerate (org.apache.derby.iapi.store.access.conglomerate.Conglomerate)1 StandardException (org.apache.derby.shared.common.error.StandardException)1