1
0
Fork 0

Merge branch 'devel' of https://github.com/arangodb/arangodb into devel

This commit is contained in:
Kaveh Vahedipour 2017-01-20 18:58:21 +01:00
commit db6b089c5f
8 changed files with 25 additions and 28 deletions

View File

@ -132,12 +132,14 @@ class Buffer {
inline ValueLength size() const { return _pos; }
inline ValueLength length() const { return _pos; }
inline ValueLength byteSize() const { return _pos; }
inline ValueLength capacity() const noexcept { return _alloc; }
std::string toString() const {
return std::string(reinterpret_cast<char const*>(_buffer), _pos);
}
void reset() {
void reset() noexcept {
_pos = 0;
initWithNone();
}
@ -243,15 +245,16 @@ class Buffer {
// reserve and zero fill
void prealloc(ValueLength len) {
reserve(len);
// memset(_buffer + _pos, 0, len);
#ifdef VELOCYPACK_DEBUG
// poison memory
memset(_buffer + _pos, 0xa5, len);
#endif
_pos += len;
}
private:
// initialize Buffer with a None value
inline void initWithNone() { _buffer[0] = '\x00'; }
inline ValueLength capacity() const { return _alloc; }
inline void initWithNone() noexcept { _buffer[0] = '\x00'; }
T* _buffer;
ValueLength _alloc;

View File

@ -98,7 +98,7 @@ class Builder {
void reserveSpace(ValueLength len) {
// Reserves len bytes at pos of the current state (top of stack)
// or throws an exception
if (_pos + len <= _size) {
if (_pos + len < _size) {
return; // All OK, we can just increase tos->pos by len
}
@ -496,8 +496,8 @@ class Builder {
void addDouble(double v) {
uint64_t dv;
memcpy(&dv, &v, sizeof(double));
ValueLength vSize = sizeof(double);
memcpy(&dv, &v, vSize);
reserveSpace(1 + vSize);
_start[_pos++] = 0x1b;
for (uint64_t x = dv; vSize > 0; vSize--) {
@ -528,11 +528,10 @@ class Builder {
}
void addUTCDate(int64_t v) {
uint8_t const vSize = sizeof(int64_t); // is always 8
uint64_t x = toUInt64(v);
constexpr uint8_t vSize = sizeof(int64_t); // is always 8
reserveSpace(1 + vSize);
_start[_pos++] = 0x1c;
appendLength<8>(x);
appendLength<vSize>(toUInt64(v));
}
uint8_t* addString(uint64_t strLen) {

View File

@ -41,6 +41,9 @@
#include "velocypack/Sink.h"
#include "velocypack/Slice.h"
#include "velocypack/SliceContainer.h"
#include "velocypack/StringRef.h"
#include "velocypack/Utf8Helper.h"
#include "velocypack/Validator.h"
#include "velocypack/Value.h"
#include "velocypack/ValueType.h"
#include "velocypack/Version.h"

View File

@ -360,7 +360,8 @@ Builder& Builder::close() {
std::vector<ValueLength>& index = _index[_stack.size() - 1];
if (index.empty()) {
return closeEmptyArrayOrObject(tos, isArray);
closeEmptyArrayOrObject(tos, isArray);
return *this;
}
// From now on index.size() > 0
@ -377,7 +378,8 @@ Builder& Builder::close() {
}
if (isArray) {
return closeArray(tos, index);
closeArray(tos, index);
return *this;
}
// fix head byte in case a compact Array / Object was originally requested
@ -569,7 +571,7 @@ uint8_t* Builder::set(Value const& item) {
reserveSpace(1 + sizeof(double));
_start[_pos++] = 0x1b;
memcpy(&x, &v, sizeof(double));
appendLength<8>(x);
appendLength<sizeof(double)>(x);
break;
}
case ValueType::External: {

View File

@ -1336,9 +1336,10 @@ function startInstanceCluster (instanceInfo, protocol, options,
};
options.agencyWaitForSync = false;
let usedPorts = [];
options.usedPorts = usedPorts;
startInstanceAgency(instanceInfo, protocol, options, ...makeArgs('agency', 'agency', {}));
let usedPorts = [];
let agencyEndpoint = instanceInfo.endpoint;
let i;
for (i = 0; i < options.dbServers; i++) {
@ -1474,7 +1475,7 @@ function startInstanceAgency (instanceInfo, protocol, options, addArgs, rootDir)
}
const wfs = options.agencyWaitForSync;
let usedPorts = [];
let usedPorts = options.usedPorts || [];
for (let i = 0; i < N; i++) {
let instanceArgs = _.clone(addArgs);
instanceArgs['log.file'] = fs.join(rootDir, 'log' + String(i));

View File

@ -49,7 +49,6 @@ function runSetup () {
if (db._collection('UnitTestsRecovery').status() === ArangoCollection.STATUS_UNLOADED) {
break;
}
internal.print(db._collection('UnitTestsRecovery').status());
internal.wait(0.5, true);
}

View File

@ -64,15 +64,6 @@ function recoverySuite () {
testIndexesAfterFlush: function () {
var c = db._collection('UnitTestsRecovery'), idx;
// debugging information - to be removed
var fs = require("fs");
var print = require("internal").print;
var f = fs.listTree(c.path());
print(f);
for (var i = 1; i < f.length; ++i) {
print(f[i], fs.readFileSync(fs.join(c.path(), "parameter.json")));
}
print(fs.readFileSync(fs.join(c.path(), "parameter.json")));
assertEqual(3, c.getIndexes().length);
idx = c.getIndexes()[0];

View File

@ -153,8 +153,7 @@ function ReplicationSuite() {
}
if (compareTicks(slaveState.state.lastAppliedContinuousTick, syncResult.lastLogTick) >= 0 ||
compareTicks(slaveState.state.lastProcessedContinuousTick, syncResult.lastLogTick) >= 0) { //||
// compareTicks(slaveState.state.lastAvailableContinuousTick, syncResult.lastLogTick) > 0) {
compareTicks(slaveState.state.lastProcessedContinuousTick, syncResult.lastLogTick) >= 0) {
break;
}
@ -162,7 +161,7 @@ function ReplicationSuite() {
console.log("waiting for slave to catch up");
printed = true;
}
internal.wait(5.0, false);
internal.wait(1.0, false);
}
db._flushCache();