◆ Key() [1/2]
Key::Key |
( |
std::uint32_t |
capacity | ) |
|
Constructor to create a Key object with key_data field of the size of some capacity and sets key_format to nullptr.
This constructor is useful for creating a Key object that can be used to extract Key data from Records or off page data. Pass in a capacity value that is big enough to store the largest Key data in this case.
- Precondition
- : capacity is a valid size (MAX_RECORD_SIZE or less)
- Postcondition
- : key_data points to a new Data object of capacity size and key_format is set to nullptr
- Parameters
-
capacity | total capacity of the Data part of the key |
◆ Key() [2/2]
Constructor given appropriate key_format and key_data.
- Precondition
- Valid key_format and key_data are provided as input. key_data is in serialized, format corresponding to key_format.
- Postcondition
- key_format and key_data are set to the provided inputs.
- Parameters
-
key_format | format of the key. |
key_data | Data* key_data that stores the Key data. |
◆ ~Key()
Destructor.
- Precondition
- None.
- Postcondition
- key_data is not deallocated.
◆ compare() [1/2]
Comp Key::compare |
( |
char * |
other, |
|
|
std::uint32_t |
size |
|
) |
| |
Compare function for comparing keys, one of which is serialized bytes of data.
- Precondition
- Valid serialized key is provided as input.
- Postcondition
- If Key is less than other, LESS is returned. If Key is equal to other, EQUAL is returned. If Key is greater than other, GREATER is returned. INVALID_TYPE is returned if there is any error in key format.
- Parameters
-
other | The serialized key to be compared to. |
size | The size of the serialized key. |
- Returns
- LESS if Key is less, EQUAL if Key is equal, GREATER if Key is greater than other. INVALID_TYPE if there is any error in key format.
◆ compare() [2/2]
Comp Key::compare |
( |
Key |
other | ) |
|
Compare function for comparing keys.
- Precondition
- Valid Key object is provided as input.
- Postcondition
- If the key_formats are different, INVALID_TYPE is returned. If Key is less than other, LESS is returned. If Key is equal to other, EQUAL is returned. If Key is greater than other, GREATER is returned.
- Parameters
-
other | The Key to be compared to. |
- Returns
- LESS if Key is less, EQUAL if Key is equal, GREATER if Key is greater than other. INVALID_TYPE if there is any error in key format.
◆ compareDifferent() [1/2]
bool Key::compareDifferent |
( |
Key * |
other_key, |
|
|
Comp |
comp_op |
|
) |
| |
Compare function for comparing keys from differing relations, but with the same format. Takes in comparison operator and returns boolean.
- Precondition
- Valid Key object is provided as input. Keys have the same number of fields and fieldtypes.
- Postcondition
- Neither key object is modified.
- Parameters
-
other_key. | The Key to be compared to. |
comp_op. | Comparison operator for all fields. |
- Returns
- true if comparison is true on all fields, false otherwise.
◆ compareDifferent() [2/2]
bool Key::compareDifferent |
( |
Key * |
other_key, |
|
|
std::vector< Comp > |
comp_list |
|
) |
| |
Compare function for comparing keys from differing relations, but with the same format. Takes in comparison operator and returns boolean.
- Precondition
- Valid Key object is provided as input. Keys have the same number of fields and fieldtypes.
- Postcondition
- Neither key object is modified.
- Parameters
-
other_key. | The Key to be compared to. |
comp_list. | Vector of Comp types corresponding to each field. |
- Returns
- true if comparison is true on all fields, false otherwise.
◆ getKeyData()
Data * Key::getKeyData |
( |
| ) |
|
Getter for key_data.
- Precondition
- None.
- Postcondition
- key_data is returned.
- Returns
- Data* to the key_data of the Key.
◆ getKeyFormat()
Getter function for key_format.
- Precondition
- None.
- Postcondition
- key format is returned.
- Returns
- format of the Key.
◆ setKeyData()
Setter for key_data.
- Precondition
- Valid Data* is provided as an input.
- Postcondition
- key_data is set to new_data. The previous data is not deleted.
- Parameters
-
new_data | New Data* key_data is set to. |
◆ setKeyFormat()
Setter for key format.
- Precondition
- Valid key_format is provided as an input.
- Postcondition
- key_format is set to given key_format.
- Parameters
-
new_format | New key_format to be set. |
◆ setKeyFromRecord()
sets a key data field to the vaules from the passed record
- Precondition
- : the Key has been initialized with non null data and KeyFormat values, and the passed record is from a Relation with a matching schema. The key_data field has appropriate capacity to store the copied values from the passed record.
- Postcondition
- : the data field is set to the field values copied to the passed rec
- Parameters
-
| rec is pointer to the Record from which the key data fields should be set |
- Exceptions
-
InvalidFormatKey if the Key and the Record format are incompatable or if the Key has not been initialized with a KeyFormat
- Exceptions
-
InvalidCapacityKey if the Key does not have enough capacity to store the key field values from the passed record
◆ setKeyFromValues()
void Key::setKeyFromValues |
( |
std::vector< void * > |
values | ) |
|
sets a key data field to the values from the passed vector of void * pointers.
- Precondition
- : the Key has been initialized with non null data and KeyFormat values, and the passed vector matches the Relation schema. The key_data field has appropriate capacity to store the values.
- Postcondition
- : the data field is set to the field values copied to the passed rec
- Parameters
-
| values vector of void * corresponding to the values to be compared to this key. |
- Exceptions
-
InvalidFormatKey if the Key has not been initialized with a KeyFormat
- Exceptions
-
InvalidCapacityKey if the Key does not have enough capacity to store the key field values from the passed record
◆ key_data
Data of the Key. The object (not the pointer) is never modified in scope of this object.
◆ key_format
The documentation for this class was generated from the following file: