1
0
Fork 0

Merge branch 'devel' of ssh://github.com/triAGENS/ArangoDB into devel

This commit is contained in:
James 2014-10-10 08:31:28 +01:00
commit 9334547583
10 changed files with 699 additions and 616 deletions

View File

@ -1,6 +1,23 @@
v2.3.0 (XXXX-XX-XX) v2.3.0 (XXXX-XX-XX)
------------------- -------------------
* command-line options that require a boolean value now validate the
value given on the command-line
This prevents issues if no value is specified for an option that
requires a boolean value. For example, the following command-line would
have caused trouble in 2.2, because `--server.endpoint` would have been
used as the value for the `--server.disable-authentication` options
(which requires a boolean value):
arangod --server.disable-authentication --server.endpoint tcp://127.0.0.1:8529 data
In 2.3, running this command will fail with an error and requires to
be modified to:
arangod --server.disable-authentication true --server.endpoint tcp://127.0.0.1:8529 data
* improved performance of CSV import in arangoimp * improved performance of CSV import in arangoimp
* fixed issue #1027: Stack traces are off-by-one * fixed issue #1027: Stack traces are off-by-one

View File

@ -637,8 +637,8 @@ class KeySpace {
return scope.Close(result); return scope.Close(result);
} }
v8::Handle<v8::Value> keyAt (std::string const& key, v8::Handle<v8::Value> keyGetAt (std::string const& key,
int64_t index) { int64_t index) {
v8::HandleScope scope; v8::HandleScope scope;
v8::Handle<v8::Value> result; v8::Handle<v8::Value> result;
@ -673,6 +673,55 @@ class KeySpace {
return scope.Close(result); return scope.Close(result);
} }
bool keySetAt (std::string const& key,
int64_t index,
v8::Handle<v8::Value> const& value) {
WRITE_LOCKER(_lock);
auto found = static_cast<KeySpaceElement*>(TRI_LookupByKeyAssociativePointer(&_hash, key.c_str()));
if (found == nullptr) {
// TODO: change error code
return TRI_ERROR_INTERNAL;
}
else {
if (! TRI_IsListJson(found->json)) {
// TODO: change error code
return TRI_ERROR_INTERNAL;
}
size_t const n = found->json->_value._objects._length;
if (index < 0) {
// TODO: change error code
return TRI_ERROR_INTERNAL;
}
auto json = TRI_ObjectToJson(value);
if (json == nullptr) {
return TRI_ERROR_OUT_OF_MEMORY;
}
if (index >= static_cast<int64_t>(n)) {
// insert new element
TRI_InsertVector(&found->json->_value._objects, json, static_cast<size_t>(index));
}
else {
// overwrite existing element
auto item = static_cast<TRI_json_t*>(TRI_AtVector(&found->json->_value._objects, static_cast<size_t>(index)));
if (item != nullptr) {
TRI_DestroyJson(TRI_UNKNOWN_MEM_ZONE, item);
}
TRI_SetVector(&found->json->_value._objects, static_cast<size_t>(index), json);
}
// only free pointer to json, but not its internal structures
TRI_Free(TRI_UNKNOWN_MEM_ZONE, json);
}
return TRI_ERROR_NO_ERROR;
}
char const* keyType (std::string const& key) { char const* keyType (std::string const& key) {
READ_LOCKER(_lock); READ_LOCKER(_lock);
@ -886,8 +935,8 @@ static v8::Handle<v8::Value> JS_KeyspaceDrop (v8::Arguments const& argv) {
TRI_V8_EXCEPTION(scope, TRI_ERROR_INTERNAL); TRI_V8_EXCEPTION(scope, TRI_ERROR_INTERNAL);
} }
h->data.erase(it);
delete (*it).second; delete (*it).second;
h->data.erase(it);
} }
return scope.Close(v8::True()); return scope.Close(v8::True());
@ -1547,11 +1596,11 @@ static v8::Handle<v8::Value> JS_KeyTransfer (v8::Arguments const& argv) {
/// @brief get an element at a specific list position /// @brief get an element at a specific list position
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static v8::Handle<v8::Value> JS_KeyAt (v8::Arguments const& argv) { static v8::Handle<v8::Value> JS_KeyGetAt (v8::Arguments const& argv) {
v8::HandleScope scope; v8::HandleScope scope;
if (argv.Length() < 3 || ! argv[0]->IsString() || ! argv[1]->IsString()) { if (argv.Length() < 3 || ! argv[0]->IsString() || ! argv[1]->IsString()) {
TRI_V8_EXCEPTION_USAGE(scope, "KEY_AT(<name>, <key>, <index>)"); TRI_V8_EXCEPTION_USAGE(scope, "KEY_GET_AT(<name>, <key>, <index>)");
} }
TRI_vocbase_t* vocbase = GetContextVocBase(); TRI_vocbase_t* vocbase = GetContextVocBase();
@ -1574,7 +1623,46 @@ static v8::Handle<v8::Value> JS_KeyAt (v8::Arguments const& argv) {
TRI_V8_EXCEPTION(scope, TRI_ERROR_INTERNAL); TRI_V8_EXCEPTION(scope, TRI_ERROR_INTERNAL);
} }
return scope.Close(hash->keyAt(key, offset)); return scope.Close(hash->keyGetAt(key, offset));
}
////////////////////////////////////////////////////////////////////////////////
/// @brief set an element at a specific list position
////////////////////////////////////////////////////////////////////////////////
static v8::Handle<v8::Value> JS_KeySetAt (v8::Arguments const& argv) {
v8::HandleScope scope;
if (argv.Length() < 4 || ! argv[0]->IsString() || ! argv[1]->IsString()) {
TRI_V8_EXCEPTION_USAGE(scope, "KEY_SET_AT(<name>, <key>, <index>, <value>)");
}
TRI_vocbase_t* vocbase = GetContextVocBase();
if (vocbase == nullptr) {
TRI_V8_EXCEPTION_INTERNAL(scope, "cannot extract vocbase");
}
std::string const&& name = TRI_ObjectToString(argv[0]);
std::string const&& key = TRI_ObjectToString(argv[1]);
int64_t offset = TRI_ObjectToInt64(argv[2]);
auto h = &(static_cast<UserStructures*>(vocbase->_userStructures)->hashes);
READ_LOCKER(h->lock);
auto hash = GetKeySpace(vocbase, name);
if (hash == nullptr) {
// TODO: change error code
TRI_V8_EXCEPTION(scope, TRI_ERROR_INTERNAL);
}
int res = hash->keySetAt(key, offset, argv[3]);
if (res != TRI_ERROR_NO_ERROR) {
TRI_V8_EXCEPTION(scope, res);
}
return scope.Close(v8::True());
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -1679,7 +1767,13 @@ void TRI_CreateUserStructuresVocBase (TRI_vocbase_t* vocbase) {
void TRI_FreeUserStructuresVocBase (TRI_vocbase_t* vocbase) { void TRI_FreeUserStructuresVocBase (TRI_vocbase_t* vocbase) {
if (vocbase->_userStructures != nullptr) { if (vocbase->_userStructures != nullptr) {
delete static_cast<UserStructures*>(vocbase->_userStructures); auto us = static_cast<UserStructures*>(vocbase->_userStructures);
for (auto& hash : us->hashes.data) {
if (hash.second != nullptr) {
delete hash.second;
}
}
delete us;
} }
} }
@ -1716,7 +1810,8 @@ void TRI_InitV8UserStructures (v8::Handle<v8::Context> context) {
TRI_AddGlobalFunctionVocbase(context, "KEY_PUSH", JS_KeyPush); TRI_AddGlobalFunctionVocbase(context, "KEY_PUSH", JS_KeyPush);
TRI_AddGlobalFunctionVocbase(context, "KEY_POP", JS_KeyPop); TRI_AddGlobalFunctionVocbase(context, "KEY_POP", JS_KeyPop);
TRI_AddGlobalFunctionVocbase(context, "KEY_TRANSFER", JS_KeyTransfer); TRI_AddGlobalFunctionVocbase(context, "KEY_TRANSFER", JS_KeyTransfer);
TRI_AddGlobalFunctionVocbase(context, "KEY_AT", JS_KeyAt); TRI_AddGlobalFunctionVocbase(context, "KEY_GET_AT", JS_KeyGetAt);
TRI_AddGlobalFunctionVocbase(context, "KEY_SET_AT", JS_KeySetAt);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -415,8 +415,8 @@ namespace triagens {
double pct = 100.0 * ((double) totalRead / (double) totalLength); double pct = 100.0 * ((double) totalRead / (double) totalLength);
if (pct >= nextProgress && totalLength >= 1024) { if (pct >= nextProgress && totalLength >= 1024) {
LOG_INFO("processed %lld bytes (%0.2f%%) of input file", (long long) totalRead, pct); LOG_INFO("processed %lld bytes (%0.1f%%) of input file", (long long) totalRead, nextProgress);
nextProgress = pct + ProgressStep; nextProgress = (double) ((int) (pct + ProgressStep));
} }
} }

View File

@ -87,15 +87,15 @@ JAVASCRIPT_JSLINT = \
jslint: jslint:
@RESULT=0; \ @RESULT=0; \
for file in $(JAVASCRIPT_JSLINT); do \ FILELIST=""; \
@builddir@/bin/arangosh \ for file in $(JAVASCRIPT_JSLINT); do FILELIST="$$FILELIST --jslint $$file"; done; \
-c none \ @builddir@/bin/arangosh \
--log.level error \ -c none \
--server.password "" \ --log.level error \
--javascript.startup-directory @srcdir@/js \ --server.password "" \
--jslint $$file; \ --javascript.startup-directory @srcdir@/js \
if [ "$$?x" != "0x" ]; then RESULT=1; fi; \ $$FILELIST; \
done; \ if [ "$$?x" != "0x" ]; then RESULT=1; fi; \
exit $$RESULT exit $$RESULT
jshint: jslint jshint: jslint

View File

@ -400,71 +400,9 @@ controller.get("/query/result/download/:query", function(req, res) {
var query = req.params("query"), var query = req.params("query"),
parsedQuery; parsedQuery;
var _utf8_decode = function (utftext) { var internal = require("internal");
var string = ""; query = internal.base64Decode(query);
var i = 0; internal.print(query);
var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
var decodeFunction = function (input) {
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = keyStr.indexOf(input.charAt(i++));
enc2 = keyStr.indexOf(input.charAt(i++));
enc3 = keyStr.indexOf(input.charAt(i++));
enc4 = keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = _utf8_decode(output);
return output;
};
query = decodeFunction(query);
try { try {
parsedQuery = JSON.parse(query); parsedQuery = JSON.parse(query);
} }

View File

@ -162,7 +162,20 @@
header: "Requests", header: "Requests",
labels: ["datetime", "GET", "PUT", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "OTHER"], labels: ["datetime", "GET", "PUT", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "OTHER"],
stackedGraph: true, stackedGraph: true,
div: "requestsChart" div: "requestsChart",
axes: {
y: {
valueFormatter: function (y) {
return parseFloat(y.toPrecision(3));
},
axisLabelFormatter: function (y) {
if (y === 0) {
return 0;
}
return parseFloat(y.toPrecision(3));
}
}
}
} }
}, },

View File

@ -167,6 +167,10 @@ $iconsize: 50px;
height: 0; height: 0;
padding-left: 4px; padding-left: 4px;
padding-right: 9px; padding-right: 9px;
&.loading {
border-bottom-color: $c-unloaded;
}
&.loaded { &.loaded {
border-bottom-color: $c-positive; border-bottom-color: $c-positive;

File diff suppressed because it is too large Load Diff

View File

@ -83,8 +83,8 @@ function RunCommandLineTests (options) {
var testResult = RunTest(file, options); var testResult = RunTest(file, options);
result = result && testResult && testResult.passed; result = result && testResult && testResult.passed;
if (testResult && (! testResult.passed && testResult.errors)) { if (testResult && (! testResult.passed && testResult.errors)) {
for (var i = 0; i < testResult.errors.length; ++i) { for (var j = 0; j < testResult.errors.length; ++j) {
var err = testResult.errors[i]; var err = testResult.errors[j];
if (! err) { if (! err) {
continue; continue;
} }
@ -105,7 +105,6 @@ function RunCommandLineTests (options) {
} }
} }
internal.setUnitTestsResult(result); internal.setUnitTestsResult(result);
} }

View File

@ -983,7 +983,7 @@ TRI_external_status_t TRI_CheckExternalProcess (TRI_external_id_t pid,
#ifndef _WIN32 #ifndef _WIN32
TRI_pid_t res; TRI_pid_t res;
int opts; int opts;
int loc; int loc = 0;
if (wait) { if (wait) {
opts = WUNTRACED; opts = WUNTRACED;
@ -995,21 +995,33 @@ TRI_external_status_t TRI_CheckExternalProcess (TRI_external_id_t pid,
if (res == 0) { if (res == 0) {
external->_exitStatus = 0; external->_exitStatus = 0;
} }
else if (WIFEXITED(loc)) { else if (res == -1) {
external->_status = TRI_EXT_TERMINATED; LOG_WARNING("waitpid returned error for pid %d: %s",
external->_exitStatus = WEXITSTATUS(loc); (int) external->_pid,
TRI_errno_string(errno));
} }
else if (WIFSIGNALED(loc)) { else if (static_cast<TRI_pid_t>(external->_pid) == static_cast<TRI_pid_t>(res)) {
external->_status = TRI_EXT_ABORTED; if (WIFEXITED(loc)) {
external->_exitStatus = WTERMSIG(loc); external->_status = TRI_EXT_TERMINATED;
} external->_exitStatus = WEXITSTATUS(loc);
else if (WIFSTOPPED(loc)) { }
external->_status = TRI_EXT_STOPPED; else if (WIFSIGNALED(loc)) {
external->_exitStatus = 0; external->_status = TRI_EXT_ABORTED;
external->_exitStatus = WTERMSIG(loc);
}
else if (WIFSTOPPED(loc)) {
external->_status = TRI_EXT_STOPPED;
external->_exitStatus = 0;
}
else {
external->_status = TRI_EXT_ABORTED;
external->_exitStatus = 0;
}
} }
else { else {
external->_status = TRI_EXT_ABORTED; LOG_WARNING("unexpected waitpid result for pid %d: %d",
external->_exitStatus = 0; (int) external->_pid,
(int) res);
} }
#else #else
if (wait) { if (wait) {
@ -1021,7 +1033,7 @@ TRI_external_status_t TRI_CheckExternalProcess (TRI_external_id_t pid,
} }
} }
DWORD exitCode = STILL_ACTIVE; DWORD exitCode = STILL_ACTIVE;
if (!GetExitCodeProcess(external->_process , &exitCode)) { if (! GetExitCodeProcess(external->_process , &exitCode)) {
LOG_WARNING("exit status could not be determined for PID '%ud'", LOG_WARNING("exit status could not be determined for PID '%ud'",
external->_pid); external->_pid);
} }
@ -1036,6 +1048,11 @@ TRI_external_status_t TRI_CheckExternalProcess (TRI_external_id_t pid,
} }
#endif #endif
} }
else {
LOG_WARNING("unexpected process status %d: %d",
(int) external->_status,
(int) external->_exitStatus);
}
status._status = external->_status; status._status = external->_status;
status._exitStatus = external->_exitStatus; status._exitStatus = external->_exitStatus;