0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

option to use main memory instead of memory mapped files

really only for testing
though i guess is kind of cool if you want to use the db purely for an in memory cache
scons --mm to build
This commit is contained in:
Eliot Horowitz 2009-01-29 22:31:13 -05:00
parent 22e5d9e94f
commit df2b701b0f
2 changed files with 62 additions and 1 deletions

View File

@ -32,6 +32,15 @@ AddOption( "--32",
action="store",
help="whether to force 32 bit" )
AddOption( "--mm",
dest="mm",
type="string",
nargs=0,
action="store",
help="use main memory instead of memory mapped files" )
AddOption( "--release",
dest="release",
type="string",
@ -73,7 +82,9 @@ commonFiles += Split( "client/connpool.cpp client/dbclient.cpp client/model.cpp"
#mmap stuff
if os.sys.platform == "win32":
if GetOption( "mm" ) != None:
commonFiles += [ "util/mmap_mm.cpp" ]
elif os.sys.platform == "win32":
commonFiles += [ "util/mmap_win.cpp" ]
else:
commonFiles += [ "util/mmap_posix.cpp" ]

50
util/mmap_mm.cpp Normal file
View File

@ -0,0 +1,50 @@
// mmap_mm.cpp
/**
* Copyright (C) 2008 10gen Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
#include "mmap.h"
namespace mongo {
MemoryMappedFile::MemoryMappedFile() {
fd = 0;
maphandle = 0;
view = 0;
len = 0;
}
void MemoryMappedFile::close() {
if ( view )
delete( view );
view = 0;
len = 0;
}
void* MemoryMappedFile::map(const char *filename, int length) {
path p( filename );
view = malloc( length );
return view;
}
void MemoryMappedFile::flush(bool sync) {
}
}