This repository was archived by the owner on Jun 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableStruct.h
More file actions
65 lines (54 loc) · 1.73 KB
/
Copy pathTableStruct.h
File metadata and controls
65 lines (54 loc) · 1.73 KB
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
64
65
//
// Created by Kira on 2017/6/8.
//
#ifndef MINISQL_TABLESTRUCT_H
#define MINISQL_TABLESTRUCT_H
#include <vector>
#include <string>
extern const size_t blockSize;
using namespace std;
class Attribute {
public:
string attrName;
int type; // -1 -> float, 0 -> int, >0 -> char
bool unique;
bool isIndex;
public:
Attribute() {
}
Attribute(string attrName, int type, bool unique, bool isIndex) : attrName(attrName), type(type), unique(unique),
isIndex(isIndex) {
}
};
class TableStruct {
public:
string tableName;
vector<Attribute> attrs;
bool hasIndex;
size_t tupleNum;
size_t tupleSize;
size_t blockMaxRecordCount;
public:
TableStruct(){
};
TableStruct(string tableName, vector<Attribute> attrs, bool hasIndex, size_t tupleNum) : tableName(tableName),
tupleNum(tupleNum),
hasIndex(hasIndex),
attrs(attrs) {
tupleSize = 0;
for (auto attr:attrs) {
switch (attr.type) {
case TYPE_FLOAT:
case TYPE_INT:
tupleSize += 4;
break;
default:
tupleSize += attr.type;
break;
}
}
// 一个block最多有几条记录
blockMaxRecordCount = blockSize / tupleSize;
}
};
#endif //MINISQL_TABLESTRUCT_H