mirror of https://gitee.com/bigwinds/arangodb
fixed jslint warnings
This commit is contained in:
parent
69a6e6449e
commit
72902b2e62
|
@ -37,11 +37,6 @@ var ShapedJson = INTERNAL.ShapedJson;
|
||||||
// --SECTION-- private variables
|
// --SECTION-- private variables
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief cache for compiled regexes
|
/// @brief cache for compiled regexes
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -65,19 +60,30 @@ var TYPEWEIGHT_STRING = 4;
|
||||||
var TYPEWEIGHT_LIST = 8;
|
var TYPEWEIGHT_LIST = 8;
|
||||||
var TYPEWEIGHT_DOCUMENT = 16;
|
var TYPEWEIGHT_DOCUMENT = 16;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- helper functions
|
// --SECTION-- helper functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @addtogroup Ahuacatl
|
/// @brief throw a runtime exception
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
function THROW (error, data) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var err = new ArangoError();
|
||||||
|
|
||||||
|
err.errorNum = error.code;
|
||||||
|
if (data) {
|
||||||
|
err.errorMessage = error.message.replace(/%s/, data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
err.errorMessage = error.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief return a database-specific function prefix
|
/// @brief return a database-specific function prefix
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -86,6 +92,72 @@ function DB_PREFIX () {
|
||||||
return INTERNAL.db._name();
|
return INTERNAL.db._name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief reset the regex cache
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
function resetRegexCache () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
RegexCache = { 'i' : { }, '' : { } };
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief reset the user functions and reload them from the database
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
function reloadUserFunctions () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var c;
|
||||||
|
|
||||||
|
c = INTERNAL.db._collection("_aqlfunctions");
|
||||||
|
|
||||||
|
if (c === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var foundError = false;
|
||||||
|
var prefix = DB_PREFIX();
|
||||||
|
|
||||||
|
UserFunctions[prefix] = { };
|
||||||
|
|
||||||
|
c.toArray().forEach(function (f) {
|
||||||
|
var code = "(function() { var callback = " + f.code + "; return callback; })();";
|
||||||
|
var key = f._key.replace(/:{1,}/g, '::');
|
||||||
|
|
||||||
|
try {
|
||||||
|
var res = INTERNAL.executeScript(code, undefined, "(user function " + key + ")");
|
||||||
|
|
||||||
|
UserFunctions[prefix][key.toUpperCase()] = {
|
||||||
|
name: key,
|
||||||
|
func: res,
|
||||||
|
isDeterministic: f.isDeterministic || false
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
foundError = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (foundError) {
|
||||||
|
THROW(INTERNAL.errors.ERROR_QUERY_FUNCTION_INVALID_CODE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief reset the query engine
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
function resetEngine () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
resetRegexCache();
|
||||||
|
reloadUserFunctions();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief normalise a function name
|
/// @brief normalise a function name
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -126,26 +198,6 @@ function FILTER (list, examples) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief throw a runtime exception
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
function THROW (error, data) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var err = new ArangoError();
|
|
||||||
|
|
||||||
err.errorNum = error.code;
|
|
||||||
if (data) {
|
|
||||||
err.errorMessage = error.message.replace(/%s/, data);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
err.errorMessage = error.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief find a fulltext index for a certain attribute & collection
|
/// @brief find a fulltext index for a certain attribute & collection
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1035,19 +1087,10 @@ function COLLECTIONS () {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- logical operations
|
// --SECTION-- logical operations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief execute ternary operator
|
/// @brief execute ternary operator
|
||||||
///
|
///
|
||||||
|
@ -1202,19 +1245,10 @@ function LOGICAL_NOT (lhs) {
|
||||||
return ! lhs;
|
return ! lhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- comparison operations
|
// --SECTION-- comparison operations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief perform equality check
|
/// @brief perform equality check
|
||||||
///
|
///
|
||||||
|
@ -1666,19 +1700,10 @@ function RELATIONAL_IN (lhs, rhs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- arithmetic operations
|
// --SECTION-- arithmetic operations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief perform unary plus operation
|
/// @brief perform unary plus operation
|
||||||
///
|
///
|
||||||
|
@ -1839,19 +1864,10 @@ function ARITHMETIC_MODULUS (lhs, rhs) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- string functions
|
// --SECTION-- string functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief perform string concatenation
|
/// @brief perform string concatenation
|
||||||
///
|
///
|
||||||
|
@ -2120,19 +2136,10 @@ function STRING_TRIM (value, type) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- typecast functions
|
// --SECTION-- typecast functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief cast to a bool
|
/// @brief cast to a bool
|
||||||
///
|
///
|
||||||
|
@ -2228,19 +2235,10 @@ function CAST_LIST (value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- typecheck functions
|
// --SECTION-- typecheck functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief test if value is of type null
|
/// @brief test if value is of type null
|
||||||
///
|
///
|
||||||
|
@ -2313,19 +2311,10 @@ function IS_DOCUMENT (value) {
|
||||||
return (TYPEWEIGHT(value) === TYPEWEIGHT_DOCUMENT);
|
return (TYPEWEIGHT(value) === TYPEWEIGHT_DOCUMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- numeric functions
|
// --SECTION-- numeric functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief integer closest to value, not greater than value
|
/// @brief integer closest to value, not greater than value
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -2406,19 +2395,10 @@ function NUMBER_SQRT (value) {
|
||||||
return NUMERIC_VALUE(Math.sqrt(value));
|
return NUMERIC_VALUE(Math.sqrt(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- high level query functions
|
// --SECTION-- high level query functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief sort the results
|
/// @brief sort the results
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -2510,19 +2490,10 @@ function LIMIT (value, offset, count) {
|
||||||
return value.slice(offset, offset + count);
|
return value.slice(offset, offset + count);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- list processing functions
|
// --SECTION-- list processing functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief get the length of a list, document or string
|
/// @brief get the length of a list, document or string
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -3082,19 +3053,10 @@ function STDDEV_POPULATION (values) {
|
||||||
return NUMERIC_VALUE(Math.sqrt(result.value / result.n));
|
return NUMERIC_VALUE(Math.sqrt(result.value / result.n));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- geo functions
|
// --SECTION-- geo functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief return at most <limit> documents near a certain point
|
/// @brief return at most <limit> documents near a certain point
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -3156,19 +3118,10 @@ function GEO_WITHIN (collection, latitude, longitude, radius, distanceAttribute)
|
||||||
return documents;
|
return documents;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- fulltext functions
|
// --SECTION-- fulltext functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief return documents that match a fulltext query
|
/// @brief return documents that match a fulltext query
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -3185,19 +3138,10 @@ function FULLTEXT (collection, attribute, query) {
|
||||||
return result.documents;
|
return result.documents;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- misc functions
|
// --SECTION-- misc functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief return the first alternative that's not null until there are no more
|
/// @brief return the first alternative that's not null until there are no more
|
||||||
/// alternatives. if neither of the alternatives is a value other than null,
|
/// alternatives. if neither of the alternatives is a value other than null,
|
||||||
|
@ -3538,19 +3482,10 @@ function FAIL (message) {
|
||||||
THROW(INTERNAL.errors.ERROR_QUERY_FAIL_CALLED, "");
|
THROW(INTERNAL.errors.ERROR_QUERY_FAIL_CALLED, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- graph functions
|
// --SECTION-- graph functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief find all paths through a graph, INTERNAL part called recursively
|
/// @brief find all paths through a graph, INTERNAL part called recursively
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -3967,97 +3902,10 @@ function GRAPH_NEIGHBORS (vertexCollection,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// --SECTION-- setup / reset functions
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief reset the regex cache
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
function resetRegexCache () {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
RegexCache = { 'i' : { }, '' : { } };
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief reset the user functions and reload them from the database
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
function reloadUserFunctions () {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var c;
|
|
||||||
|
|
||||||
c = INTERNAL.db._collection("_aqlfunctions");
|
|
||||||
|
|
||||||
if (c === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var foundError = false;
|
|
||||||
var prefix = DB_PREFIX();
|
|
||||||
|
|
||||||
UserFunctions[prefix] = { };
|
|
||||||
|
|
||||||
c.toArray().forEach(function (f) {
|
|
||||||
var code = "(function() { var callback = " + f.code + "; return callback; })();";
|
|
||||||
var key = f._key.replace(/:{1,}/g, '::');
|
|
||||||
|
|
||||||
try {
|
|
||||||
var res = INTERNAL.executeScript(code, undefined, "(user function " + key + ")");
|
|
||||||
|
|
||||||
UserFunctions[prefix][key.toUpperCase()] = {
|
|
||||||
name: key,
|
|
||||||
func: res,
|
|
||||||
isDeterministic: f.isDeterministic || false
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
foundError = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (foundError) {
|
|
||||||
THROW(INTERNAL.errors.ERROR_QUERY_FUNCTION_INVALID_CODE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief reset the query engine
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
function resetEngine () {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
resetRegexCache();
|
|
||||||
reloadUserFunctions();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- MODULE EXPORTS
|
// --SECTION-- MODULE EXPORTS
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup Ahuacatl
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
exports.FCALL = FCALL;
|
exports.FCALL = FCALL;
|
||||||
exports.FCALL_USER = FCALL_USER;
|
exports.FCALL_USER = FCALL_USER;
|
||||||
exports.KEYS = KEYS;
|
exports.KEYS = KEYS;
|
||||||
|
@ -4177,11 +4025,6 @@ exports.reload = reloadUserFunctions;
|
||||||
// initialise the query engine
|
// initialise the query engine
|
||||||
resetEngine();
|
resetEngine();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- END-OF-FILE
|
// --SECTION-- END-OF-FILE
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue