4. Defining Data Types : hashprep Routine--Prepare Value for Hash Key
 
Share this page                  
hashprep Routine--Prepare Value for Hash Key
This routine prepares a data value for becoming a hash key. Place the address of this routine in the dtd_hashprep_addr field of the IIADD_DT_DFN structure. If the II_DT_NOKEY attribute is present, then this routine is not necessary.
For most data types, hash key preparation is a simple copy operation, copying the input data to the output. However, some data types may require more processing. For example, character data types may require blank removal or case translation.
The DBMS Server hash algorithm treats the hash key as a simple byte stream. It does not make allowances for the special characteristics of a data type. You must normalize any variable-length data types within this routine. Unused space must be initialized to some known value. For example, character strings are typically padded with blanks. You must also ensure that there are no compiler-generated holes in your data type. Holes can occur when a compiler pads a structure definition for alignment.
This routine must transform any two values of a data type that compare as equal (using the compare routine) into identical byte streams.