ForeignKeyNullifier
, SecondaryKeyCreator
TupleSerialMarshalledKeyCreator
public abstract class TupleSerialKeyCreator<D> extends TupleBase implements SecondaryKeyCreator, ForeignKeyNullifier
TupleInput
and TupleOutput
objects.
The following abstract method must be implemented by a concrete subclass
to create the index key using these objects
If ForeignKeyDeleteAction.NULLIFY
was
specified when opening the secondary database, the following method must be
overridden to nullify the foreign index key. If NULLIFY was not specified,
this method need not be overridden.
Modifier and Type | Field | Description |
---|---|---|
protected SerialBinding<D> |
dataBinding |
Constructor | Description |
---|---|
TupleSerialKeyCreator(ClassCatalog classCatalog,
java.lang.Class<D> dataClass) |
Creates a tuple-serial key creator.
|
TupleSerialKeyCreator(SerialBinding<D> dataBinding) |
Creates a tuple-serial key creator.
|
Modifier and Type | Method | Description |
---|---|---|
abstract boolean |
createSecondaryKey(TupleInput primaryKeyInput,
D dataInput,
TupleOutput indexKeyOutput) |
Creates the index key entry from primary key tuple entry and
deserialized data entry.
|
boolean |
createSecondaryKey(SecondaryDatabase db,
DatabaseEntry primaryKeyEntry,
DatabaseEntry dataEntry,
DatabaseEntry indexKeyEntry) |
Creates a secondary key entry, given a primary key and data entry.
|
boolean |
nullifyForeignKey(SecondaryDatabase db,
DatabaseEntry dataEntry) |
Sets the foreign key reference to null in the datum of the primary
database.
|
D |
nullifyForeignKey(D data) |
Clears the index key in the deserialized data entry.
|
entryToInput, getTupleBufferSize, getTupleOutput, inputToEntry, newOutput, newOutput, outputToEntry, setTupleBufferSize
protected SerialBinding<D> dataBinding
public TupleSerialKeyCreator(ClassCatalog classCatalog, java.lang.Class<D> dataClass)
classCatalog
- is the catalog to hold shared class information and
for a database should be a StoredClassCatalog
.dataClass
- is the data base class.public TupleSerialKeyCreator(SerialBinding<D> dataBinding)
dataBinding
- is the data binding.public boolean createSecondaryKey(SecondaryDatabase db, DatabaseEntry primaryKeyEntry, DatabaseEntry dataEntry, DatabaseEntry indexKeyEntry)
SecondaryKeyCreator
A secondary key may be derived from the primary key, primary data, or a combination of the primary key and data. For secondary keys that are optional, the key creator method may return false and the key/data pair will not be indexed. To ensure the integrity of a secondary database the key creator method must always return the same result for a given set of input parameters.
createSecondaryKey
in interface SecondaryKeyCreator
db
- the database to which the secondary key will be added.
This parameter is passed for informational purposes but is not commonly
used.
primaryKeyEntry
- the primary key entry. This parameter must not be modified
by this method.
dataEntry
- the primary data entry. This parameter must not be modified
by this method.
indexKeyEntry
- the secondary key created by this method.
public boolean nullifyForeignKey(SecondaryDatabase db, DatabaseEntry dataEntry)
ForeignKeyNullifier
nullifyForeignKey
in interface ForeignKeyNullifier
db
- the database in which the foreign key integrity
constraint is defined. This parameter is passed for informational
purposes but is not commonly used.dataEntry
- the existing primary datum in which the foreign key
reference should be set to null. This parameter should be updated by
this method if it returns true.public abstract boolean createSecondaryKey(TupleInput primaryKeyInput, D dataInput, TupleOutput indexKeyOutput)
primaryKeyInput
- is the TupleInput
for the primary key
entry, or null if no primary key entry is used to construct the index
key.dataInput
- is the deserialized data entry, or null if no data
entry is used to construct the index key.indexKeyOutput
- is the destination index key tuple. For index
keys which are optionally present, no tuple entry should be output to
indicate that the key is not present or null.public D nullifyForeignKey(D data)
On entry the data parameter contains the index key to be cleared. It
should be changed by this method such that createSecondaryKey(com.sleepycat.db.SecondaryDatabase, com.sleepycat.db.DatabaseEntry, com.sleepycat.db.DatabaseEntry, com.sleepycat.db.DatabaseEntry)
will return false. Other fields in the data object should remain
unchanged.
data
- is the source and destination deserialized data
entry.Copyright (c) 1996, 2020 Oracle and/or its affiliates. All rights reserved.