-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStatistics.h
63 lines (48 loc) · 1.65 KB
/
Statistics.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef STATISTICS_
#define STATISTICS_
#include <string>
#include <unordered_map>
#include <utility>
#include <string.h>
#include <unistd.h>
#include <iostream>
#include <stdlib.h>
#include "ParseTree.h"
using namespace std;
class RelStats {
public:
unordered_map<string, int> umap;
double num_tuples = 0;
public:
RelStats();
void UpdateNumTuples(int num_tuples);
void AddAtt(char *attName, int numDistincts);
void Copy(RelStats &toMe, char *newName);
void Write(FILE *file);
};
class Statistics {
friend class RelStats;
private:
unordered_map<string, RelStats*> umap;
// this lookmap will have all atribute's of all relations distinct values in one map
unordered_map<string, int> distinct_lookup;
// this maps the attribute to the relation's total tuples
// lineitem : l_orderkey - 1000 : where 1000 is the total tuples in lineitem relation
unordered_map<string, int> numtuples_lookup;
// this maps the attribute names to the relation
unordered_map<string, string> reverse_lookup;
// void CopyMap(unordered_map copyMe, unordered_map intoMe);
public:
Statistics();
Statistics(Statistics ©Me); // Performs deep copy
~Statistics();
void AddRel(char *relName, int numTuples);
void AddAtt(char *relName, char *attName, int numDistincts);
void CopyRel(char *oldName, char *newName);
void Read(char *fromWhere);
void Write(char *toWhere);
void JoinRels(string relNames[], double join_result);
void Apply(struct AndList *parseTree, char *relNames[], int numToJoin);
double Estimate(struct AndList *parseTree, char **relNames, int numToJoin);
};
#endif