Class RIBulkChecker
java.lang.Object
org.apache.derby.impl.sql.execute.RIBulkChecker
Do a merge run comparing all the foreign keys from the
foreign key conglomerate against the referenced keys
from the primary key conglomerate. The scanControllers
are passed in by the caller (caller controls locking on
said conglomerates).
The comparision is done via a merge. Consequently, it is imperative that the scans are on keyed conglomerates (indexes) and that the referencedKeyScan is a unique scan.
Performance is no worse than N + M where N is foreign key rows and M is primary key rows.
Bulk fetch is used to further speed performance. The fetch size is LanguageProperties.BULK_FETCH_DEFAULT
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final UUIDprivate intprivate intprivate final booleanprivate BackingStoreHashtableprivate static final intprivate intprivate ExecRowprivate final longprivate DataValueDescriptor[][]private GroupFetchScanControllerprivate static final intprivate intprivate intprivate final LanguageConnectionContextprivate static final intprivate intprivate final longprivate booleanprivate DataValueDescriptor[][]private GroupFetchScanControllerprivate final Stringprivate final Stringprivate ConglomerateController -
Constructor Summary
ConstructorsConstructorDescriptionRIBulkChecker(Activation a, GroupFetchScanController referencedKeyScan, GroupFetchScanController foreignKeyScan, ExecRow templateRow, boolean quitOnFirstFailure, ConglomerateController unreferencedCC, ExecRow firstRowToFail, String schemaName, String tableName, UUID constraintId, boolean deferrable, long fkCID, long pkCID) Create a RIBulkChecker -
Method Summary
Modifier and TypeMethodDescriptionprivate booleananyNull(DataValueDescriptor[] fkRowArray) intdoCheck()Perform the check.private voidfailure(DataValueDescriptor[] foreignKeyRow) private DataValueDescriptor[]private DataValueDescriptor[]private intgreaterThan(DataValueDescriptor[] fkRowArray, DataValueDescriptor[] refRowArray)
-
Field Details
-
EQUAL
private static final int EQUAL- See Also:
-
GREATER_THAN
private static final int GREATER_THAN- See Also:
-
LESS_THAN
private static final int LESS_THAN- See Also:
-
fkCID
private final long fkCID -
pkCID
private final long pkCID -
schemaName
-
tableName
-
constraintId
-
deferredRowsHashTable
-
lcc
-
deferred
private final boolean deferred -
referencedKeyScan
-
referencedKeyRowArray
-
foreignKeyScan
-
foreignKeyRowArray
-
unreferencedCC
-
failedCounter
private int failedCounter -
quitOnFirstFailure
private boolean quitOnFirstFailure -
numColumns
private int numColumns -
currRefRowIndex
private int currRefRowIndex -
currFKRowIndex
private int currFKRowIndex -
lastRefRowIndex
private int lastRefRowIndex -
lastFKRowIndex
private int lastFKRowIndex -
firstRowToFail
-
-
Constructor Details
-
RIBulkChecker
public RIBulkChecker(Activation a, GroupFetchScanController referencedKeyScan, GroupFetchScanController foreignKeyScan, ExecRow templateRow, boolean quitOnFirstFailure, ConglomerateController unreferencedCC, ExecRow firstRowToFail, String schemaName, String tableName, UUID constraintId, boolean deferrable, long fkCID, long pkCID) throws StandardException Create a RIBulkChecker- Parameters:
a- the activationreferencedKeyScan- scan of the referenced key's backing index. must be uniqueforeignKeyScan- scan of the foreign key's backing indextemplateRow- a template row for the indexes. Will be cloned when it is used. Must be a full index row.quitOnFirstFailure- quit on first unreferenced keyunreferencedCC- put unreferenced keys herefirstRowToFail- the first row that fails the constraint is copied to this, if non-nullschemaName- schema name of the table we insert intotableName- table name of the table we insert intoconstraintId- constraint id of the foreign constraintdeferrable-trueif the constraint is deferrablefkCID- conglomerate id of the foreign key supporting indexpkCID- conglomerate id of the referenced primary key or unique index.- Throws:
StandardException
-
-
Method Details
-
doCheck
Perform the check. If deferred constraint mode, the numbers of failed rows returned will be always be 0 (but any violating keys will have been saved for later checking).- Returns:
- the number of failed rows
- Throws:
StandardException- on error
-
getNextFK
- Throws:
StandardException
-
getNextRef
- Throws:
StandardException
-
failure
- Throws:
StandardException
-
anyNull
- Throws:
StandardException
-
greaterThan
private int greaterThan(DataValueDescriptor[] fkRowArray, DataValueDescriptor[] refRowArray) throws StandardException - Throws:
StandardException
-