1
0
Fork 0

in-memory collections, seem to work now

documentation and some helper functions are still missing
This commit is contained in:
Jan Steemann 2013-01-04 17:04:15 +01:00
parent 6dce10de80
commit 51305de692
4 changed files with 32 additions and 7 deletions

View File

@ -1312,10 +1312,10 @@ static v8::Handle<v8::Value> CreateVocBase (v8::Arguments const& argv, TRI_col_t
} }
v8::Handle<v8::Object> p = argv[1]->ToObject(); v8::Handle<v8::Object> p = argv[1]->ToObject();
v8::Handle<v8::String> waitForSyncKey = v8::String::New("waitForSync"); v8::Handle<v8::String> isSystemKey = v8::String::New("isSystem");
v8::Handle<v8::String> journalSizeKey = v8::String::New("journalSize"); v8::Handle<v8::String> isVolatileKey = v8::String::New("isVolatile");
v8::Handle<v8::String> isSystemKey = v8::String::New("isSystem"); v8::Handle<v8::String> journalSizeKey = v8::String::New("journalSize");
v8::Handle<v8::String> volatileKey = v8::String::New("isVolatile"); v8::Handle<v8::String> waitForSyncKey = v8::String::New("waitForSync");
v8::Handle<v8::String> createOptionsKey = v8::String::New("createOptions"); v8::Handle<v8::String> createOptionsKey = v8::String::New("createOptions");
if (p->Has(journalSizeKey)) { if (p->Has(journalSizeKey)) {
@ -1347,14 +1347,21 @@ static v8::Handle<v8::Value> CreateVocBase (v8::Arguments const& argv, TRI_col_t
parameter._isSystem = TRI_ObjectToBoolean(p->Get(isSystemKey)); parameter._isSystem = TRI_ObjectToBoolean(p->Get(isSystemKey));
} }
if (p->Has(volatileKey)) { if (p->Has(isVolatileKey)) {
parameter._isVolatile = TRI_ObjectToBoolean(p->Get(volatileKey)); #ifdef TRI_HAVE_ANONYMOUS_MMAP
parameter._isVolatile = TRI_ObjectToBoolean(p->Get(isVolatileKey));
#else
TRI_FreeCollectionInfoOptions(&parameter);
return scope.Close(v8::ThrowException(TRI_CreateErrorObject(TRI_ERROR_ILLEGAL_OPTION, "volatile collections are not supported on this platform", true)));
#endif
} }
if (parameter._isVolatile && parameter._waitForSync) { if (parameter._isVolatile && parameter._waitForSync) {
// the combination of waitForSync and isVolatile makes no sense // the combination of waitForSync and isVolatile makes no sense
parameter._waitForSync = false; TRI_FreeCollectionInfoOptions(&parameter);
return scope.Close(v8::ThrowException(TRI_CreateErrorObject(TRI_ERROR_BAD_PARAMETER, "volatile collections do not support the waitForSync option", true)));
} }
} }
else { else {
TRI_InitCollectionInfo(vocbase, &parameter, name.c_str(), collectionType, effectiveSize, 0); TRI_InitCollectionInfo(vocbase, &parameter, name.c_str(), collectionType, effectiveSize, 0);

View File

@ -751,7 +751,12 @@ TRI_datafile_t* TRI_CreateDatafile (char const* filename,
// create either an anonymous or a physical datafile // create either an anonymous or a physical datafile
if (filename == NULL) { if (filename == NULL) {
#ifdef TRI_HAVE_ANONYMOUS_MMAP
datafile = TRI_CreateAnonymousDatafile(maximalSize); datafile = TRI_CreateAnonymousDatafile(maximalSize);
#else
// system does not support anonymous mmap
return NULL;
#endif
} }
else { else {
datafile = TRI_CreatePhysicalDatafile(filename, maximalSize); datafile = TRI_CreatePhysicalDatafile(filename, maximalSize);
@ -809,6 +814,8 @@ TRI_datafile_t* TRI_CreateDatafile (char const* filename,
/// @brief creates a new anonymous datafile /// @brief creates a new anonymous datafile
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifdef TRI_HAVE_ANONYMOUS_MMAP
TRI_datafile_t* TRI_CreateAnonymousDatafile (const TRI_voc_size_t maximalSize) { TRI_datafile_t* TRI_CreateAnonymousDatafile (const TRI_voc_size_t maximalSize) {
TRI_datafile_t* datafile; TRI_datafile_t* datafile;
ssize_t res; ssize_t res;
@ -818,6 +825,7 @@ TRI_datafile_t* TRI_CreateAnonymousDatafile (const TRI_voc_size_t maximalSize) {
int fd; int fd;
// TODO: find a good workaround for Windows // TODO: find a good workaround for Windows
// TODO: make this more portable
#ifdef MAP_ANONYMOUS #ifdef MAP_ANONYMOUS
// this is required for "real" anonymous regions // this is required for "real" anonymous regions
@ -872,6 +880,8 @@ TRI_datafile_t* TRI_CreateAnonymousDatafile (const TRI_voc_size_t maximalSize) {
return datafile; return datafile;
} }
#endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief creates a new physical datafile /// @brief creates a new physical datafile
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -434,7 +434,9 @@ TRI_datafile_t* TRI_CreateDatafile (char const*,
/// automatically adds a @ref TRI_df_footer_marker_t to the file. /// automatically adds a @ref TRI_df_footer_marker_t to the file.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifdef TRI_HAVE_ANONYMOUS_MMAP
TRI_datafile_t* TRI_CreateAnonymousDatafile (TRI_voc_size_t); TRI_datafile_t* TRI_CreateAnonymousDatafile (TRI_voc_size_t);
#endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief creates a new physical datafile /// @brief creates a new physical datafile

View File

@ -114,6 +114,9 @@
#define TRI_HAVE_STRTOLL 1 #define TRI_HAVE_STRTOLL 1
#define TRI_HAVE_STRTOULL 1 #define TRI_HAVE_STRTOULL 1
// TODO: add a feature check in configure
#define TRI_HAVE_ANONYMOUS_MMAP 1
#define TRI_OVERLOAD_FUNCS_SIZE_T 1 #define TRI_OVERLOAD_FUNCS_SIZE_T 1
#define TRI_MISSING_MEMRCHR 1 #define TRI_MISSING_MEMRCHR 1
@ -335,6 +338,9 @@ typedef int socket_t;
#define TRI_HAVE_STRTOLL 1 #define TRI_HAVE_STRTOLL 1
#define TRI_HAVE_STRTOULL 1 #define TRI_HAVE_STRTOULL 1
// TODO: add a feature check in configure
#define TRI_HAVE_ANONYMOUS_MMAP 1
#if __WORDSIZE == 64 #if __WORDSIZE == 64
#define TRI_SIZEOF_SIZE_T 8 #define TRI_SIZEOF_SIZE_T 8
#define TRI_ALIGNOF_VOIDP 8 #define TRI_ALIGNOF_VOIDP 8