-
Notifications
You must be signed in to change notification settings - Fork 4
/
dict.h
93 lines (85 loc) · 2.08 KB
/
dict.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
数据字典,管理表和字段的信息
*/
#ifndef DICT_H_INCLUDED
#define DICT_H_INCLUDED
#include "util.h"
#include <stdio.h>
struct TableDictItem
{
uint TID;
char TName[MAX_T_NAME];
char MetaPath[MAX_PATH_LEN];
char DataPath[MAX_PATH_LEN];
uint FieldNum;
uint64 TupleNum;
uint64 BlockNum;
bool Valid;
};
struct FieldDictItem
{
uint TID;
char FName[MAX_F_NAME];
bool IsPrimaryKey;
bool IsUnique;
bool BuildHashIndex;
bool BuildBPTIndex;
bool Valid;
FieldType Type;
uint Size;
};
struct FieldInfo
{
char FName[MAX_F_NAME];
bool IsPrimaryKey;
bool IsUnique;
bool BuildHashIndex;
bool BuildBPTIndex;
FieldType Type;
uint Size;
FieldInfo();
FieldInfo(char fname[], bool isPrimKey, bool isUniq, bool buildHash, bool buildBpt, FieldType type, uint size);
void SetInfo(char fname[], bool isPrimKey, bool isUniq, bool buildHash, bool buildBpt, FieldType type, uint size);
};
struct TableInfo
{
char TName[MAX_T_NAME];
char MetaPath[MAX_PATH_LEN];
char DataPath[MAX_PATH_LEN];
FieldInfo *Fields;
uint FieldNum;
uint64 TupleNum;
uint64 BlockNum;
TableInfo();
TableInfo(char tname[], char dpath[], char mpath[], uint fnum, FieldInfo *fields);
~TableInfo();
};
class Dictionary
{
private:
uint ShowTabIndex;
uint TableNum, FieldNum;
uint TabDicLen, FieDicLen;
Addr TabDicAddr, FieDicAddr;
bool M;
TableDictItem *TableDict;
FieldDictItem *FieldDict;
char DBPath[MAX_PATH_LEN];
uint MaxTID;
public:
Dictionary(char *dbPath);
~Dictionary();
void Open();
void Close();
void Flush();
void Create();
void InitShowTable();
char *GetNextTabName();
bool GetTableInfo(char *tableName, TableInfo* tableInfo);
bool AddTable(TableInfo* tableInfo);
bool DelTable(char *tableName);
bool TableExist(char *tableName);
bool UpdateStatis(char *tableName, uint64 tupleNum, uint64 blockNum);
int UpdateIndex(char *tableName, char *fieldName, bool bpt, bool hash, char type);
};
#endif // DICT_H_INCLUDED