Search in sources :

Example 1 with FetchDescriptor

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

the class ControlRow method checkRowOrder.

/**
 ** Check that all rows on the page are in order.  This
 ** means that each key is > than the previous key.
 *
 *    @exception StandardException Standard exception policy.
 */
protected boolean checkRowOrder(OpenBTree btree, ControlRow parent) throws StandardException {
    if (SanityManager.DEBUG) {
        RecordHandle lesser_handle = null;
        RecordHandle greater_handle = null;
        DataValueDescriptor[] lesser = getRowTemplate(btree);
        DataValueDescriptor[] greater = getRowTemplate(btree);
        boolean is_consistent = true;
        int numslots = page.recordCount();
        for (int i = ControlRow.CR_SLOT + 1; (i + 1) < numslots; i++) {
            lesser_handle = page.fetchFromSlot((RecordHandle) null, i, lesser, (FetchDescriptor) null, true);
            greater_handle = page.fetchFromSlot((RecordHandle) null, i + 1, greater, (FetchDescriptor) null, true);
            SanityManager.ASSERT(btree.getConglomerate().nUniqueColumns <= btree.getConglomerate().nKeyFields);
            int compare_result = compareIndexRowToKey(lesser, greater, btree.getConglomerate().nUniqueColumns, 0, btree.getConglomerate().ascDescInfo);
            // >= 0 means that lesser >= greater
            if (compare_result >= 0) {
                SanityManager.THROWASSERT("Bad order of rows found in conglomerate: " + btree + "\n." + "compare result = " + compare_result + ".  " + "nKeyFields = " + btree.getConglomerate().nKeyFields + ".\n" + this + " rows " + (i) + " and " + (i + 1) + " out of order.\n" + "row[" + i + "] + " + RowUtil.toString(lesser) + "\n" + "row[" + (i + 1) + "] + " + RowUtil.toString(greater) + "\ndump of page = " + debugPage(btree) + "\ndump of parent page = " + ((parent != null) ? parent.debugPage(btree) : "null parent") + "\rawstore dump = " + this.page);
                is_consistent = false;
            }
        }
        return (is_consistent);
    } else {
        return (true);
    }
}
Also used : RecordHandle(org.apache.derby.iapi.store.raw.RecordHandle) FetchDescriptor(org.apache.derby.iapi.store.raw.FetchDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Example 2 with FetchDescriptor

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

the class LeafControlRow method initEmptyBtree.

/**
 * Initialize conglomerate with one page, to be a 1 page btree.
 *
 * Given a conglomerate which already has one page allocated to it,
 * initialize the page to be a leaf-root page with no entries.  Allocate
 * the control row and store it on the page.
 *
 * @param open_btree The open btree to initialize (container is open).
 *
 * @exception StandardException Standard exception policy.
 */
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;
}
Also used : RecordHandle(org.apache.derby.iapi.store.raw.RecordHandle) FetchDescriptor(org.apache.derby.iapi.store.raw.FetchDescriptor) Page(org.apache.derby.iapi.store.raw.Page) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor)

Example 3 with FetchDescriptor

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

the class BasePage method fetchFieldFromSlot.

/**
 *		@exception StandardException	Standard Derby error policy
 *		@see Page#fetchFieldFromSlot
 */
public final RecordHandle fetchFieldFromSlot(int slot, int fieldId, Object column) throws StandardException {
    // need to allocate row with fieldId cols because of sparse row change
    // needs to be RESOLVED
    Object[] row = new Object[fieldId + 1];
    row[fieldId] = column;
    FetchDescriptor fetchDesc = new FetchDescriptor(fieldId + 1, fieldId);
    return (fetchFromSlot(null, slot, row, fetchDesc, true));
}
Also used : FetchDescriptor(org.apache.derby.iapi.store.raw.FetchDescriptor) AuxObject(org.apache.derby.iapi.store.raw.AuxObject)

Example 4 with FetchDescriptor

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

the class GenericConglomerateController method fetch.

/**
 * @see ConglomerateController#fetch
 */
