Class TupleTupleKeyCreator<E>
- All Implemented Interfaces:
ForeignKeyNullifier,SecondaryKeyCreator
- Direct Known Subclasses:
TupleTupleMarshalledKeyCreator
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.
If ForeignKeyDeleteAction.NULLIFY was
specified when creating the secondary, this method is called when the
entity for this foreign key is deleted. If NULLIFY was not specified,
this method will not be called and may always return false.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancreateSecondaryKey(TupleInput primaryKeyInput, TupleInput dataInput, TupleOutput indexKeyOutput) Creates the index key from primary key tuple and data tuple.booleancreateSecondaryKey(SecondaryDatabase db, DatabaseEntry primaryKeyEntry, DatabaseEntry dataEntry, DatabaseEntry indexKeyEntry) Creates a secondary key entry, given a primary key and data entry.booleannullifyForeignKey(TupleInput dataInput, TupleOutput dataOutput) Clears the index key in the tuple data entry.booleannullifyForeignKey(SecondaryDatabase db, DatabaseEntry dataEntry) Sets the foreign key reference to null in the datum of the primary database.Methods inherited from class com.sleepycat.bind.tuple.TupleBase
entryToInput, getTupleBufferSize, getTupleOutput, inputToEntry, newOutput, newOutput, outputToEntry, setTupleBufferSize
-
Constructor Details
-
TupleTupleKeyCreator
public TupleTupleKeyCreator()Creates a tuple-tuple key creator.
-
-
Method Details
-
createSecondaryKey
public boolean createSecondaryKey(SecondaryDatabase db, DatabaseEntry primaryKeyEntry, DatabaseEntry dataEntry, DatabaseEntry indexKeyEntry) Description copied from interface:SecondaryKeyCreatorCreates a secondary key entry, given a primary key and data entry.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.
- Specified by:
createSecondaryKeyin interfaceSecondaryKeyCreator- Parameters:
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.- Returns:
- true if a key was created, or false to indicate that the key is not present.
-
nullifyForeignKey
Description copied from interface:ForeignKeyNullifierSets the foreign key reference to null in the datum of the primary database.- Specified by:
nullifyForeignKeyin interfaceForeignKeyNullifier- Parameters:
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.- Returns:
- true if the datum was modified, or false to indicate that the key is not present.
-
createSecondaryKey
public abstract boolean createSecondaryKey(TupleInput primaryKeyInput, TupleInput dataInput, TupleOutput indexKeyOutput) Creates the index key from primary key tuple and data tuple.- Parameters:
primaryKeyInput- is theTupleInputfor the primary key entry.dataInput- is theTupleInputfor the data entry.indexKeyOutput- is the destination index key tuple.- Returns:
- true if a key was created, or false to indicate that the key is not present.
-
nullifyForeignKey
Clears the index key in the tuple data entry. The dataInput should be read and then written to the dataOutput, clearing the index key in the process.The secondary key should be output or removed 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.- Parameters:
dataInput- is theTupleInputfor the data entry.dataOutput- is the destinationTupleOutput.- Returns:
- true if the key was cleared, or false to indicate that the key is not present and no change is necessary.
-