Search in sources :

Example 61 with FormatableBitSet

use of org.apache.derby.iapi.services.io.FormatableBitSet in project derby by apache.

the class UpdateResultSet method checkStreamCols.

/* Following 2 methods are for checking and make sure we don't have one un-objectified stream
	 * to be inserted into 2 temp table rows for deferred update.  Otherwise it would cause problem
	 * when writing to disk using the stream a second time.  In other cases we don't want to
	 * unnecessarily objectify the stream. beetle 4896.
	 */
private FormatableBitSet checkStreamCols() {
    DataValueDescriptor[] cols = row.getRowArray();
    FormatableBitSet streamCols = null;
    for (int i = 0; i < numberOfBaseColumns; i++) {
        if (// check new values
        cols[i + numberOfBaseColumns] instanceof StreamStorable) {
            if (streamCols == null)
                streamCols = new FormatableBitSet(numberOfBaseColumns);
            streamCols.set(i);
        }
    }
    return streamCols;
}
Also used : StreamStorable(org.apache.derby.iapi.services.io.StreamStorable) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor)

Example 62 with FormatableBitSet

use of org.apache.derby.iapi.services.io.FormatableBitSet in project derby by apache.

the class DeleteResultSet method deleteDeferredRows.

// delete the rows that in case deferred case and
// during cascade delete (All deletes are deferred during cascade action)
void deleteDeferredRows() throws StandardException {
    DataValueDescriptor rlColumn;
    RowLocation baseRowLocation;
    ExecRow defRLRow;
    deferredBaseCC = tc.openCompiledConglomerate(false, (TransactionController.OPENMODE_FORUPDATE | TransactionController.OPENMODE_SECONDARY_LOCKED), lockMode, TransactionController.ISOLATION_SERIALIZABLE, constants.heapSCOCI, heapDCOCI);
    CursorResultSet rs = rowHolder.getResultSet();
    try {
        /*
			** We need to do a fetch doing a partial row
			** read.  We need to shift our 1-based bit
			** set to a zero based bit set like the store
			** expects.
			*/
        FormatableBitSet readBitSet = RowUtil.shift(baseRowReadList, 1);
        rs.open();
        while ((defRLRow = rs.getNextRow()) != null) {
            rlColumn = defRLRow.getColumn(rlColumnNumber);
            baseRowLocation = (RowLocation) (rlColumn).getObject();
            /* Get the base row at the given RowLocation */
            boolean row_exists = deferredBaseCC.fetch(baseRowLocation, deferredSparseRow.getRowArray(), readBitSet);
            // the rows before the dependent result get a chance to delete
            if (cascadeDelete && !row_exists)
                continue;
            if (SanityManager.DEBUG) {
                if (!row_exists) {
                    SanityManager.THROWASSERT("could not find row " + baseRowLocation);
                }
            }
            rc.deleteRow(deferredBaseRow, baseRowLocation);
            source.markRowAsDeleted();
        }
    } finally {
        rs.close();
    }
}
Also used : CursorResultSet(org.apache.derby.iapi.sql.execute.CursorResultSet) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) RowLocation(org.apache.derby.iapi.types.RowLocation)

Example 63 with FormatableBitSet

use of org.apache.derby.iapi.services.io.FormatableBitSet in project derby by apache.

the class T_ConsistencyChecker method openUnqualifiedIndexScan.

/* Open an unqualified scan on the index for update */
private ScanController openUnqualifiedIndexScan() throws StandardException {
    ScanController indexScan;
    indexScan = tc.openScan(id.getConglomerateNumber(), // hold
    false, // forUpdate
    TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_TABLE, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, // startKeyValue
    null, // not used with null start posn.
    0, // qualifier
    null, // stopKeyValue
    null, // not used with null stop posn.
    0);
    return indexScan;
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet)

Example 64 with FormatableBitSet

use of org.apache.derby.iapi.services.io.FormatableBitSet in project derby by apache.

the class T_ConsistencyChecker method getIndexTemplateRow.

/* Get a template row for the specified index */
private ExecRow getIndexTemplateRow(RowLocation baseRL) throws StandardException {
    int[] baseColumnPositions;
    int baseColumns = 0;
    ExecRow indexScanTemplate;
    baseColumnPositions = id.getIndexDescriptor().baseColumnPositions();
    baseColumns = baseColumnPositions.length;
    FormatableBitSet indexColsBitSet = new FormatableBitSet();
    for (int i = 0; i < baseColumns; i++) {
        indexColsBitSet.grow(baseColumnPositions[i]);
        indexColsBitSet.set(baseColumnPositions[i] - 1);
    }
    /* Get a row template */
    indexScanTemplate = lcc.getLanguageConnectionFactory().getExecutionFactory().getValueRow(baseColumns + 1);
    /* Fill the row with nulls of the correct type */
    for (int column = 0; column < baseColumns; column++) {
        /* Column positions in the data dictionary are one-based */
        ColumnDescriptor cd = td.getColumnDescriptor(baseColumnPositions[column]);
        DataTypeDescriptor dts = cd.getType();
        indexScanTemplate.setColumn(column + 1, dts.getNull());
    }
    /* Set the row location in the last column of the index row */
    indexScanTemplate.setColumn(baseColumns + 1, baseRL);
    return indexScanTemplate;
}
Also used : DataTypeDescriptor(org.apache.derby.iapi.types.DataTypeDescriptor) ColumnDescriptor(org.apache.derby.iapi.sql.dictionary.ColumnDescriptor) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet)

Example 65 with FormatableBitSet

use of org.apache.derby.iapi.services.io.FormatableBitSet in project derby by apache.

the class FormatableBitSetTest method testORWithNull.

// Test cases for or(FormatableBitSet)
public void testORWithNull() {
    FormatableBitSet cpy = new FormatableBitSet(bitset18);
    assertTrue(cpy.invariantHolds());
    bitset18.or(null);
    assertEquals(9, bitset18.getNumBitsSet());
    assertTrue(cpy.equals(bitset18));
}
Also used : FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet)

Aggregations

FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)146 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)36 RowLocation (org.apache.derby.iapi.types.RowLocation)32 SQLLongint (org.apache.derby.iapi.types.SQLLongint)25 ScanController (org.apache.derby.iapi.store.access.ScanController)24 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)23 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)18 StandardException (org.apache.derby.shared.common.error.StandardException)17 RawTransaction (org.apache.derby.iapi.store.raw.xact.RawTransaction)15 RawContainerHandle (org.apache.derby.iapi.store.raw.data.RawContainerHandle)13 TransactionController (org.apache.derby.iapi.store.access.TransactionController)12 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)11 SQLInteger (org.apache.derby.iapi.types.SQLInteger)11 UUID (org.apache.derby.catalog.UUID)10 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)10 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)9 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)7 SQLChar (org.apache.derby.iapi.types.SQLChar)7 Properties (java.util.Properties)6 ContextManager (org.apache.derby.iapi.services.context.ContextManager)6