Search in sources :

Example 6 with ScanQualifier

use of org.apache.derby.iapi.sql.execute.ScanQualifier in project derby by apache.

the class DataDictionaryImpl method hashAllConglomerateDescriptorsByNumber.

/**
 * Get all of the ConglomerateDescriptors in the database and
 * hash them by conglomerate number.
 * This is useful as a performance optimization for the locking VTIs.
 * NOTE:  This method will scan SYS.SYSCONGLOMERATES at READ UNCOMMITTED.
 *
 * @param tc		TransactionController for the transaction
 *
 * @return	A Hashtable with all of the ConglomerateDescriptors
 *		in the database hashed by conglomerate number.
 *
 * @exception StandardException		Thrown on failure
 */
public Hashtable<Long, ConglomerateDescriptor> hashAllConglomerateDescriptorsByNumber(TransactionController tc) throws StandardException {
    Hashtable<Long, ConglomerateDescriptor> ht = new Hashtable<Long, ConglomerateDescriptor>();
    ConglomerateDescriptor cd = null;
    ScanController scanController;
    ExecRow outRow;
    TabInfoImpl ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
    SYSCONGLOMERATESRowFactory rf = (SYSCONGLOMERATESRowFactory) ti.getCatalogRowFactory();
    outRow = rf.makeEmptyRow();
    scanController = tc.openScan(// conglomerate to open
    ti.getHeapConglomerate(), // don't hold open across commit
    false, // for read
    0, // scans whole table.
    TransactionController.MODE_RECORD, TransactionController.ISOLATION_READ_UNCOMMITTED, // all fields as objects
    (FormatableBitSet) null, // keyRow.getRowArray(),   // start position - first row
    (DataValueDescriptor[]) null, // startSearchOperation
    ScanController.GE, (ScanQualifier[][]) null, // keyRow.getRowArray(),   // stop position - through last row
    (DataValueDescriptor[]) null, // stopSearchOperation
    ScanController.GT);
    // fetch() may find the row deleted or purged from the table.
    while (scanController.fetchNext(outRow.getRowArray())) {
        cd = (ConglomerateDescriptor) rf.buildDescriptor(outRow, (TupleDescriptor) null, this);
        Long hashKey = cd.getConglomerateNumber();
        ht.put(hashKey, cd);
    }
    scanController.close();
    return ht;
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) Hashtable(java.util.Hashtable) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) ScanQualifier(org.apache.derby.iapi.sql.execute.ScanQualifier) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) ConglomerateDescriptor(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)

Example 7 with ScanQualifier

use of org.apache.derby.iapi.sql.execute.ScanQualifier in project derby by apache.

the class DataDictionaryImpl method computeSequenceRowLocation.

/**
 * Computes the RowLocation in SYSSEQUENCES for a particular sequence. Also
 * constructs the sequence descriptor.
 *
 * @param tc			Transaction Controller to use.
 * @param sequenceIDstring UUID of the sequence as a string
 * @param rowLocation OUTPUT param for returing the row location
 * @param sequenceDescriptor OUTPUT param for return the sequence descriptor
 *
 * @exception StandardException thrown on failure.
 */
public void computeSequenceRowLocation(TransactionController tc, String sequenceIDstring, RowLocation[] rowLocation, SequenceDescriptor[] sequenceDescriptor) throws StandardException {
    TabInfoImpl ti = getNonCoreTI(SYSSEQUENCES_CATALOG_NUM);
    ExecIndexRow keyRow = null;
    keyRow = (ExecIndexRow) exFactory.getIndexableRow(1);
    keyRow.setColumn(1, new SQLChar(sequenceIDstring));
    rowLocation[0] = ti.getRowLocation(tc, keyRow, SYSSEQUENCESRowFactory.SYSSEQUENCES_INDEX1_ID);
    sequenceDescriptor[0] = getDescriptorViaIndex(SYSSEQUENCESRowFactory.SYSSEQUENCES_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, SequenceDescriptor.class, false, TransactionController.ISOLATION_REPEATABLE_READ, tc);
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) SQLChar(org.apache.derby.iapi.types.SQLChar) ScanQualifier(org.apache.derby.iapi.sql.execute.ScanQualifier) ColumnDescriptorList(org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList) ConglomerateDescriptorList(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptorList) ArrayList(java.util.ArrayList) TriggerDescriptorList(org.apache.derby.iapi.sql.dictionary.TriggerDescriptorList) List(java.util.List) ConstraintDescriptorList(org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList) LinkedList(java.util.LinkedList) SequenceDescriptor(org.apache.derby.iapi.sql.dictionary.SequenceDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Aggregations

ScanQualifier (org.apache.derby.iapi.sql.execute.ScanQualifier)7 TupleDescriptor (org.apache.derby.iapi.sql.dictionary.TupleDescriptor)5 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)5 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)4 ConglomerateDescriptorList (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptorList)4 ConstraintDescriptorList (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList)4 TriggerDescriptorList (org.apache.derby.iapi.sql.dictionary.TriggerDescriptorList)4 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)4 SQLChar (org.apache.derby.iapi.types.SQLChar)4 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)3 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)3 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)3 ScanController (org.apache.derby.iapi.store.access.ScanController)3 Hashtable (java.util.Hashtable)2 UUID (org.apache.derby.catalog.UUID)2 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)2 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)1