public boolean fetch(RowLocation loc, DataValueDescriptor[] row, FormatableBitSet validColumns, boolean waitForLock) throws StandardException {
    if (open_conglom.isClosed()) {
        if (open_conglom.getHold()) {
            if (open_conglom.isClosed())
                open_conglom.reopen();
        } else {
            throw (StandardException.newException(SQLState.HEAP_IS_CLOSED, open_conglom.getConglomerate().getId()));
        }
    }
    if (SanityManager.DEBUG) {
        // Make sure valid columns are in the list.  The RowUtil
        // call is too expensive to make in a released system for
        // every fetch.
        int invalidColumn = RowUtil.columnOutOfRange(row, validColumns, open_conglom.getFormatIds().length);
        if (invalidColumn >= 0) {
            throw (StandardException.newException(SQLState.HEAP_TEMPLATE_MISMATCH, invalidColumn, open_conglom.getFormatIds().length));
        }
    }
    // Get the record handle out of its wrapper.
    RowPosition pos = open_conglom.getRuntimeMem().get_scratch_row_position();
    getRowPositionFromRowLocation(loc, pos);
    if (!open_conglom.latchPage(pos)) {
        return false;
    }
    if (open_conglom.isForUpdate()) {
        open_conglom.lockPositionForWrite(pos, waitForLock);
    } else {
        open_conglom.lockPositionForRead(pos, (RowPosition) null, false, waitForLock);
    }
    if (pos.current_page == null) {
        // false to indicate that the row is no longer valid. (DERBY-4676)
        return false;
    }
    // Fetch the row.
    // RESOLVE (STO061) - don't know whether the fetch is for update or not.
    // 
    // 
    // RESOLVE (mikem) - get rid of new here.
    boolean ret_val = (pos.current_page.fetchFromSlot(pos.current_rh, pos.current_slot, row, new FetchDescriptor(row.length, validColumns, (Qualifier[][]) null), false) != null);
    // and just always make the unlock call.
    if (!open_conglom.isForUpdate())
        open_conglom.unlockPositionAfterRead(pos);
    pos.current_page.unlatch();
    return (ret_val);
}
Also used : FetchDescriptor(org.apache.derby.iapi.store.raw.FetchDescriptor) Qualifier(org.apache.derby.iapi.store.access.Qualifier)

Example 5 with FetchDescriptor

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

the class GenericConglomerateController method fetch.

/**
 * @see ConglomerateController#fetch
 */
public boolean fetch(RowLocation loc, DataValueDescriptor[] row, FormatableBitSet validColumns) throws StandardException {
    if (open_conglom.isClosed()) {
        if (open_conglom.getHold()) {
            if (open_conglom.isClosed())
                open_conglom.reopen();
        } else {
            throw (StandardException.newException(SQLState.HEAP_IS_CLOSED, open_conglom.getConglomerate().getId()));
        }
    }
    if (SanityManager.DEBUG) {
        // Make sure valid columns are in the list.  The RowUtil
        // call is too expensive to make in a released system for
        // every fetch.
        int invalidColumn = RowUtil.columnOutOfRange(row, validColumns, open_conglom.getFormatIds().length);
        if (invalidColumn >= 0) {
            throw (StandardException.newException(SQLState.HEAP_TEMPLATE_MISMATCH, invalidColumn, open_conglom.getFormatIds().length));
        }
    }
    // Get the record handle out of its wrapper.
    RowPosition pos = open_conglom.getRuntimeMem().get_scratch_row_position();
    getRowPositionFromRowLocation(loc, pos);
    if (!open_conglom.latchPage(pos)) {
        return (false);
    }
    if (open_conglom.isForUpdate()) {
        open_conglom.lockPositionForWrite(pos, true);
    } else {
        open_conglom.lockPositionForRead(pos, (RowPosition) null, false, true);
    }
    if (pos.current_page == null) {
        // false to indicate that the row is no longer valid. (DERBY-4676)
        return false;
    }
    // Fetch the row.
    // RESOLVE (STO061) - don't know whether the fetch is for update or not.
    // 
    // RESOLVE (mikem) - get rid of new here.
    boolean ret_val = (pos.current_page.fetchFromSlot(pos.current_rh, pos.current_slot, row, new FetchDescriptor(row.length, validColumns, (Qualifier[][]) null), false) != null);
    if (!open_conglom.isForUpdate())
        open_conglom.unlockPositionAfterRead(pos);
    pos.current_page.unlatch();
    return (ret_val);
}
Also used : FetchDescriptor(org.apache.derby.iapi.store.raw.FetchDescriptor) Qualifier(org.apache.derby.iapi.store.access.Qualifier)

Aggregations

FetchDescriptor (org.apache.derby.iapi.store.raw.FetchDescriptor)16 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)9 Page (org.apache.derby.iapi.store.raw.Page)5 Qualifier (org.apache.derby.iapi.store.access.Qualifier)4 RecordHandle (org.apache.derby.iapi.store.raw.RecordHandle)4 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)3 AuxObject (org.apache.derby.iapi.store.raw.AuxObject)2 RowLocation (org.apache.derby.iapi.types.RowLocation)2 CounterOutputStream (org.apache.derby.iapi.services.io.CounterOutputStream)1 NullOutputStream (org.apache.derby.iapi.services.io.NullOutputStream)1 SQLLongint (org.apache.derby.iapi.types.SQLLongint)1 StorableFormatId (org.apache.derby.impl.store.access.StorableFormatId)1 StandardException (org.apache.derby.shared.common.error.StandardException)1