#include <NVArray.h>
Inheritance diagram for NVArray:

Public Types | |
| enum | { force = 0x1 } |
Public Member Functions | |
| NVArray () | |
| NVArray (const char *dbname, int flags=0) | |
| ASSERT (nvoff_t nvalloc(size_t rsz);void nvfree(nvoff_t p);) void open(const char *dbname | |
| void | ssetsize (unsigned long fst, unsigned long lst) |
| int | setsize (unsigned long fst, unsigned long lst, int flags=0) |
| void | getsize (unsigned long *fst, unsigned long *lst) |
| void | clear (void) |
| void | set (unsigned long i, const char *data, size_t szdata) |
| void | del (unsigned long i) |
| int | is_empty (void) |
| int | has_element (unsigned long i) |
| void | get (unsigned long i, const char **data, size_t *szdata) |
| void | print (ostream &os) |
Public Attributes | |
| int | flags = 0) |
Protected Member Functions | |
| void | make_current (void) |
| void | sclear (void) |
| void | sset (unsigned long i, const char *data, size_t szdata) |
| void | sdel (unsigned long i) |
| int | sis_empty (void) |
| int | shas_element (unsigned long i) |
| void | sget (unsigned long i, char **data, size_t *szdata) |
| void | sprint (ostream &os) |
Protected Attributes | |
| nvoff_t * | arrtab |
| unsigned long | arrfst |
| unsigned long | arrlst |
Definition at line 19 of file NVArray.h.
|
|
Definition at line 34 of file NVArray.h.
00034 {
00035 force = 0x1
00036 };
|
|
|
Definition at line 37 of file NVArray.h.
00037 :NVcontainer() { 00038 } NVArray(const char *dbname, int flags = 0); |
|
||||||||||||
|
Definition at line 114 of file NVArray.cc. References NVcontainer::open().
00115 :NVcontainer() 00116 { 00117 open(dbname, flags); 00118 } |
|
|
Open an NVArray container
|
|
|
Definition at line 225 of file NVArray.cc. References NVcontainer::lock(), and sclear(). Referenced by CNewsgroup::sUpdateGroupInfo().
|
|
|
Definition at line 239 of file NVArray.cc. References NVcontainer::lock(), and sdel().
|
|
||||||||||||||||
|
Definition at line 264 of file NVArray.cc. References NVcontainer::lock(), and sget().
|
|
||||||||||||
|
Returns the size of NVArray.
Definition at line 69 of file NVArray.h. References arrfst, and arrlst. Referenced by NVNewsgroup::getarticle(), NVNewsgroup::getover(), NVNewsgroup::printarticle(), NVNewsgroup::printheaderdb(), NVNewsgroup::setarticle(), NVNewsgroup::setover(), and NVNewsgroup::sprintover().
|
|
|
Definition at line 255 of file NVArray.cc. References NVcontainer::lock(), and shas_element(). Referenced by NVNewsgroup::hasrecord().
00256 {
00257 int r;
00258 lock(ShrdLock);
00259 r = shas_element(i);
00260 lock(UnLock);
00261 return r;
00262 }
|
|
|
Definition at line 246 of file NVArray.cc. References NVcontainer::lock(), and sis_empty().
|
|
|
Reimplemented from NVcontainer. Definition at line 12 of file NVArray.cc. References arrfst, arrlst, arrtab, NVcontainer::getdata(), NVcontainer::is_current(), NVcontainer::make_current(), and nvoff_t.
00013 {
00014 nvoff_t adata;
00015
00016 if (!mem_p || !is_current())
00017 NVcontainer::make_current();
00018 if ((adata = getdata()) == 0) {
00019 arrtab = NULL;
00020 arrfst = 1;
00021 arrlst = 0;
00022 } else {
00023 arrtab =
00024 (nvoff_t *) (mem_p + adata +
00025 2 * sizeof(unsigned long));
00026 arrfst = *(unsigned long *) (mem_p + adata);
00027 arrlst = *((unsigned long *) (mem_p + adata) + 1);
00028 }
00029 }
|
|
|
Definition at line 271 of file NVArray.cc. References NVcontainer::lock(), and sprint().
|
|
|
Definition at line 31 of file NVArray.cc. References arrfst, arrlst, arrtab, and NVcontainer::nvfree(). Referenced by clear().
|
|
|
Definition at line 55 of file NVArray.cc. References arrtab, and NVcontainer::nvfree(). Referenced by del().
|
|
||||||||||||||||
|
Definition at line 232 of file NVArray.cc. References NVcontainer::lock(), and sset().
|
|
||||||||||||||||
|
Sets a new size for the NVArray.
Definition at line 179 of file NVArray.cc. References arrlst, force, NVcontainer::lock(), NVcontainer::nvfree(), and ssetsize().
00180 {
00181 // Usually, the user should have already set an excludive lock
00182 // Otherwise, it cannot be guaranteed that no other process
00183 // changes the arraysize again
00184 // This is just to ensure that the NVArray cannot get inconsistent
00185 // even in the case where the user uses this database incorrectly.
00186 lock(ExclLock);
00187 int ok = 1;
00188 unsigned long i, n;
00189
00190 if (arrfst <= arrlst) {
00191 // Clean up existing array or return an error
00192 if (fst > arrfst) {
00193 n = fst - arrfst + 1;
00194 for (i = 0; i < n; i++) {
00195 if (arrtab[i]) {
00196 if (flags & force)
00197 nvfree(arrtab[i]);
00198 else
00199 ok = 0;
00200 }
00201 }
00202 }
00203 if (lst < arrlst) {
00204 n = arrlst - arrfst + 1;
00205 for (i = lst - arrfst + 1; i < n; i++) {
00206 if (arrtab[i]) {
00207 if (flags & force) {
00208 nvfree(arrtab[i]);
00209 arrtab[i] = 0;
00210 } else
00211 ok = 0;
00212 }
00213 }
00214 }
00215 }
00216 if (ok)
00217 ssetsize(fst, lst);
00218 lock(UnLock);
00219 if (ok)
00220 return 0;
00221 else
00222 return -1;
00223 }
|
|
||||||||||||||||
|
Definition at line 83 of file NVArray.cc. References arrfst, arrlst, and arrtab. Referenced by get(), NVNewsgroup::getarticle(), NVNewsgroup::getover(), CNewsgroup::prefetchGroup(), NVNewsgroup::printarticle(), NVNewsgroup::printheaderdb(), NVNewsgroup::setarticle(), NVNewsgroup::setover(), and NVNewsgroup::sprintover().
|
|
|
Definition at line 76 of file NVArray.cc. References arrfst, arrlst, and arrtab. Referenced by has_element(), NVNewsgroup::printlistgroup(), and CNewsgroup::sUpdateOverview().
|
|
|
Definition at line 63 of file NVArray.cc. References arrfst, arrlst, and arrtab. Referenced by is_empty().
|
|
|
Definition at line 94 of file NVArray.cc. References arrfst, arrlst, and arrtab. Referenced by print().
00095 {
00096 unsigned long i, n;
00097
00098 if (arrfst > arrlst)
00099 return;
00100 n = arrlst - arrfst + 1;
00101 for (i = 0; i < n; i++) {
00102 if (arrtab[i]) {
00103 os << arrfst +
00104 i << "/" << *(unsigned long *) (mem_p +
00105 arrtab[i])
00106 << ":" << mem_p + arrtab[i] +
00107 sizeof(unsigned long) << endl;
00108 } else {
00109 os << arrfst + i << "/(null):" << endl;
00110 }
00111 }
00112 }
|
|
||||||||||||||||
|
Definition at line 43 of file NVArray.cc. References arrtab, NVcontainer::nvalloc(), NVcontainer::nvfree(), and nvoff_t. Referenced by set().
|
|
||||||||||||
|
Definition at line 147 of file NVArray.cc. References arrlst, NVcontainer::getdata(), NVcontainer::nvalloc(), NVcontainer::nvfree(), nvoff_t, and NVcontainer::setdata(). Referenced by NVNewsgroup::setsize(), and setsize().
00148 {
00149 nvoff_t *ndata;
00150 nvoff_t p, q;
00151 unsigned long i, n;
00152
00153 p = nvalloc((lst - fst + 1 + 2) * sizeof(unsigned long));
00154 q = getdata();
00155 ndata = (nvoff_t *) (mem_p + p);
00156 ndata[0] = fst;
00157 ndata[1] = lst;
00158 n = lst - fst + 1;
00159 if (arrfst <= arrlst) {
00160 for (i = 0; i < n; i++) {
00161 if (arrfst <= i + fst && i + fst <= arrlst) {
00162 ndata[2 + i] = arrtab[i + fst - arrfst];
00163 } else {
00164 ndata[2 + i] = 0;
00165 }
00166 }
00167 } else {
00168 for (i = 0; i < n; i++)
00169 ndata[2 + i] = 0;
00170 }
00171 arrfst = fst;
00172 arrlst = lst;
00173 setdata(p);
00174 arrtab = ndata + 2;
00175 if (q)
00176 nvfree(q);
00177 }
|
|
|
Definition at line 23 of file NVArray.h. Referenced by getsize(), make_current(), sclear(), sget(), shas_element(), sis_empty(), and sprint(). |
|
|
Definition at line 23 of file NVArray.h. Referenced by getsize(), make_current(), sclear(), setsize(), sget(), shas_element(), sis_empty(), sprint(), and ssetsize(). |
|
|
Definition at line 22 of file NVArray.h. Referenced by make_current(), sclear(), sdel(), sget(), shas_element(), sis_empty(), sprint(), and sset(). |
|
|
|
1.3.6-20040222