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
63 Key(std::uint32_t capacity);
64
76
83 ~Key(){}
84
94
104
114
142 void setKeyFromValues(std::vector<void *> values);
143
164
180
195 bool compareDifferent(Key *other_key, std::vector<Comp> comp_list);
196
212
229 Comp compare(char* other, std::uint32_t size);
230
235
236 private:
241
247
269 Comp _compare_field(char *other, std::uint32_t size, FieldId field_id,
270 FieldType field_type);
272};
273
274#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:83
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:240
Data * key_data
Definition key.h:246
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