From a3923c9eaf833fbcea00c86b7215fc24157db4e7 Mon Sep 17 00:00:00 2001 From: Max Neunhoeffer Date: Mon, 18 May 2015 01:39:54 -0700 Subject: [PATCH] Fix configurability of indexBuckets. --- arangod/Cluster/ClusterInfo.cpp | 3 +++ arangod/Cluster/ClusterInfo.h | 8 ++++++++ arangod/V8Server/v8-collection.cpp | 13 +++++++++++++ .../js/modules/org/arangodb/arango-collection.js | 3 ++- .../js/modules/org/arangodb/arango-database.js | 2 +- js/client/modules/org/arangodb/arango-database.js | 2 +- js/server/modules/org/arangodb/cluster.js | 3 ++- 7 files changed, 30 insertions(+), 4 deletions(-) diff --git a/arangod/Cluster/ClusterInfo.cpp b/arangod/Cluster/ClusterInfo.cpp index 94ff74998e..c774dc131c 100644 --- a/arangod/Cluster/ClusterInfo.cpp +++ b/arangod/Cluster/ClusterInfo.cpp @@ -730,6 +730,7 @@ TRI_col_info_t ClusterInfo::getCollectionProperties (CollectionInfo const& colle info._isSystem = collection.isSystem(); info._isVolatile = collection.isVolatile(); info._waitForSync = collection.waitForSync(); + info._indexBuckets = collection.indexBuckets(); return info; } @@ -1347,10 +1348,12 @@ int ClusterInfo::setCollectionPropertiesCoordinator (string const& databaseName, TRI_DeleteObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "doCompact"); TRI_DeleteObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "journalSize"); TRI_DeleteObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "waitForSync"); + TRI_DeleteObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "indexBuckets"); TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "doCompact", TRI_CreateBooleanJson(TRI_UNKNOWN_MEM_ZONE, info->_doCompact)); TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "journalSize", TRI_CreateNumberJson(TRI_UNKNOWN_MEM_ZONE, info->_maximalSize)); TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "waitForSync", TRI_CreateBooleanJson(TRI_UNKNOWN_MEM_ZONE, info->_waitForSync)); + TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "indexBuckets", TRI_CreateNumberJson(TRI_UNKNOWN_MEM_ZONE, info->_indexBuckets)); res.clear(); res = ac.setValue("Plan/Collections/" + databaseName + "/" + collectionID, copy, 0.0); diff --git a/arangod/Cluster/ClusterInfo.h b/arangod/Cluster/ClusterInfo.h index 9b31ed8a92..7e322400aa 100644 --- a/arangod/Cluster/ClusterInfo.h +++ b/arangod/Cluster/ClusterInfo.h @@ -226,6 +226,14 @@ namespace triagens { return triagens::basics::JsonHelper::getNumericValue(_json, "journalSize", 0); } +//////////////////////////////////////////////////////////////////////////////// +/// @brief returns the maximal journal size +//////////////////////////////////////////////////////////////////////////////// + + uint32_t indexBuckets () const { + return triagens::basics::JsonHelper::getNumericValue(_json, "indexBuckets", 1); + } + //////////////////////////////////////////////////////////////////////////////// /// @brief returns the shard keys //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/V8Server/v8-collection.cpp b/arangod/V8Server/v8-collection.cpp index b20fd05d16..06864974df 100644 --- a/arangod/V8Server/v8-collection.cpp +++ b/arangod/V8Server/v8-collection.cpp @@ -2121,6 +2121,19 @@ static void JS_PropertiesVocbaseCol (const v8::FunctionCallbackInfo& } TRI_V8_THROW_EXCEPTION_PARAMETER("volatile collections do not support the waitForSync option"); } + + if (po->Has(TRI_V8_ASCII_STRING("indexBuckets"))) { + uint32_t tmp = TRI_ObjectToUInt64( + po->Get(TRI_V8_ASCII_STRING("indexBuckets")), + false); + if (tmp < 1 || tmp > 1024) { + if (info._keyOptions != nullptr) { + TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, info._keyOptions); + } + TRI_V8_THROW_EXCEPTION_PARAMETER("indexBucket must be a two-power between 1 and 1024"); + } + info._indexBuckets = tmp; + } } int res = ClusterInfo::instance()->setCollectionPropertiesCoordinator(databaseName, StringUtils::itoa(collection->_cid), &info); diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/modules/org/arangodb/arango-collection.js b/js/apps/system/_admin/aardvark/APP/frontend/js/modules/org/arangodb/arango-collection.js index e01668f3bf..acf0c45d1e 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/modules/org/arangodb/arango-collection.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/modules/org/arangodb/arango-collection.js @@ -334,7 +334,8 @@ ArangoCollection.prototype.properties = function (properties) { "waitForSync": true, "shardKeys": false, "numberOfShards": false, - "keyOptions": false + "keyOptions": false, + "indexBuckets": true }; var a; diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/modules/org/arangodb/arango-database.js b/js/apps/system/_admin/aardvark/APP/frontend/js/modules/org/arangodb/arango-database.js index 7dcae68e99..5ec69fbd9b 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/modules/org/arangodb/arango-database.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/modules/org/arangodb/arango-database.js @@ -315,7 +315,7 @@ ArangoDatabase.prototype._create = function (name, properties, type) { if (properties !== undefined) { [ "waitForSync", "journalSize", "isSystem", "isVolatile", "doCompact", "keyOptions", "shardKeys", "numberOfShards", - "distributeShardsLike" ].forEach(function(p) { + "distributeShardsLike", "indexBuckets" ].forEach(function(p) { if (properties.hasOwnProperty(p)) { body[p] = properties[p]; } diff --git a/js/client/modules/org/arangodb/arango-database.js b/js/client/modules/org/arangodb/arango-database.js index 632e23054a..8343edb512 100644 --- a/js/client/modules/org/arangodb/arango-database.js +++ b/js/client/modules/org/arangodb/arango-database.js @@ -314,7 +314,7 @@ ArangoDatabase.prototype._create = function (name, properties, type) { if (properties !== undefined) { [ "waitForSync", "journalSize", "isSystem", "isVolatile", "doCompact", "keyOptions", "shardKeys", "numberOfShards", - "distributeShardsLike" ].forEach(function(p) { + "distributeShardsLike", "indexBuckets" ].forEach(function(p) { if (properties.hasOwnProperty(p)) { body[p] = properties[p]; } diff --git a/js/server/modules/org/arangodb/cluster.js b/js/server/modules/org/arangodb/cluster.js index 9588b3d648..b897d53775 100644 --- a/js/server/modules/org/arangodb/cluster.js +++ b/js/server/modules/org/arangodb/cluster.js @@ -506,7 +506,8 @@ function createLocalCollections (plannedCollections) { // collection exists, now compare collection properties var properties = { }; - var cmp = [ "journalSize", "waitForSync", "doCompact" ]; + var cmp = [ "journalSize", "waitForSync", "doCompact", + "indexBuckets" ]; for (i = 0; i < cmp.length; ++i) { var p = cmp[i]; if (localCollections[shard][p] !== payload[p]) {