00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifndef SM_S_H
00054 #define SM_S_H
00055
00056 #include "w_defines.h"
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 typedef w_base_t::uint4_t extnum_t;
00067
00068 #ifndef STHREAD_H
00069 #include <sthread.h>
00070 #endif
00071
00072 #ifndef STID_T_H
00073 #include <stid_t.h>
00074 #endif
00075
00076 #ifdef __GNUG__
00077 #pragma interface
00078 #endif
00079
00080
00081
00082
00083
00084
00085
00086 class extid_t {
00087 public:
00088 vid_t vol;
00089 fill2 filler;
00090 extnum_t ext;
00091
00092 friend ostream& operator<<(ostream&, const extid_t& x);
00093 friend istream& operator>>(istream&, extid_t &x);
00094 };
00095
00096
00097
00098
00099
00100 class lpid_t {
00101 public:
00102 stid_t _stid;
00103 shpid_t page;
00104
00105 lpid_t();
00106 lpid_t(const stid_t& s, shpid_t p);
00107 lpid_t(vid_t v, snum_t s, shpid_t p);
00108
00109 bool valid() const;
00110
00111 vid_t vol() const {return _stid.vol;}
00112 snum_t store() const {return _stid.store;}
00113 const stid_t& stid() const {return _stid;}
00114
00115
00116
00117 bool is_null() const { return page == 0; }
00118
00119 bool operator==(const lpid_t& p) const;
00120 bool operator!=(const lpid_t& p) const;
00121 bool operator<(const lpid_t& p) const;
00122 bool operator<=(const lpid_t& p) const;
00123 bool operator>(const lpid_t& p) const;
00124 bool operator>=(const lpid_t& p) const;
00125 friend ostream& operator<<(ostream&, const lpid_t& p);
00126 friend istream& operator>>(istream&, lpid_t& p);
00127
00128
00129 static const lpid_t bof;
00130 static const lpid_t eof;
00131 static const lpid_t null;
00132 };
00133
00134
00135
00136 class rid_t;
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 class shrid_t {
00150 public:
00151 shpid_t page;
00152 snum_t store;
00153 slotid_t slot;
00154 fill2 filler;
00155
00156 shrid_t();
00157 shrid_t(const rid_t& r);
00158 shrid_t(shpid_t p, snum_t st, slotid_t sl) : page(p), store(st), slot(sl) {}
00159 friend ostream& operator<<(ostream&, const shrid_t& s);
00160 friend istream& operator>>(istream&, shrid_t& s);
00161 };
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 class rid_t {
00176 public:
00177 lpid_t pid;
00178 slotid_t slot;
00179 fill2 filler;
00180
00181 rid_t();
00182 rid_t(vid_t vid, const shrid_t& shrid);
00183 rid_t(const lpid_t& p, slotid_t s) : pid(p), slot(s) {};
00184
00185 stid_t stid() const;
00186
00187 bool operator==(const rid_t& r) const;
00188 bool operator!=(const rid_t& r) const;
00189 friend ostream& operator<<(ostream&, const rid_t& s);
00190 friend istream& operator>>(istream&, rid_t& s);
00191
00192 static const rid_t null;
00193 };
00194
00195 #include <lsn.h>
00196
00197
00198
00199
00200
00201
00202
00203 struct key_type_s {
00204 enum type_t {
00205 i = 'i',
00206 I = 'I',
00207 u = 'u',
00208 U = 'U',
00209 f = 'f',
00210 F = 'F',
00211 b = 'b',
00212 B = 'B'
00213
00214
00215
00216
00217
00218
00219 };
00220 enum max_length_t { max_len = 2000 };
00221 char type;
00222 char variable;
00223 uint2_t length;
00224 char compressed;
00225 #ifdef __GNUG__
00226 fill1 dummy;
00227 #endif
00228
00229 key_type_s(type_t t = (type_t)0, char v = 0, uint2_t l = 0)
00230 : type((char) t), variable(v), length(l), compressed(false) {};
00231
00232
00233
00234
00235
00236
00237 static w_rc_t parse_key_type(const char* s, w_base_t::uint4_t& count, key_type_s kc[]);
00238 static w_rc_t get_key_type(char* s, int buflen, w_base_t::uint4_t count, const key_type_s *kc);
00239
00240 };
00241
00242 inline ostream& operator<<(ostream& o, const lsn_t& l)
00243 {
00244 return o << l.file() << '.' << l.rba();
00245 }
00246
00247 inline istream& operator>>(istream& i, lsn_t& l)
00248 {
00249 sm_diskaddr_t d;
00250 char c;
00251 w_base_t::uint8_t f;
00252 i >> f >> c >> d;
00253 l = lsn_t(f, d);
00254 return i;
00255 }
00256
00257 inline lpid_t::lpid_t() : page(0) {}
00258
00259 inline lpid_t::lpid_t(const stid_t& s, shpid_t p) : _stid(s), page(p)
00260 {}
00261
00262 inline lpid_t::lpid_t(vid_t v, snum_t s, shpid_t p) :
00263 _stid(v, s), page(p)
00264 {}
00265
00266 inline shrid_t::shrid_t() : page(0), store(0), slot(0)
00267 {}
00268 inline shrid_t::shrid_t(const rid_t& r) :
00269 page(r.pid.page), store(r.pid.store()), slot(r.slot)
00270 {}
00271
00272 inline rid_t::rid_t() : slot(0)
00273 {}
00274
00275 inline rid_t::rid_t(vid_t vid, const shrid_t& shrid) :
00276 pid(vid, shrid.store, shrid.page), slot(shrid.slot)
00277 {}
00278
00279 inline stid_t rid_t::stid() const
00280 {
00281 return pid.stid();
00282 }
00283
00284 inline bool lpid_t::operator==(const lpid_t& p) const
00285 {
00286 return (page == p.page) && (stid() == p.stid());
00287 }
00288
00289 inline bool lpid_t::operator!=(const lpid_t& p) const
00290 {
00291 return !(*this == p);
00292 }
00293
00294 inline bool lpid_t::operator<=(const lpid_t& p) const
00295 {
00296 return _stid == p._stid && page <= p.page;
00297 }
00298
00299 inline bool lpid_t::operator>=(const lpid_t& p) const
00300 {
00301 return _stid == p._stid && page >= p.page;
00302 }
00303
00304 inline bool rid_t::operator==(const rid_t& r) const
00305 {
00306 return (pid == r.pid && slot == r.slot);
00307 }
00308
00309 inline bool rid_t::operator!=(const rid_t& r) const
00310 {
00311 return !(*this == r);
00312 }
00313
00314
00315
00316 #endif