Relational-Database / relData.h
relData.h
Raw
// Project ID: C0F4DFE8B340D81183C208F70F9D2D797908754D
#include <vector>  
#include "TableEntry.h"
#include <unordered_map>
#include <map>

using namespace std;

struct Metadata {
    enum class Datatype {String, Int, Bool, Double} datatype;
};

struct Table  {
    vector<pair<string, Metadata>> columns;
    vector<vector<TableEntry>> data;
    unordered_map<TableEntry, vector<int>> unorderedMapIndex;
    int unorderedMapIndexColNum;
    map<TableEntry, vector<int>> orderedMapIndex;
    int orderedMapIndexColNum;
    bool bstIndex;
    bool hashIndex;
};

class equalFunctor {
    public:
        equalFunctor(int colNo, TableEntry te_in) : te(te_in), index(colNo) {}
    bool operator() (const vector<TableEntry> &te2) const {

        return te == te2[static_cast<size_t>(index)];
    }
    private:
        TableEntry te;
        int index;
}; 

class greaterFunctor {
    public:
        greaterFunctor(int colNo, TableEntry te_in) : te(te_in), index(colNo) {}
    bool operator() (const vector<TableEntry> &te2) const {

        return te > te2[static_cast<size_t>(index)];
    }
    private:
        TableEntry te;
        int index;
}; 

class lessFunctor {
    public:
        lessFunctor(int colNo, TableEntry te_in) : te(te_in), index(colNo) {}
    bool operator() (const vector<TableEntry> &te2) const {

        return te < te2[static_cast<size_t>(index)];
    }
    private:
        TableEntry te;
        int index;
};