diff options
author | Mathias Stearn <mathias@10gen.com> | 2010-12-22 14:26:01 -0500 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2010-12-22 16:52:47 -0500 |
commit | 0bd4f7db8d750438722048eb9cc46d95e71be82e (patch) | |
tree | 769827f89b7f9a8d930b390d32cf239d43545c57 /db | |
parent | 82d46601e1283d7140523a800b77a2af0957e44b (diff) | |
download | mongo-0bd4f7db8d750438722048eb9cc46d95e71be82e.tar.gz |
privatize permanent members of WriteIntent
Diffstat (limited to 'db')
-rw-r--r-- | db/dur_commitjob.h | 11 | ||||
-rw-r--r-- | db/dur_preplogbuffer.cpp | 6 | ||||
-rw-r--r-- | db/dur_writetodatafiles.cpp | 4 |
3 files changed, 12 insertions, 9 deletions
diff --git a/db/dur_commitjob.h b/db/dur_commitjob.h index 645eff5388c..023dcce1ee7 100644 --- a/db/dur_commitjob.h +++ b/db/dur_commitjob.h @@ -34,13 +34,10 @@ namespace mongo { struct WriteIntent /* copyable */ { WriteIntent() : w_ptr(0), p(0) { } WriteIntent(void *a, unsigned b) : w_ptr(0), p(a), len(b) { } - /*temp*/ mutable void *w_ptr; // p is mapped from private to equivalent location in the writable mmap - void *p; // intent to write at p - unsigned len; // up to this len - // these two are to make algorithms more readable void* start() const { return p; } void* end() const { return (char*) p + len; } + int length() const { return len; } bool operator < (const WriteIntent& rhs) const { return end() < rhs.end(); } @@ -60,6 +57,12 @@ namespace mongo { friend ostream& operator << (ostream& out, const WriteIntent& wi) { return (out << "p: " << wi.p << " end: " << wi.end() << " len: " << wi.len); } + + /*temp*/ mutable void *w_ptr; // p is mapped from private to equivalent location in the writable mmap + private: + void *p; // intent to write at p + unsigned len; // up to this len + }; /** try to remember things we have already marked for journalling. false negatives are ok if infrequent - diff --git a/db/dur_preplogbuffer.cpp b/db/dur_preplogbuffer.cpp index 2daf06b7875..cc710f6f7e6 100644 --- a/db/dur_preplogbuffer.cpp +++ b/db/dur_preplogbuffer.cpp @@ -52,7 +52,7 @@ namespace mongo { void prepBasicWrite(AlignedBuilder&bb, const WriteIntent *i, RelativePath& lastDbPath) { size_t ofs = 1; - MongoMMF *mmf = findMMF(i->p, /*out*/ofs); + MongoMMF *mmf = findMMF(i->start(), /*out*/ofs); dassert( i->w_ptr == 0 ); if( !mmf->willNeedRemap() ) { @@ -68,7 +68,7 @@ namespace mongo { i->w_ptr = ((char*)mmf->view_write()) + ofs; JEntry e; - e.len = i->len; + e.len = i->length(); assert( ofs <= 0x80000000 ); e.ofs = (unsigned) ofs; e.setFileNo( mmf->fileSuffixNo() ); @@ -82,7 +82,7 @@ namespace mongo { bb.appendStr(lastDbPath.toString()); } bb.appendStruct(e); - bb.appendBuf(i->p, i->len); + bb.appendBuf(i->start(), i->length()); } /** basic write ops / write intents. note there is no particular order to these : if we have diff --git a/db/dur_writetodatafiles.cpp b/db/dur_writetodatafiles.cpp index 4c46e5ef4a5..344a85d85d8 100644 --- a/db/dur_writetodatafiles.cpp +++ b/db/dur_writetodatafiles.cpp @@ -48,9 +48,9 @@ namespace mongo { /* we go backwards as what is at the end is most likely in the cpu cache. it won't be much, but we'll take it. */ for( set<WriteIntent>::const_iterator it(commitJob.writes().begin()), end(commitJob.writes().end()); it != end; ++it ){ const WriteIntent& intent = *it; - stats.curr._writeToDataFilesBytes += intent.len; + stats.curr._writeToDataFilesBytes += intent.length(); dassert(intent.w_ptr); - memcpy(intent.w_ptr, intent.p, intent.len); + memcpy(intent.w_ptr, intent.start(), intent.length()); } debugValidateMapsMatch(); |