org.apache.derby.impl.sql.execute
Class RIBulkChecker

java.lang.Object
  extended byorg.apache.derby.impl.sql.execute.RIBulkChecker

public class RIBulkChecker
extends java.lang.Object

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:
LanguageProperties

Field Summary
private  int currFKRowIndex
           
private  int currRefRowIndex
           
private static int EQUAL
           
private  int failedCounter
           
private  ExecRow firstRowToFail
           
private  FKInfo fkInfo
           
private  DataValueDescriptor[][] foreignKeyRowArray
           
private  GroupFetchScanController foreignKeyScan
           
private static int GREATER_THAN
           
private  int lastFKRowIndex
           
private  int lastRefRowIndex
           
private static int LESS_THAN
           
private  int numColumns
           
private  boolean quitOnFirstFailure
           
private  DataValueDescriptor[][] referencedKeyRowArray
           
private  GroupFetchScanController referencedKeyScan
           
private  ConglomerateController unreferencedCC
           
 
Constructor Summary
RIBulkChecker(GroupFetchScanController referencedKeyScan, GroupFetchScanController foreignKeyScan, ExecRow templateRow, boolean quitOnFirstFailure, ConglomerateController unreferencedCC, ExecRow firstRowToFail)
          Create a RIBulkChecker
 
Method Summary
private  boolean anyNull(DataValueDescriptor[] fkRowArray)
           
 int doCheck()
          Perform the check.
private  void failure(DataValueDescriptor[] foreignKeyRow)
           
private  DataValueDescriptor[] getNextFK()
           
private  DataValueDescriptor[] getNextRef()
           
private  int greaterThan(DataValueDescriptor[] fkRowArray, DataValueDescriptor[] refRowArray)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EQUAL

private static final int EQUAL
See Also:
Constant Field Values

GREATER_THAN

private static final int GREATER_THAN
See Also:
Constant Field Values

LESS_THAN

private static final int LESS_THAN
See Also:
Constant Field Values

fkInfo

private FKInfo fkInfo

referencedKeyScan

private GroupFetchScanController referencedKeyScan

referencedKeyRowArray

private DataValueDescriptor[][] referencedKeyRowArray

foreignKeyScan

private GroupFetchScanController foreignKeyScan

foreignKeyRowArray

private DataValueDescriptor[][] foreignKeyRowArray

unreferencedCC

private ConglomerateController 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

private ExecRow firstRowToFail
Constructor Detail

RIBulkChecker

public RIBulkChecker(GroupFetchScanController referencedKeyScan,
                     GroupFetchScanController foreignKeyScan,
                     ExecRow templateRow,
                     boolean quitOnFirstFailure,
                     ConglomerateController unreferencedCC,
                     ExecRow firstRowToFail)
Create a RIBulkChecker

Parameters:
referencedKeyScan - scan of the referenced key's backing index. must be unique
foreignKeyScan - scan of the foreign key's backing index
templateRow - a template row for the indexes. Will be cloned when it is used. Must be a full index row.
quitOnFirstFailure - quit on first unreferenced key
firstRowToFail - the first row that fails the constraint is copied to this, if non-null
Method Detail

doCheck

public int doCheck()
            throws StandardException
Perform the check.

Returns:
the number of failed rows
Throws:
StandardException - on error

getNextFK

private DataValueDescriptor[] getNextFK()
                                 throws StandardException
Throws:
StandardException

getNextRef

private DataValueDescriptor[] getNextRef()
                                  throws StandardException
Throws:
StandardException

failure

private void failure(DataValueDescriptor[] foreignKeyRow)
              throws StandardException
Throws:
StandardException

anyNull

private boolean anyNull(DataValueDescriptor[] fkRowArray)
                 throws StandardException
Throws:
StandardException

greaterThan

private int greaterThan(DataValueDescriptor[] fkRowArray,
                        DataValueDescriptor[] refRowArray)
                 throws StandardException
Throws:
StandardException

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.