SwatDB
Loading...
Searching...
No Matches
schema.h
Go to the documentation of this file.
1
10#ifndef _SWATDB_SCHEMMA_H_
11#define _SWATDB_SCHEMMA_H_
12
13
14
19#include <string>
20#include <vector>
21#include <unordered_map>
22#include <iostream>
23#include <fstream>
24#include "swatdb_types.h"
25
37class Schema {
42 friend class IndexFile;
43 friend class RelOpsManager;
44 friend class Select;
45 friend class Record;
46 friend class Key;
47 friend class SearchKeyFormat;
48 friend class SwatDB;
49 friend class FileManager;
50
51 public:
55 Schema() = delete;
56
60 //Schema& operator=(const Schema& other) = delete;
61
65 Schema(const Schema& other);
76 Schema(std::vector<FieldEntry> field_list,
77 std::vector<std::string> primary_key);
78
118 Schema(std::ifstream *in_file);
119
124
125 std::string getFieldName(FieldId field_id);
126
131 FieldId getFieldId(std::string field_name);
132
141
158 void saveToFile(std::ofstream *out_file);
159
166
167 private:
168
172 std::unordered_map<std::string, FieldId> field_map;
173
178 std::vector<FieldEntry> field_list;
179
185 std::vector<FieldId> primary_key;
186
187
188};
189
190#endif
Definition filemgr.h:32
Definition indexfile.h:41
Definition key.h:38
Definition record.h:34
Definition relopsmgr.h:46
Definition schema.h:37
Schema(std::vector< FieldEntry > field_list, std::vector< std::string > primary_key)
Constructor of Schema.
FieldId getFieldId(std::string field_name)
getter function for the FieldId associated with a field name.
Schema()=delete
Disable default Constructor.
void printFields()
std::vector< FieldEntry > field_list
Definition schema.h:178
Schema(std::ifstream *in_file)
Schema Constructor that initializes schema based on saved metadata.
std::unordered_map< std::string, FieldId > field_map
Definition schema.h:172
Schema(const Schema &other)
Disable copy assignment constructor.
FieldType getFieldType(FieldId field_id)
returns the field type given a field_id
void saveToFile(std::ofstream *out_file)
save schema metadata to a file.
std::vector< FieldId > primary_key
Definition schema.h:185
~Schema()
Destructor.
Definition schema.h:123
Definition searchkeyformat.h:32
Definition select.h:35
Definition swatdb.h:48
std::uint32_t FieldId
Definition swatdb_types.h:86
FieldType
Definition swatdb_types.h:97