SwatDB
Loading...
Searching...
No Matches
key.h
Go to the documentation of this file.
1/*
2 * SwatDB
3 *
4 * @authors: See Contributors.doc for code contributors
5 *
6 * Copyright (c) 2020 Swarthmore College Computer Science Department
7 * Swarthmore PA, Professors Tia Newhall, Ameet Soni
8 */
9
10#ifndef _SWATDB_KEY_H_
11#define _SWATDB_KEY_H_
12
17#include <vector>
18#include <string>
19#include "swatdb_types.h"
20
21class Data;
22class SearchKeyFormat;
23class Record;
24
36class Key;
37
38class Key {
39
40 public:
41
45 Key();
46
47
66 Key(std::uint32_t capacity);
67
79
86 ~Key(){}
87
97
107
117
145 void setKeyFromValues(std::vector<void *> values);
146
167
183
198 bool compareDifferent(Key *other_key, std::vector<Comp> comp_list);
199
215
232 Comp compare(char* other, std::uint32_t size);
233
238
239 private:
244
250
272 Comp _compare_field(char *other, std::uint32_t size, FieldId field_id,
273 FieldType field_type);
275};
276
277#endif
Definition data.h:26
Definition key.h:38
void setKeyFromRecord(Record *rec)
sets a key data field to the vaules from the passed record
Comp compare(Key other)
Compare function for comparing keys.
Key()
Default constructor. Sets key_format and key_data to nullptr.
Key(SearchKeyFormat *key_format, Data *key_data)
Constructor given appropriate key_format and key_data.
void setKeyFromValues(std::vector< void * > values)
sets a key data field to the values from the passed vector of void * pointers.
Comp compare(char *other, std::uint32_t size)
Compare function for comparing keys, one of which is serialized bytes of data.
Data * getKeyData()
Getter for key_data.
bool compareDifferent(Key *other_key, std::vector< Comp > comp_list)
Compare function for comparing keys from differing relations, but with the same format....
void setKeyData(Data *new_data)
Setter for key_data.
~Key()
Destructor.
Definition key.h:86
void setKeyFormat(SearchKeyFormat *new_format)
Setter for key format.
HashVal hash()
Hash function for hashing key, as raw bytes of data.
SearchKeyFormat * key_format
Definition key.h:243
Data * key_data
Definition key.h:249
bool compareDifferent(Key *other_key, Comp comp_op)
Compare function for comparing keys from differing relations, but with the same format....
Key(std::uint32_t capacity)
Constructor to create a Key object with key_data field of the size of some capacity and sets key_form...
SearchKeyFormat * getKeyFormat()
Getter function for key_format.
Definition record.h:34
Definition searchkeyformat.h:32
std::uint32_t FieldId
Definition swatdb_types.h:86
FieldType
Definition swatdb_types.h:97
std::uint32_t HashVal
Definition swatdb_types.h:136