use of org.apache.derby.iapi.store.access.conglomerate.ScanManager in project derby by apache.
the class RAMTransaction method openScan.
private ScanController openScan(Conglomerate conglom, boolean hold, int open_mode, int lock_level, int isolation_level, FormatableBitSet scanColumnList, DataValueDescriptor[] startKeyValue, int startSearchOperator, Qualifier[][] qualifier, DataValueDescriptor[] stopKeyValue, int stopSearchOperator, StaticCompiledOpenConglomInfo static_info, DynamicCompiledOpenConglomInfo dynamic_info) throws StandardException {
if (SanityManager.DEBUG) {
if ((open_mode & ~(TransactionController.OPENMODE_FORUPDATE | TransactionController.OPENMODE_USE_UPDATE_LOCKS | TransactionController.OPENMODE_FOR_LOCK_ONLY | TransactionController.OPENMODE_LOCK_NOWAIT | TransactionController.OPENMODE_LOCK_ROW_NOWAIT | TransactionController.OPENMODE_SECONDARY_LOCKED)) != 0) {
SanityManager.THROWASSERT("Bad open mode to openScan:" + Integer.toHexString(open_mode));
}
if (!((lock_level == MODE_RECORD | lock_level == MODE_TABLE))) {
SanityManager.THROWASSERT("Bad lock level to openScan:" + lock_level);
}
}
// Get a scan controller.
ScanManager sm = conglom.openScan(this, rawtran, hold, open_mode, determine_lock_level(lock_level), determine_locking_policy(lock_level, isolation_level), isolation_level, scanColumnList, startKeyValue, startSearchOperator, qualifier, stopKeyValue, stopSearchOperator, static_info, dynamic_info);
// Keep track of it so we can release on close.
scanControllers.add(sm);
return (sm);
}
use of org.apache.derby.iapi.store.access.conglomerate.ScanManager in project derby by apache.
the class RAMTransaction method defragmentConglomerate.
/**
* Compress table in place.
* <p>
* Returns a GroupFetchScanController which can be used to move rows
* around in a table, creating a block of free pages at the end of the
* table. The process will move rows from the end of the table toward
* the beginning. The GroupFetchScanController will return the
* old row location, the new row location, and the actual data of any
* row moved. Note that this scan only returns moved rows, not an
* entire set of rows, the scan is designed specifically to be
* used by either explicit user call of the SYSCS_ONLINE_COMPRESS_TABLE()
* procedure, or internal background calls to compress the table.
*
* The old and new row locations are returned so that the caller can
* update any indexes necessary.
*
* This scan always returns all collumns of the row.
*
* All inputs work exactly as in openScan(). The return is
* a GroupFetchScanController, which only allows fetches of groups
* of rows from the conglomerate.
* <p>
*
* @return The GroupFetchScanController to be used to fetch the rows.
*
* @param conglomId see openScan()
* @param hold see openScan()
* @param open_mode see openScan()
* @param lock_level see openScan()
* @param isolation_level see openScan()
*
* @exception StandardException Standard exception policy.
*
* @see ScanController
* @see GroupFetchScanController
*/
public GroupFetchScanController defragmentConglomerate(long conglomId, boolean online, boolean hold, int open_mode, int lock_level, int isolation_level) throws StandardException {
if (SanityManager.DEBUG) {
if ((open_mode & ~(TransactionController.OPENMODE_FORUPDATE | TransactionController.OPENMODE_FOR_LOCK_ONLY | TransactionController.OPENMODE_SECONDARY_LOCKED)) != 0)
SanityManager.THROWASSERT("Bad open mode to openScan:" + Integer.toHexString(open_mode));
if (!(lock_level == MODE_RECORD | lock_level == MODE_TABLE))
SanityManager.THROWASSERT("Bad lock level to openScan:" + lock_level);
}
// Find the conglomerate.
Conglomerate conglom = findExistingConglomerate(conglomId);
// Get a scan controller.
ScanManager sm = conglom.defragmentConglomerate(this, rawtran, hold, open_mode, determine_lock_level(lock_level), determine_locking_policy(lock_level, isolation_level), isolation_level);
// Keep track of it so we can release on close.
scanControllers.add(sm);
return (sm);
}
use of org.apache.derby.iapi.store.access.conglomerate.ScanManager in project derby by apache.
the class RAMTransaction method closeControllers.
/**
************************************************************************
* Private/Protected methods of This class:
**************************************************************************
*/
// XXX (nat) currently closes all controllers.
protected void closeControllers(boolean closeHeldControllers) throws StandardException {
if (!scanControllers.isEmpty()) {
// loop from end to beginning, removing scans which are not held.
for (int i = scanControllers.size() - 1; i >= 0; i--) {
ScanManager sc = scanControllers.get(i);
if (sc.closeForEndTransaction(closeHeldControllers)) {
// TODO - now counting on scan's removing themselves by
// calling the closeMe() method.
/* scanControllers.removeElementAt(i); */
}
}
if (closeHeldControllers) {
if (SanityManager.DEBUG) {
SanityManager.ASSERT(scanControllers.isEmpty());
}
// just to make sure everything has been closed and removed.
scanControllers.clear();
}
}
if (!conglomerateControllers.isEmpty()) {
// loop from end to beginning, removing scans which are not held.
for (int i = conglomerateControllers.size() - 1; i >= 0; i--) {
ConglomerateController cc = conglomerateControllers.get(i);
if (cc.closeForEndTransaction(closeHeldControllers)) {
// TODO - now counting on cc's removing themselves by
// calling the closeMe() method.
/* conglomerateControllers.removeElementAt(i); */
}
}
if (closeHeldControllers) {
if (SanityManager.DEBUG) {
SanityManager.ASSERT(scanControllers.isEmpty());
}
// just to make sure everything has been closed and removed.
conglomerateControllers.clear();
}
}
if ((sortControllers != null) && !sortControllers.isEmpty()) {
if (closeHeldControllers) {
// element from the list.
for (int i = sortControllers.size() - 1; i >= 0; i--) {
SortController sc = sortControllers.get(i);
sc.completedInserts();
}
sortControllers.clear();
}
}
if ((sorts != null) && (!sorts.isEmpty())) {
if (closeHeldControllers) {
// element from the list.
for (int i = sorts.size() - 1; i >= 0; i--) {
Sort sort = sorts.get(i);
if (sort != null)
sort.drop(this);
}
sorts.clear();
freeSortIds.clear();
}
}
}
use of org.apache.derby.iapi.store.access.conglomerate.ScanManager in project derby by apache.
the class RAMTransaction method debugOpened.
/**
* Return a string with debug information about opened congloms/scans/sorts.
* <p>
* Return a string with debugging information about current opened
* congloms/scans/sorts which have not been close()'d.
* Calls to this routine are only valid under code which is conditional
* on SanityManager.DEBUG.
* <p>
*
* @return String with debugging information.
*
* @exception StandardException Standard exception policy.
*/
public String debugOpened() throws StandardException {
String str = null;
if (SanityManager.DEBUG) {
str = "";
for (Iterator<ScanManager> it = scanControllers.iterator(); it.hasNext(); ) {
ScanController sc = it.next();
str += "open scan controller: " + sc + "\n";
}
for (Iterator<ConglomerateController> it = conglomerateControllers.iterator(); it.hasNext(); ) {
ConglomerateController cc = (ConglomerateController) it.next();
str += "open conglomerate controller: " + cc + "\n";
}
if (sortControllers != null) {
for (Iterator<SortController> it = sortControllers.iterator(); it.hasNext(); ) {
SortController sc = it.next();
str += "open sort controller: " + sc + "\n";
}
}
if (sorts != null) {
for (int i = 0; i < sorts.size(); i++) {
Sort sort = sorts.get(i);
if (sort != null) {
str += "sorts created by createSort() in current xact:" + sort + "\n";
}
}
}
if (tempCongloms != null) {
for (Iterator<Long> it = tempCongloms.keySet().iterator(); it.hasNext(); ) {
Long conglomId = it.next();
Conglomerate c = tempCongloms.get(conglomId);
str += "temp conglomerate id = " + conglomId + ": " + c;
}
}
}
return (str);
}
use of org.apache.derby.iapi.store.access.conglomerate.ScanManager in project derby by apache.
the class RAMTransaction method openSortScan.
/**
* @see TransactionController#openSortScan
* @exception StandardException Standard error policy.
*/
public ScanController openSortScan(long id, boolean hold) throws StandardException {
Sort sort;
// if it doesn't exist.
if (sorts == null || id >= sorts.size() || (sort = ((Sort) sorts.get((int) id))) == null) {
throw StandardException.newException(SQLState.AM_NO_SUCH_SORT, id);
}
// Open a scan on it.
ScanManager sc = sort.openSortScan(this, hold);
// Keep track of it so we can release on close.
scanControllers.add(sc);
return sc;
}
Aggregations