From b5b00ebdb05606d2fe9e9c1ba9929d2903a3803b Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Mon, 17 Mar 2014 09:00:15 +0100 Subject: [PATCH 1/4] set vocbase state for "artificial" databases --- arangod/VocBase/server.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arangod/VocBase/server.c b/arangod/VocBase/server.c index c2ea0c9d29..266fc93904 100644 --- a/arangod/VocBase/server.c +++ b/arangod/VocBase/server.c @@ -2126,6 +2126,8 @@ int TRI_CreateCoordinatorDatabaseServer (TRI_server_t* server, WRITE_UNLOCK_DATABASES(server->_databasesLock); TRI_UnlockMutex(&server->_createLock); + + vocbase->_state = (sig_atomic_t) TRI_VOCBASE_STATE_NORMAL; *database = vocbase; From 9810780ebe57f1a66103eabab49d749a95a94353 Mon Sep 17 00:00:00 2001 From: gschwab Date: Mon, 17 Mar 2014 09:21:34 +0100 Subject: [PATCH 2/4] css refactoring: moved content of loginView.css to _login.scss: not used yet, so not active in style.scss --- .../{css/loginView.css => scss/_login.scss} | 23 ++++++++----------- .../system/aardvark/frontend/scss/style.scss | 2 ++ js/apps/system/aardvark/manifest.json | 1 - 3 files changed, 12 insertions(+), 14 deletions(-) rename js/apps/system/aardvark/frontend/{css/loginView.css => scss/_login.scss} (95%) diff --git a/js/apps/system/aardvark/frontend/css/loginView.css b/js/apps/system/aardvark/frontend/scss/_login.scss similarity index 95% rename from js/apps/system/aardvark/frontend/css/loginView.css rename to js/apps/system/aardvark/frontend/scss/_login.scss index 0ce83be851..12fc013871 100644 --- a/js/apps/system/aardvark/frontend/css/loginView.css +++ b/js/apps/system/aardvark/frontend/scss/_login.scss @@ -1,24 +1,21 @@ #loginWindow { - width: 400px; - height: 300px; - border: 1px solid #868686; - position: absolute; - left: 50%; - top: 50%; - margin-top: -150px; - margin-left: -220px !important; background-color: #F4F4F4; + border: 1px solid #868686; border-radius: 2px; + height: 300px; + left: 50%; + margin-left: -220px !important; + margin-top: -150px; + padding-left: 10px; + padding-right: 10px; + position: absolute; + top: 50%; + width: 400px; } #loginLogo { } -#loginWindow { - padding-left: 10px; - padding-right: 10px; -} - #loginSpace { height: 50px; } diff --git a/js/apps/system/aardvark/frontend/scss/style.scss b/js/apps/system/aardvark/frontend/scss/style.scss index 4b5cd3e43c..fd0a728469 100644 --- a/js/apps/system/aardvark/frontend/scss/style.scss +++ b/js/apps/system/aardvark/frontend/scss/style.scss @@ -27,3 +27,5 @@ @import 'searchBar'; // shortcuts info boxes @import 'shortcuts'; +// login view +//@import 'login'; diff --git a/js/apps/system/aardvark/manifest.json b/js/apps/system/aardvark/manifest.json index 2ac7c40966..8c062a0aac 100644 --- a/js/apps/system/aardvark/manifest.json +++ b/js/apps/system/aardvark/manifest.json @@ -142,7 +142,6 @@ "frontend/css/swaggerView.css", "frontend/css/foxxView.css", "frontend/css/graphView.css", - "frontend/css/loginView.css", "frontend/css/dbSelectionView.css", "frontend/css/jquery.snippet.css", "frontend/css/modal.css", From fe5d2096fac4a92b2423754bff84a6bf2f11e491 Mon Sep 17 00:00:00 2001 From: gschwab Date: Mon, 17 Mar 2014 10:27:23 +0100 Subject: [PATCH 3/4] css refactoring: deleted general.css; already backuped by scss --- js/apps/system/aardvark/frontend/css/general.css | 6 ------ js/apps/system/aardvark/frontend/js/templates/graphView.ejs | 2 +- js/apps/system/aardvark/manifest.json | 1 - 3 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 js/apps/system/aardvark/frontend/css/general.css diff --git a/js/apps/system/aardvark/frontend/css/general.css b/js/apps/system/aardvark/frontend/css/general.css deleted file mode 100644 index 4e7b844c3b..0000000000 --- a/js/apps/system/aardvark/frontend/css/general.css +++ /dev/null @@ -1,6 +0,0 @@ -div.content { - padding-top: 13px; - padding-left: 5px; - padding-right: 5px; - padding-bottom: 5px; -} \ No newline at end of file diff --git a/js/apps/system/aardvark/frontend/js/templates/graphView.ejs b/js/apps/system/aardvark/frontend/js/templates/graphView.ejs index 18272eb719..73b9d5856f 100644 --- a/js/apps/system/aardvark/frontend/js/templates/graphView.ejs +++ b/js/apps/system/aardvark/frontend/js/templates/graphView.ejs @@ -23,7 +23,7 @@ gs = _.sortBy(gs, sortF); Graph Viewer Configuration -
+
diff --git a/js/apps/system/aardvark/manifest.json b/js/apps/system/aardvark/manifest.json index 8c062a0aac..4f12dd545c 100644 --- a/js/apps/system/aardvark/manifest.json +++ b/js/apps/system/aardvark/manifest.json @@ -149,7 +149,6 @@ "frontend/css/graphlayout.css", "frontend/css/datatables.css", "frontend/css/api.css", - "frontend/css/general.css", "frontend/css/headerBar.css", "frontend/css/screenSizes.css", "frontend/css/clusterDashboardView.css", From c760272a7f58f3bd56b1b09cbce90851d9753f46 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Mon, 17 Mar 2014 11:29:13 +0100 Subject: [PATCH 4/4] provide a sint hint to indexes when initially filling them this may speed up building indexes when opening an existing collection --- arangod/VocBase/document-collection.c | 13 +++++++++++++ arangod/VocBase/index.c | 20 ++++++++++++++++++++ arangod/VocBase/index.h | 3 +++ lib/BasicsC/associative-multi.c | 23 ++++++++++++++++++----- lib/BasicsC/associative-multi.h | 6 ++++++ 5 files changed, 60 insertions(+), 5 deletions(-) diff --git a/arangod/VocBase/document-collection.c b/arangod/VocBase/document-collection.c index a32b6a7504..f5657ca55d 100644 --- a/arangod/VocBase/document-collection.c +++ b/arangod/VocBase/document-collection.c @@ -2708,14 +2708,27 @@ static bool OpenIterator (TRI_df_marker_t const* marker, //////////////////////////////////////////////////////////////////////////////// static bool FillInternalIndexes (TRI_document_collection_t* document) { + TRI_primary_collection_t* primary; size_t i; int res; + primary = (TRI_primary_collection_t*) document; + res = TRI_ERROR_NO_ERROR; for (i = 0; i < document->_allIndexes._length; ++i) { TRI_index_t* idx = document->_allIndexes._buffer[i]; + if (idx->sizeHint != NULL) { + // give the index a size hint + int r = idx->sizeHint(idx, primary->_primaryIndex._nrUsed); + + if (r != TRI_ERROR_NO_ERROR) { + // return first error, but continue + res = r; + } + } + if (idx->_type == TRI_IDX_TYPE_EDGE_INDEX) { int r = FillIndex(document, idx); diff --git a/arangod/VocBase/index.c b/arangod/VocBase/index.c index cea4792a76..990d0a9a7e 100644 --- a/arangod/VocBase/index.c +++ b/arangod/VocBase/index.c @@ -93,6 +93,7 @@ void TRI_InitIndex (TRI_index_t* idx, // init common functions idx->removeIndex = NULL; idx->cleanup = NULL; + idx->sizeHint = NULL; idx->postInsert = NULL; @@ -898,6 +899,23 @@ static TRI_json_t* JsonEdge (TRI_index_t* idx) { return json; } +//////////////////////////////////////////////////////////////////////////////// +/// @brief JSON description of edge index +//////////////////////////////////////////////////////////////////////////////// + +static int SizeHintEdge (TRI_index_t* idx, + size_t size) { + + TRI_multi_pointer_t* edgesIndex = &(((TRI_edge_index_t*) idx)->_edges); + + // we assume this is called when setting up the index and the index is still empty + assert(edgesIndex->_nrUsed == 0); + + // set an initial size for the index and allow for some new nodes to be created + // without resizing + return TRI_ResizeMultiPointer(edgesIndex, size + 2048); +} + //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// @@ -955,6 +973,8 @@ TRI_index_t* TRI_CreateEdgeIndex (struct TRI_primary_collection_s* primary, idx->insert = InsertEdge; idx->remove = RemoveEdge; + idx->sizeHint = SizeHintEdge; + return idx; } diff --git a/arangod/VocBase/index.h b/arangod/VocBase/index.h index 019b3ba145..916cd0c43f 100644 --- a/arangod/VocBase/index.h +++ b/arangod/VocBase/index.h @@ -124,6 +124,9 @@ typedef struct TRI_index_s { // a garbage collection function for the index int (*cleanup) (struct TRI_index_s*); + + // give index a hint about the expected size + int (*sizeHint) (struct TRI_index_s*, size_t); // ......................................................................................... // the following functions are called by the query machinery which attempting to determine an diff --git a/lib/BasicsC/associative-multi.c b/lib/BasicsC/associative-multi.c index 1e1ab1a4ec..28576060ad 100644 --- a/lib/BasicsC/associative-multi.c +++ b/lib/BasicsC/associative-multi.c @@ -588,7 +588,8 @@ static void AddNewElementPointer (TRI_multi_pointer_t* array, void* element) { /// @brief resizes the array //////////////////////////////////////////////////////////////////////////////// -static void ResizeMultiPointer (TRI_multi_pointer_t* array) { +static int ResizeMultiPointer (TRI_multi_pointer_t* array, + size_t targetSize) { void** oldTable; uint64_t oldAlloc; uint64_t j; @@ -596,7 +597,7 @@ static void ResizeMultiPointer (TRI_multi_pointer_t* array) { oldTable = array->_table; oldAlloc = array->_nrAlloc; - array->_nrAlloc = 2 * array->_nrAlloc + 1; + array->_nrAlloc = (uint64_t) targetSize; array->_table = TRI_Allocate(array->_memoryZone, array->_nrAlloc * sizeof(void*), true); @@ -604,7 +605,7 @@ static void ResizeMultiPointer (TRI_multi_pointer_t* array) { array->_nrAlloc = oldAlloc; array->_table = oldTable; - return; + return TRI_ERROR_OUT_OF_MEMORY; } array->_nrUsed = 0; @@ -619,7 +620,11 @@ static void ResizeMultiPointer (TRI_multi_pointer_t* array) { } } - TRI_Free(array->_memoryZone, oldTable); + if (oldTable != NULL) { + TRI_Free(array->_memoryZone, oldTable); + } + + return TRI_ERROR_NO_ERROR; } //////////////////////////////////////////////////////////////////////////////// @@ -831,7 +836,7 @@ void* TRI_InsertElementMultiPointer (TRI_multi_pointer_t* array, // if we were adding and the table is more than half full, extend it if (array->_nrAlloc < 2 * array->_nrUsed) { - ResizeMultiPointer(array); + ResizeMultiPointer(array, 2 * array->_nrAlloc + 1); } return NULL; @@ -892,6 +897,14 @@ void* TRI_RemoveElementMultiPointer (TRI_multi_pointer_t* array, void const* ele return old; } +//////////////////////////////////////////////////////////////////////////////// +/// @brief resize the array +//////////////////////////////////////////////////////////////////////////////// + +int TRI_ResizeMultiPointer (TRI_multi_pointer_t* array, size_t size) { + return ResizeMultiPointer(array, 2 * size + 1); +} + //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// diff --git a/lib/BasicsC/associative-multi.h b/lib/BasicsC/associative-multi.h index a3979d6c60..0e49221a7f 100644 --- a/lib/BasicsC/associative-multi.h +++ b/lib/BasicsC/associative-multi.h @@ -308,6 +308,12 @@ void* TRI_InsertElementMultiPointer (TRI_multi_pointer_t*, void* TRI_RemoveElementMultiPointer (TRI_multi_pointer_t*, void const* element); +//////////////////////////////////////////////////////////////////////////////// +/// @brief resize the array +//////////////////////////////////////////////////////////////////////////////// + +int TRI_ResizeMultiPointer (TRI_multi_pointer_t*, size_t); + //////////////////////////////////////////////////////////////////////////////// /// @} ////////////////////////////////////////////////////////////////////////////////