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 #include "w_defines.h"
00031
00032
00033 #include "sm_vas.h"
00034
00035
00036
00037
00038 vid_t vol(1000);
00039 stid_t stor(vol,900);
00040 lpid_t page(stor, 50);
00041 rid_t rec(page, 6);
00042 extid_t extent;
00043 kvl_t kvl;
00044 typedef lockid_t::user1_t user1_t;
00045 typedef lockid_t::user2_t user2_t;
00046 typedef lockid_t::user3_t user3_t;
00047 typedef lockid_t::user4_t user4_t;
00048 user1_t u1(1);
00049 user2_t u2(u1.u1, 2);
00050 user3_t u3(u1.u1, u2.u2, 3);
00051 user4_t u4(u1.u1, u2.u2, u3.u3, 4);
00052
00053
00054 void dump(lockid_t &l)
00055 {
00056 cout << "Lock: lspace " << l.lspace() << endl;
00057 cout << "\t vid()=" << l.vid() << endl;
00058
00059 stid_t stor;
00060 l.extract_stid(stor);
00061 cout << "\t store()=" << l.store() << " stid_t=(" << stor << ")" << endl;
00062
00063
00064 lpid_t page;
00065 l.extract_lpid(page);
00066 cout << "\t page()=" << l.page() << " (lpid_t=" << page << ")" << endl;
00067
00068 rid_t rec;
00069 l.extract_rid(rec);
00070 cout << "\t slot()=" << l.slot() << " (rid_t=" << rec << ")" << endl;
00071
00072 extid_t extent;
00073 l.extract_extent(extent);
00074 cout << "\t extent()=" << l.extent() << " (extid_t=" << extent << ")" << endl;
00075
00076 #if defined(DEBUG_DESPERATE)
00077
00078
00079 kvl_t kvl;
00080 l.extract_kvl(kvl);
00081 cout << "\t kvl" << "(" << kvl << ")" << endl;
00082 #endif
00083
00084 user1_t u1;
00085 l.extract_user1(u1);
00086 cout << "\t u1()=" << l.u1() << " user1_t=(" << u1 << ")" << endl;
00087
00088 user2_t u2;
00089 l.extract_user2(u2);
00090 cout << "\t u2()=" << l.u2() << " (user2_t=" << u2 << ")" << endl;
00091
00092 user3_t u3;
00093 l.extract_user3(u3);
00094 cout << "\t u3()=" << l.u3() << " ( user3_t=" << u3 << ")" << endl;
00095
00096 user4_t u4;
00097 l.extract_user4(u4);
00098 cout << "\t u4()=" << l.u4() << " ( user4_t=" << u4 << ")" << endl;
00099
00100 #if defined(DEBUG_DESPERATE)
00101
00102 {
00103 cout << "hex/dec dump - b" << endl;
00104 u_char *p = (u_char *)&l;
00105 for(int i=0; i < int(sizeof(l)); i++) {
00106 cout << i << ":" << ::hex << unsigned(*p)
00107 << "/" << ::dec << unsigned(*p) << " " ;
00108 p++;
00109 }
00110 cout << endl;
00111 }
00112 {
00113 cout << "hex/dec dump - s" << endl;
00114 uint2_t *p = (uint2_t *)&l;
00115 for(int i=0; i < int(sizeof(l)/sizeof(uint2_t)); i++) {
00116 cout << i << ":" << ::hex << unsigned(*p)
00117 << "/" << ::dec << unsigned(*p) << " ";
00118 p++;
00119 }
00120 cout << endl;
00121 }
00122 {
00123 cout << "hex/dec dump - w" << endl;
00124 u_int *p = (u_int *)&l;
00125 for(int i=0; i < int(sizeof(l)/sizeof(uint_t)); i++) {
00126 cout << i << ":" << ::hex << unsigned(*p)
00127 << "/" << ::dec << unsigned(*p) << " ";
00128 p++;
00129 }
00130 cout << endl;
00131 }
00132 #endif
00133 }
00134
00135 int
00136 main(int , char* [])
00137 {
00138 extent.vol = vol;
00139 extent.ext = 33;
00140
00141 const char *keybuf = "Admiral Richard E. Byrd";
00142 const char *elembuf= "Most of the confusion in the world comes from not knowing how little we need.";
00143 vec_t key(keybuf, strlen(keybuf));
00144 vec_t elem(elembuf, strlen(elembuf));
00145 kvl.set(stor, key, elem);
00146
00147 cout << "Sources: " << endl
00148 << "\t vol " << vol << endl
00149 << "\t store " << stor << endl
00150 << "\t page " << page << endl
00151 << "\t rec " << rec << endl
00152 << "\t kvl " << kvl << endl
00153 << "\t extent " << extent << endl
00154 << "\t u1 " << u1 << endl
00155 << "\t u2 " << u2 << endl
00156 << "\t u3 " << u3 << endl
00157 << "\t u4 " << u4 << endl
00158 ;
00159
00160 {
00161 lockid_t l(vol);
00162 cout << "{ Volume lock " << l << endl;
00163 dump(l);
00164 cout << "}" << endl;
00165 }
00166 {
00167 lockid_t l(stor);
00168 cout << "Store lock " << l << endl;
00169 dump(l);
00170 cout << "}" << endl;
00171 }
00172 {
00173 lockid_t l(page);
00174 cout << "Page lock " << l << endl;
00175 dump(l);
00176 cout << "}" << endl;
00177 }
00178 {
00179 lockid_t l(rec);
00180 cout << "Record lock " << l << endl;
00181 dump(l);
00182 cout << "}" << endl;
00183 }
00184 {
00185 lockid_t l(kvl);
00186 cout << "Kvl lock " << l << endl;
00187 cout << "}" << endl;
00188 }
00189 {
00190 lockid_t l(extent);
00191 cout << "Extent lock " << l << endl;
00192 dump(l);
00193 cout << "}" << endl;
00194 }
00195 {
00196 lockid_t l(u1);
00197 cout << "User 1 lock " << l << endl;
00198 dump(l);
00199 cout << "}" << endl;
00200 }
00201 {
00202 lockid_t l(u2);
00203 cout << "User 2 lock " << l << endl;
00204 dump(l);
00205 cout << "}" << endl;
00206 }
00207 {
00208 lockid_t l(u3);
00209 cout << "User 3 lock " << l << endl;
00210 dump(l);
00211 cout << "}" << endl;
00212 }
00213 {
00214 lockid_t l(u4);
00215 cout << "User 4 lock " << l << endl;
00216 dump(l);
00217 cout << "}" << endl;
00218 }
00219 }
00220