mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
mmf abstraction 2
This commit is contained in:
parent
a4db903faa
commit
4778a2c4ad
@ -137,8 +137,8 @@ namespace mongo {
|
||||
int minSize = 0;
|
||||
if ( n != 0 && files[ n - 1 ] )
|
||||
minSize = files[ n - 1 ]->getHeader()->fileLength;
|
||||
if ( sizeNeeded + MDFHeader::headerSize() > minSize )
|
||||
minSize = sizeNeeded + MDFHeader::headerSize();
|
||||
if ( sizeNeeded + DataFileHeader::headerSize() > minSize )
|
||||
minSize = sizeNeeded + DataFileHeader::headerSize();
|
||||
try {
|
||||
p->open( fullNameString.c_str(), minSize, preallocateOnly );
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ namespace mongo {
|
||||
bool shouldRepairDatabases = 0;
|
||||
bool forceRepair = 0;
|
||||
|
||||
bool doDBUpgrade( const string& dbName , string errmsg , MDFHeader * h ){
|
||||
bool doDBUpgrade( const string& dbName , string errmsg , DataFileHeader * h ){
|
||||
static DBDirectClient db;
|
||||
|
||||
if ( h->version == 4 && h->versionMinor == 4 ){
|
||||
@ -361,7 +361,7 @@ namespace mongo {
|
||||
log(1) << "\t" << dbName << endl;
|
||||
Client::Context ctx( dbName );
|
||||
MongoDataFile *p = cc().database()->getFile( 0 );
|
||||
MDFHeader *h = p->getHeader();
|
||||
DataFileHeader *h = p->getHeader();
|
||||
if ( !h->currentVersion() || forceRepair ) {
|
||||
log() << "****" << endl;
|
||||
log() << "****" << endl;
|
||||
|
@ -199,7 +199,7 @@ namespace mongo {
|
||||
}
|
||||
} else {
|
||||
while ( size > 0 ) {
|
||||
int max = MongoDataFile::maxSize() - MDFHeader::headerSize();
|
||||
int max = MongoDataFile::maxSize() - DataFileHeader::headerSize();
|
||||
int desiredExtentSize = (int) (size > max ? max : size);
|
||||
Extent *e = database->allocExtent( ns, desiredExtentSize, newCapped );
|
||||
size -= e->length;
|
||||
@ -325,7 +325,8 @@ namespace mongo {
|
||||
return;
|
||||
}
|
||||
|
||||
header = (MDFHeader *) mmf.map(filename, size);
|
||||
_p = mmf.map(filename, size);
|
||||
header = (DataFileHeader *) _p.at(0);
|
||||
if( sizeof(char *) == 4 )
|
||||
uassert( 10084 , "can't map file memory - mongo requires 64 bit build for larger datasets", header);
|
||||
else
|
||||
|
16
db/pdfile.h
16
db/pdfile.h
@ -34,7 +34,7 @@
|
||||
|
||||
namespace mongo {
|
||||
|
||||
class MDFHeader;
|
||||
class DataFileHeader;
|
||||
class Extent;
|
||||
class Record;
|
||||
class Cursor;
|
||||
@ -56,7 +56,6 @@ namespace mongo {
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
|
||||
class MDFHeader;
|
||||
class MongoDataFile {
|
||||
friend class DataFileMgr;
|
||||
friend class BasicCursor;
|
||||
@ -70,7 +69,7 @@ namespace mongo {
|
||||
*/
|
||||
Extent* createExtent(const char *ns, int approxSize, bool capped = false, int loops = 0);
|
||||
|
||||
MDFHeader *getHeader() {
|
||||
DataFileHeader *getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
@ -84,8 +83,10 @@ namespace mongo {
|
||||
Extent* _getExtent(DiskLoc loc);
|
||||
Record* recordAt(DiskLoc dl);
|
||||
|
||||
MemoryMappedFile mmf;
|
||||
MDFHeader *header;
|
||||
typedef MemoryMappedFile MMF;
|
||||
MMF mmf;
|
||||
MMF::Pointer _p;
|
||||
DataFileHeader *header;
|
||||
int fileNo;
|
||||
};
|
||||
|
||||
@ -254,8 +255,7 @@ namespace mongo {
|
||||
----------------------
|
||||
*/
|
||||
|
||||
/* data file header */
|
||||
class MDFHeader {
|
||||
class DataFileHeader {
|
||||
public:
|
||||
int version;
|
||||
int versionMinor;
|
||||
@ -267,7 +267,7 @@ namespace mongo {
|
||||
char data[4];
|
||||
|
||||
static int headerSize() {
|
||||
return sizeof(MDFHeader) - 4;
|
||||
return sizeof(DataFileHeader) - 4;
|
||||
}
|
||||
|
||||
bool currentVersion() const {
|
||||
|
@ -741,7 +741,7 @@ namespace NamespaceTests {
|
||||
// private:
|
||||
// virtual string spec() const {
|
||||
// // NOTE 256 added to size in _userCreateNS()
|
||||
// long long big = MongoDataFile::maxSize() - MDFHeader::headerSize();
|
||||
// long long big = MongoDataFile::maxSize() - DataFileHeader::headerSize();
|
||||
// stringstream ss;
|
||||
// ss << "{\"capped\":true,\"size\":" << big << "}";
|
||||
// return ss.str();
|
||||
|
Loading…
Reference in New Issue
Block a user