… | |
… | |
28 | |
28 | |
29 | // MTfile is a simple storage class for GiSTs to work over |
29 | // MTfile is a simple storage class for GiSTs to work over |
30 | // UNIX/NT files. It is a copy of the GiSTfile class. |
30 | // UNIX/NT files. It is a copy of the GiSTfile class. |
31 | |
31 | |
32 | class MTfile: public GiSTstore { |
32 | class MTfile: public GiSTstore { |
|
|
33 | unsigned int page; |
|
|
34 | struct Page { |
|
|
35 | GiSTpage page; |
|
|
36 | char *buf; |
|
|
37 | int dirty; |
|
|
38 | int seq; |
|
|
39 | }; |
|
|
40 | Page *cache; |
|
|
41 | unsigned int cachesize; |
|
|
42 | |
|
|
43 | Page *newpage(GiSTpage page); |
|
|
44 | Page *findpage(GiSTpage page); |
|
|
45 | void flushpage(Page *p); |
33 | public: |
46 | public: |
34 | MTfile(): GiSTstore() {} |
47 | void setcache(unsigned int pages); |
|
|
48 | |
|
|
49 | MTfile(unsigned int pagesize) |
|
|
50 | : GiSTstore(), page(pagesize), cachesize(0) |
|
|
51 | { |
|
|
52 | setcache (16); |
|
|
53 | } |
|
|
54 | |
|
|
55 | ~MTfile(); |
35 | |
56 | |
36 | void Create(const char *filename); |
57 | void Create(const char *filename); |
37 | void Open(const char *filename); |
58 | void Open(const char *filename); |
38 | void Close(); |
59 | void Close(); |
39 | |
60 | |
40 | void Read(GiSTpage page, char *buf); |
61 | void Read(GiSTpage page, char *buf); |
41 | void Write(GiSTpage page, const char *buf); |
62 | void Write(GiSTpage page, const char *buf); |
42 | GiSTpage Allocate(); |
63 | GiSTpage Allocate(); |
43 | void Deallocate(GiSTpage page); |
64 | void Deallocate(GiSTpage page); |
44 | void Sync() {} |
65 | void Sync(); |
45 | // int PageSize() const { return 65536; } |
|
|
46 | int PageSize() const { return 4096; } |
66 | int PageSize() const { return page; } |
47 | |
67 | |
48 | private: |
68 | private: |
49 | int fileHandle; |
69 | int fileHandle; |
50 | }; |
70 | }; |
51 | |
71 | |