mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:arangodb/arangodb into devel
This commit is contained in:
commit
e307505753
|
@ -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);
|
||||
|
|
|
@ -226,6 +226,14 @@ namespace triagens {
|
|||
return triagens::basics::JsonHelper::getNumericValue<TRI_voc_size_t>(_json, "journalSize", 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the maximal journal size
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint32_t indexBuckets () const {
|
||||
return triagens::basics::JsonHelper::getNumericValue<uint32_t>(_json, "indexBuckets", 1);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the shard keys
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -2121,6 +2121,19 @@ static void JS_PropertiesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>&
|
|||
}
|
||||
TRI_V8_THROW_EXCEPTION_PARAMETER("volatile collections do not support the waitForSync option");
|
||||
}
|
||||
|
||||
if (po->Has(TRI_V8_ASCII_STRING("indexBuckets"))) {
|
||||
uint32_t tmp = static_cast<uint32_t>(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);
|
||||
|
@ -2232,8 +2245,8 @@ static void JS_PropertiesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>&
|
|||
}
|
||||
|
||||
if (po->Has(TRI_V8_ASCII_STRING("indexBuckets"))) {
|
||||
indexBuckets = TRI_ObjectToUInt64(
|
||||
po->Get(TRI_V8_ASCII_STRING("indexBuckets")), true);
|
||||
indexBuckets = static_cast<uint32_t>(TRI_ObjectToUInt64(
|
||||
po->Get(TRI_V8_ASCII_STRING("indexBuckets")), true));
|
||||
if (indexBuckets == 0 || indexBuckets > 1024) {
|
||||
ReleaseCollection(collection);
|
||||
TRI_V8_THROW_EXCEPTION_PARAMETER("indexBuckets must be a two-power between 1 and 1024");
|
||||
|
|
|
@ -1707,7 +1707,7 @@ static void CreateVocBase (const v8::FunctionCallbackInfo<v8::Value>& args,
|
|||
|
||||
if (p->Has(TRI_V8_ASCII_STRING("indexBuckets"))) {
|
||||
parameters._indexBuckets
|
||||
= TRI_ObjectToUInt64(p->Get(TRI_V8_ASCII_STRING("indexBuckets")), true);
|
||||
= static_cast<uint32_t>(TRI_ObjectToUInt64(p->Get(TRI_V8_ASCII_STRING("indexBuckets")), true));
|
||||
if (parameters._indexBuckets < 1 ||
|
||||
parameters._indexBuckets > 1024) {
|
||||
TRI_FreeCollectionInfoOptions(¶meters);
|
||||
|
|
|
@ -939,7 +939,7 @@ static int SizeHintEdge (TRI_index_t* idx,
|
|||
|
||||
// set an initial size for the index for some new nodes to be created
|
||||
// without resizing
|
||||
int err = edgesIndex->resize(size + 2049);
|
||||
int err = edgesIndex->resize(static_cast<uint32_t>(size + 2049));
|
||||
|
||||
if (err != TRI_ERROR_NO_ERROR) {
|
||||
return err;
|
||||
|
@ -953,7 +953,7 @@ static int SizeHintEdge (TRI_index_t* idx,
|
|||
|
||||
// set an initial size for the index for some new nodes to be created
|
||||
// without resizing
|
||||
return edgesIndex->resize(size + 2049);
|
||||
return edgesIndex->resize(static_cast<uint32_t>(size + 2049));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
#include "VocBase/document-collection.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
|
||||
#define NUM_ACCESSORS 8
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -61,8 +63,6 @@ typedef struct voc_shaper_s {
|
|||
TRI_associative_synced_t _shapeDictionary;
|
||||
TRI_associative_synced_t _shapeIds;
|
||||
|
||||
TRI_associative_pointer_t _accessors;
|
||||
|
||||
std::atomic<TRI_shape_aid_t> _nextAid;
|
||||
std::atomic<TRI_shape_sid_t> _nextSid;
|
||||
|
||||
|
@ -71,7 +71,8 @@ typedef struct voc_shaper_s {
|
|||
triagens::basics::Mutex _shapeLock;
|
||||
triagens::basics::Mutex _attributeLock;
|
||||
|
||||
triagens::basics::ReadWriteLock _accessorLock[8];
|
||||
triagens::basics::ReadWriteLock _accessorLock[NUM_ACCESSORS];
|
||||
TRI_associative_pointer_t _accessors[NUM_ACCESSORS];
|
||||
}
|
||||
voc_shaper_t;
|
||||
|
||||
|
@ -542,24 +543,31 @@ static int InitStep1VocShaper (voc_shaper_t* shaper) {
|
|||
return res;
|
||||
}
|
||||
|
||||
res = TRI_InitAssociativePointer(&shaper->_accessors,
|
||||
TRI_UNKNOWN_MEM_ZONE,
|
||||
0,
|
||||
HashElementAccessor,
|
||||
0,
|
||||
EqualElementAccessor);
|
||||
for (size_t i = 0; i < NUM_ACCESSORS; ++i) {
|
||||
res = TRI_InitAssociativePointer(&shaper->_accessors[i],
|
||||
TRI_UNKNOWN_MEM_ZONE,
|
||||
0,
|
||||
HashElementAccessor,
|
||||
0,
|
||||
EqualElementAccessor);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_DestroyAssociativeSynced(&shaper->_shapeIds);
|
||||
TRI_DestroyAssociativeSynced(&shaper->_shapeDictionary);
|
||||
TRI_DestroyAssociativeSynced(&shaper->_attributeIds);
|
||||
TRI_DestroyAssociativeSynced(&shaper->_attributeNames);
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
for (size_t j = 0; j < i; ++j) {
|
||||
TRI_DestroyAssociativePointer(&shaper->_accessors[j]);
|
||||
}
|
||||
TRI_DestroyAssociativeSynced(&shaper->_shapeIds);
|
||||
TRI_DestroyAssociativeSynced(&shaper->_shapeDictionary);
|
||||
TRI_DestroyAssociativeSynced(&shaper->_attributeIds);
|
||||
TRI_DestroyAssociativeSynced(&shaper->_attributeNames);
|
||||
|
||||
return res;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_DestroyAssociativePointer(&shaper->_accessors);
|
||||
for (size_t i = 0; i < NUM_ACCESSORS; ++i) {
|
||||
TRI_DestroyAssociativePointer(&shaper->_accessors[i]);
|
||||
}
|
||||
TRI_DestroyAssociativeSynced(&shaper->_shapeIds);
|
||||
TRI_DestroyAssociativeSynced(&shaper->_shapeDictionary);
|
||||
TRI_DestroyAssociativeSynced(&shaper->_attributeIds);
|
||||
|
@ -638,14 +646,16 @@ void TRI_DestroyVocShaper (TRI_shaper_t* s) {
|
|||
TRI_DestroyAssociativeSynced(&shaper->_shapeDictionary);
|
||||
TRI_DestroyAssociativeSynced(&shaper->_shapeIds);
|
||||
|
||||
for (size_t i = 0; i < shaper->_accessors._nrAlloc; ++i) {
|
||||
TRI_shape_access_t* accessor = (TRI_shape_access_t*) shaper->_accessors._table[i];
|
||||
for (size_t i = 0; i < NUM_ACCESSORS; ++i) {
|
||||
for (size_t j = 0; j < shaper->_accessors[i]._nrAlloc; ++j) {
|
||||
auto accessor = static_cast<TRI_shape_access_t*>(shaper->_accessors[i]._table[j]);
|
||||
|
||||
if (accessor != nullptr) {
|
||||
TRI_FreeShapeAccessor(accessor);
|
||||
if (accessor != nullptr) {
|
||||
TRI_FreeShapeAccessor(accessor);
|
||||
}
|
||||
}
|
||||
TRI_DestroyAssociativePointer(&shaper->_accessors[i]);
|
||||
}
|
||||
TRI_DestroyAssociativePointer(&shaper->_accessors);
|
||||
TRI_DestroyShaper(s);
|
||||
}
|
||||
|
||||
|
@ -901,14 +911,15 @@ TRI_shape_access_t const* TRI_FindAccessorVocShaper (TRI_shaper_t* s,
|
|||
TRI_shape_pid_t pid) {
|
||||
TRI_shape_access_t search = { sid, pid, 0, nullptr };
|
||||
|
||||
size_t const lockId = static_cast<size_t>(fasthash64(&sid, sizeof(TRI_shape_sid_t), fasthash64(&pid, sizeof(TRI_shape_pid_t), 0x87654321)) % 8);
|
||||
size_t const i = static_cast<size_t>(fasthash64(&sid, sizeof(TRI_shape_sid_t), fasthash64(&pid, sizeof(TRI_shape_pid_t), 0x87654321)) % NUM_ACCESSORS);
|
||||
|
||||
voc_shaper_t* shaper = (voc_shaper_t*) s;
|
||||
|
||||
TRI_shape_access_t const* found;
|
||||
TRI_shape_access_t const* found = nullptr;
|
||||
{
|
||||
READ_LOCKER(shaper->_accessorLock[lockId]);
|
||||
READ_LOCKER(shaper->_accessorLock[i]);
|
||||
|
||||
found = static_cast<TRI_shape_access_t const*>(TRI_LookupByElementAssociativePointer(&shaper->_accessors, &search));
|
||||
found = static_cast<TRI_shape_access_t const*>(TRI_LookupByElementAssociativePointer(&shaper->_accessors[i], &search));
|
||||
|
||||
if (found != nullptr) {
|
||||
return found;
|
||||
|
@ -924,11 +935,11 @@ TRI_shape_access_t const* TRI_FindAccessorVocShaper (TRI_shaper_t* s,
|
|||
}
|
||||
|
||||
// acquire the write-lock and try to insert our own accessor
|
||||
|
||||
{
|
||||
WRITE_LOCKER(shaper->_accessorLock[i]);
|
||||
|
||||
WRITE_LOCKER(shaper->_accessorLock[lockId]);
|
||||
|
||||
found = static_cast<TRI_shape_access_t const*>(TRI_InsertElementAssociativePointer(&shaper->_accessors, const_cast<void*>(static_cast<void const*>(accessor)), false));
|
||||
found = static_cast<TRI_shape_access_t const*>(TRI_InsertElementAssociativePointer(&shaper->_accessors[i], const_cast<void*>(static_cast<void const*>(accessor)), false));
|
||||
}
|
||||
|
||||
if (found != nullptr) {
|
||||
|
@ -936,6 +947,7 @@ TRI_shape_access_t const* TRI_FindAccessorVocShaper (TRI_shaper_t* s,
|
|||
// but before we acquired the write-lock
|
||||
// this is ok, and we can return the concurrently built accessor now
|
||||
TRI_FreeShapeAccessor(accessor);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
|
|
@ -334,7 +334,8 @@ ArangoCollection.prototype.properties = function (properties) {
|
|||
"waitForSync": true,
|
||||
"shardKeys": false,
|
||||
"numberOfShards": false,
|
||||
"keyOptions": false
|
||||
"keyOptions": false,
|
||||
"indexBuckets": true
|
||||
};
|
||||
var a;
|
||||
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ function percentChange2 (current, prev, section, src1, src2) {
|
|||
var p = prev[section][src1] - prev[section][src2];
|
||||
|
||||
if (p !== 0) {
|
||||
return (current[section][src1] -current[section][src2] - p) / p;
|
||||
return (current[section][src1] - current[section][src2] - p) / p;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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]) {
|
||||
|
|
|
@ -202,7 +202,11 @@ namespace triagens {
|
|||
_buckets.emplace_back();
|
||||
Bucket& b = _buckets.back();
|
||||
b._nrAlloc = initialSize;
|
||||
b._table = nullptr;
|
||||
|
||||
// may fail...
|
||||
b._table = new Entry[b._nrAlloc];
|
||||
|
||||
for (IndexType i = 0; i < b._nrAlloc; i++) {
|
||||
invalidateEntry(b, i);
|
||||
}
|
||||
|
@ -210,6 +214,7 @@ namespace triagens {
|
|||
}
|
||||
catch (...) {
|
||||
for (auto& b : _buckets) {
|
||||
delete [] b._table;
|
||||
b._table = nullptr;
|
||||
b._nrAlloc = 0;
|
||||
}
|
||||
|
@ -241,11 +246,11 @@ namespace triagens {
|
|||
|
||||
size_t memoryUsage () const {
|
||||
size_t res = 0;
|
||||
size_t count = 0;
|
||||
// size_t count = 0;
|
||||
for (auto& b : _buckets) {
|
||||
res += static_cast<size_t> (b._nrAlloc) * sizeof(Entry);
|
||||
std::cout << "Bucket: " << count++ << " _nrAlloc=" << b._nrAlloc
|
||||
<< " _nrUsed=" << b._nrUsed << std::endl;
|
||||
// std::cout << "Bucket: " << count++ << " _nrAlloc=" << b._nrAlloc
|
||||
// << " _nrUsed=" << b._nrUsed << std::endl;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -764,14 +769,14 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int resize (IndexType size) throw() {
|
||||
size /= _buckets.size();
|
||||
size /= static_cast<IndexType>(_buckets.size());
|
||||
for (auto& b : _buckets) {
|
||||
if (2 * (2*size+1) < 3 * b._nrUsed) {
|
||||
if (2 * (2 * size + 1) < 3 * b._nrUsed) {
|
||||
return TRI_ERROR_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
try {
|
||||
resizeInternal(b, 2*size+1);
|
||||
resizeInternal(b, 2 * size + 1);
|
||||
}
|
||||
catch (...) {
|
||||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -842,7 +847,7 @@ namespace triagens {
|
|||
Entry* oldTable = b._table;
|
||||
IndexType oldAlloc = b._nrAlloc;
|
||||
|
||||
b._nrAlloc = TRI_NearPrime(size);
|
||||
b._nrAlloc = static_cast<IndexType>(TRI_NearPrime(size));
|
||||
try {
|
||||
b._table = new Entry[b._nrAlloc];
|
||||
IndexType i;
|
||||
|
@ -1145,7 +1150,7 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline IndexType hashToIndex (uint64_t const h) const {
|
||||
return sizeof(IndexType) == 8 ? h : TRI_64to32(h);
|
||||
return static_cast<IndexType>(sizeof(IndexType) == 8 ? h : TRI_64to32(h));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -761,8 +761,7 @@ TRI_process_info_t TRI_ProcessInfo (TRI_pid_t pid) {
|
|||
if (n == 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
sscanf(str, "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %llu %lu %ld",
|
||||
sscanf(str, "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %llu %lu %ld",
|
||||
&st.pid, (char*) &st.comm, &st.state, &st.ppid, &st.pgrp, &st.session, &st.tty_nr, &st.tpgid,
|
||||
&st.flags, &st.minflt, &st.cminflt, &st.majflt, &st.cmajflt, &st.utime, &st.stime,
|
||||
&st.cutime, &st.cstime, &st.priority, &st.nice, &st.num_threads, &st.itrealvalue,
|
||||
|
|
Loading…
Reference in New Issue