Top Description Fields Constructors Methods
org.apache.derby.impl.sql.execute

public Class UniqueWithDuplicateNullsIndexSortObserver

extends BasicSortObserver
Class Inheritance
Imports
org.apache.derby.catalog.UUID, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, org.apache.derby.iapi.sql.execute.ExecRow, org.apache.derby.iapi.store.access.BackingStoreHashtable, .TransactionController, org.apache.derby.iapi.types.DataValueDescriptor

UniqueWithDuplicateNullsIndexSortObserver is implementation of BasicSortObserver for eliminating non null duplicates from the backing index of unique constraint. This class is implemented to check for special case of distinct sorting where duplicate keys are allowed only if there is a null in the key part.

Field Summary

Modifier and TypeField and Description
private final UUID
private final boolean
private final boolean
private BackingStoreHashtable
private final String
private final LanguageConnectionContext
private final String
Inherited from org.apache.derby.impl.sql.execute.BasicSortObserver:
distinctdoClone

Constructor Summary

AccessConstructor and Description
public
UniqueWithDuplicateNullsIndexSortObserver(LanguageConnectionContext
Language Connection context
lcc
,
UUID
Id of the constraint (only used for deferrable constraints)
constraintId
,
boolean
If true, then rows that are retained by the sorter will be cloned. This is needed if language is reusing row wrappers.
doClone
,
boolean
deferrable constraint
deferrable
,
boolean
constraint mode is deferred
deferred
,
String
name of index of constraint
indexOrConstraintName
,
ExecRow
ExecRow to use as source of clone for store.
execRow
,
boolean
Whether or not we can reuse the wrappers
reuseWrappers
,
String
name of the table
tableName
)

Constructs an object of UniqueWithDuplicateNullsIndexSortObserver

Method Summary

Modifier and TypeMethod and Description
public boolean
deferrable()

Overrides org.apache.derby.impl.sql.execute.BasicSortObserver.deferrable.

Implements org.apache.derby.iapi.store.access.SortObserver.deferrable.

Overridden by subclasses that observe sorters with uniqueness checking.

public boolean
deferred()

Overrides org.apache.derby.impl.sql.execute.BasicSortObserver.deferred.

Implements org.apache.derby.iapi.store.access.SortObserver.deferred.

Overridden by subclasses that observe sorters with uniqueness checking.

public DataValueDescriptor[]

Returns:

DVD [] if there is at least one null in the key else throws StandardException
insertDuplicateKey
(DataValueDescriptor[]
new key
in
,
DataValueDescriptor[]
the new key is duplicate of this key
dup
)

Overrides org.apache.derby.impl.sql.execute.BasicSortObserver.insertDuplicateKey.

Implements org.apache.derby.iapi.store.access.SortObserver.insertDuplicateKey.

Methods to check if the duplicate key can be inserted or not.

public void
rememberDuplicate(DataValueDescriptor[]
data of offending key
row
)

Overrides org.apache.derby.impl.sql.execute.BasicSortObserver.rememberDuplicate.

Implements org.apache.derby.iapi.store.access.SortObserver.rememberDuplicate.

Overridden by subclasses that observe sorters with uniqueness checking.

Inherited from org.apache.derby.impl.sql.execute.BasicSortObserver:
addToFreeListgetArrayCloneinsertNonDuplicateKey

Field Detail

constraintIdback to summary
private final UUID constraintId
deferrableback to summary
private final boolean deferrable
deferredback to summary
private final boolean deferred
deferredDuplicatesback to summary
private BackingStoreHashtable deferredDuplicates
indexOrConstraintNameback to summary
private final String indexOrConstraintName
lccback to summary
private final LanguageConnectionContext lcc
tableNameback to summary
private final String tableName

Constructor Detail

UniqueWithDuplicateNullsIndexSortObserverback to summary
public UniqueWithDuplicateNullsIndexSortObserver(LanguageConnectionContext lcc, UUID constraintId, boolean doClone, boolean deferrable, boolean deferred, String indexOrConstraintName, ExecRow execRow, boolean reuseWrappers, String tableName)

Constructs an object of UniqueWithDuplicateNullsIndexSortObserver

Parameters
lcc:LanguageConnectionContext

Language Connection context

constraintId:UUID

Id of the constraint (only used for deferrable constraints)

doClone:boolean

If true, then rows that are retained by the sorter will be cloned. This is needed if language is reusing row wrappers.

deferrable:boolean

deferrable constraint

deferred:boolean

constraint mode is deferred

indexOrConstraintName:String

name of index of constraint

execRow:ExecRow

ExecRow to use as source of clone for store.

reuseWrappers:boolean

Whether or not we can reuse the wrappers

tableName:String

name of the table

Method Detail

deferrableback to summary
public boolean deferrable()

Overrides org.apache.derby.impl.sql.execute.BasicSortObserver.deferrable.

Implements org.apache.derby.iapi.store.access.SortObserver.deferrable.

Doc from org.apache.derby.iapi.store.access.SortObserver.deferrable.

Overridden by subclasses that observe sorters with uniqueness checking.

Returns:boolean

true if the index's constraint is deferrable. Any SortObserver implementations that implement uniqueness checking need to keep track of this information.

Annotations
@Override
deferredback to summary
public boolean deferred()

Overrides org.apache.derby.impl.sql.execute.BasicSortObserver.deferred.

Implements org.apache.derby.iapi.store.access.SortObserver.deferred.

Doc from org.apache.derby.iapi.store.access.SortObserver.deferred.

Overridden by subclasses that observe sorters with uniqueness checking.

Returns:boolean

true if constraint mode of the index's constraint is effectively deferred. Any SortObserver implementations that implement uniqueness checking need to keep track of this information.

Annotations
@Override
insertDuplicateKeyback to summary
public DataValueDescriptor[] insertDuplicateKey(DataValueDescriptor[] in, DataValueDescriptor[] dup) throws StandardException

Overrides org.apache.derby.impl.sql.execute.BasicSortObserver.insertDuplicateKey.

Implements org.apache.derby.iapi.store.access.SortObserver.insertDuplicateKey.

Methods to check if the duplicate key can be inserted or not. It throws exception if the duplicates has no null part in the key.

Parameters
in:DataValueDescriptor[]

new key

dup:DataValueDescriptor[]

the new key is duplicate of this key

Returns:DataValueDescriptor[]

DVD [] if there is at least one null in the key else throws StandardException

Annotations
@Override
Exceptions
StandardException:
is the duplicate key has all non null parts
rememberDuplicateback to summary
public void rememberDuplicate(DataValueDescriptor[] row) throws StandardException

Overrides org.apache.derby.impl.sql.execute.BasicSortObserver.rememberDuplicate.

Implements org.apache.derby.iapi.store.access.SortObserver.rememberDuplicate.

Doc from org.apache.derby.iapi.store.access.SortObserver.rememberDuplicate.

Overridden by subclasses that observe sorters with uniqueness checking. Will be called by sorters iff deferrable() and deferred() and uniqueness violation, so implementations that sometimes return true to these must implement this method to save duplicate information till commit time.

Parameters
row:DataValueDescriptor[]

data of offending key

Annotations
@Override
Exceptions
StandardException:
standard error policy