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 #define RID_T
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 class rid_t {
00178 public:
00179 lpid_t pid;
00180 slotid_t slot;
00181 fill2 filler;
00182
00183 rid_t();
00184 rid_t(vid_t vid, const shrid_t& shrid);
00185 rid_t(const lpid_t& p, slotid_t s) : pid(p), slot(s) {};
00186
00187 stid_t stid() const;
00188
00189 bool operator==(const rid_t& r) const;
00190 bool operator!=(const rid_t& r) const;
00191 friend ostream& operator<<(ostream&, const rid_t& s);
00192 friend istream& operator>>(istream&, rid_t& s);
00193
00194 static const rid_t null;
00195 };
00196
00197 #include <lsn.h>
00198
00199
00200
00201
00202
00203
00204
00205 struct key_type_s {
00206 enum type_t {
00207 i = 'i',
00208 I = 'I',
00209 u = 'u',
00210 U = 'U',
00211 f = 'f',
00212 F = 'F',
00213 b = 'b',
00214 B = 'B'
00215
00216
00217
00218
00219
00220
00221 };
00222 enum max_length_t { max_len = 2000 };
00223 char type;
00224 char variable;
00225 uint2_t length;
00226 char compressed;
00227 #ifdef __GNUG__
00228 fill1 dummy;
00229 #endif
00230
00231 key_type_s(type_t t = (type_t)0, char v = 0, uint2_t l = 0)
00232 : type((char) t), variable(v), length(l), compressed(false) {};
00233
00234
00235
00236
00237
00238
00239 static w_rc_t parse_key_type(const char* s, w_base_t::uint4_t& count, key_type_s kc[]);
00240 static w_rc_t get_key_type(char* s, int buflen, w_base_t::uint4_t count, const key_type_s *kc);
00241
00242 };
00243 #define null_lsn (lsn_t::null)
00244 #define max_lsn (lsn_t::max)
00245
00246 inline ostream& operator<<(ostream& o, const lsn_t& l)
00247 {
00248 return o << l.file() << '.' << l.rba();
00249 }
00250
00251 inline istream& operator>>(istream& i, lsn_t& l)
00252 {
00253 sm_diskaddr_t d;
00254 char c;
00255 w_base_t::uint8_t f;
00256 i >> f >> c >> d;
00257 l = lsn_t(f, d);
00258 return i;
00259 }
00260
00261 inline lpid_t::lpid_t() : page(0) {}
00262
00263 inline lpid_t::lpid_t(const stid_t& s, shpid_t p) : _stid(s), page(p)
00264 {}
00265
00266 inline lpid_t::lpid_t(vid_t v, snum_t s, shpid_t p) :
00267 _stid(v, s), page(p)
00268 {}
00269
00270 inline shrid_t::shrid_t() : page(0), store(0), slot(0)
00271 {}
00272 inline shrid_t::shrid_t(const rid_t& r) :
00273 page(r.pid.page), store(r.pid.store()), slot(r.slot)
00274 {}
00275
00276 inline rid_t::rid_t() : slot(0)
00277 {}
00278
00279 inline rid_t::rid_t(vid_t vid, const shrid_t& shrid) :
00280 pid(vid, shrid.store, shrid.page), slot(shrid.slot)
00281 {}
00282
00283 inline stid_t rid_t::stid() const
00284 {
00285 return pid.stid();
00286 }
00287
00288 inline bool lpid_t::operator==(const lpid_t& p) const
00289 {
00290 return (page == p.page) && (stid() == p.stid());
00291 }
00292
00293 inline bool lpid_t::operator!=(const lpid_t& p) const
00294 {
00295 return !(*this == p);
00296 }
00297
00298 inline bool lpid_t::operator<=(const lpid_t& p) const
00299 {
00300 return _stid == p._stid && page <= p.page;
00301 }
00302
00303 inline bool lpid_t::operator>=(const lpid_t& p) const
00304 {
00305 return _stid == p._stid && page >= p.page;
00306 }
00307
00308 inline bool rid_t::operator==(const rid_t& r) const
00309 {
00310 return (pid == r.pid && slot == r.slot);
00311 }
00312
00313 inline bool rid_t::operator!=(const rid_t& r) const
00314 {
00315 return !(*this == r);
00316 }
00317
00318
00319
00320 #endif