-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreln.h
95 lines (77 loc) · 3.09 KB
/
reln.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
94
95
// reln.h ... interface to functions on Relations
// part of SIMC signature files
// See reln.c for details on Reln type and functions
// Written by John Shepherd, September 2018
#ifndef RELN_H
#define RELN_H 1
#include "defs.h"
// Relation parameters
typedef struct _RelnParams {
// dynamic parameters
Count npages; // number of data pages
Count ntups; // number of tuples
Count tsigNpages; // number of tsig pages
Count ntsigs; // number of tuple signatures (tsigs)
Count psigNpages; // number of tsig pages
Count npsigs; // number of page signatures (psigs)
Count bsigNpages; // number of tsig pages
Count nbsigs; // number of bit-sliced sigs (bsigs)
// fixed parameters (set at relation creation time)
Count nattrs; // number of attributes
float pF; // false match probability
Count tupsize; // # bytes in tuples (all same size)
Count tupPP; // max tuples per page
Count tk; // bits set per attribute
Count tm; // width of tuple signature (bits)
Count tsigSize; // # bytes in tuple signature
Count tsigPP; // max tuple signatures per page
Count pm; // width of page signature (bits)
Count psigSize; // # bytes in page signature
Count psigPP; // max tuple signatures per page
Count bm; // width of bit-slice (=maxpages)
Count bsigSize; // # bytes in bit-slice
Count bsigPP; // max bit-slices per page
} RelnParams;
// Open relation = parameters + open files
typedef struct _RelnRep {
RelnParams params; // relation parameters
File infof; // handle on info file
File dataf; // handle on data file
File tsigf; // handle on tuple signature file
File psigf; // handle on page signature file
File bsigf; // handle on bit-sliced signature file
} RelnRep;
typedef struct _RelnRep *Reln;
#include "tuple.h"
#include "page.h"
Status newRelation(char *name, Count nattrs, float pF,
Count tk, Count tm, Count pm, Count bm);
Reln openRelation(char *name);
void closeRelation(Reln r);
Bool existsRelation(char *name);
PageID addToRelation(Reln r, Tuple t);
void relationStats(Reln r);
// Convenience marcos
#define nAttrs(REL) (REL)->params.nattrs
#define tupSize(REL) (REL)->params.tupsize
#define nPages(REL) (REL)->params.npages
#define nTuples(REL) (REL)->params.ntups
#define maxTupsPP(REL) (REL)->params.tupPP
#define nTsigPages(REL) (REL)->params.tsigNpages
#define nTsigs(REL) (REL)->params.ntsigs
#define maxTsigsPP(REL) (REL)->params.tsigPP
#define nPsigPages(REL) (REL)->params.psigNpages
#define nPsigs(REL) (REL)->params.npsigs
#define maxPsigsPP(REL) (REL)->params.psigPP
#define nBsigPages(REL) (REL)->params.bsigNpages
#define nBsigs(REL) (REL)->params.nbsigs
#define maxBsigsPP(REL) (REL)->params.bsigPP
#define codeBits(REL) (REL)->params.tk
#define tsigBits(REL) (REL)->params.tm
#define psigBits(REL) (REL)->params.pm
#define bsigBits(REL) (REL)->params.bm
#define dataFile(REL) (REL)->dataf
#define tsigFile(REL) (REL)->tsigf
#define psigFile(REL) (REL)->psigf
#define bsigFile(REL) (REL)->bsigf
#endif