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);
}
}
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;
}
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));
}
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);
}
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);
}
Aggregations