From 8e229ec2b235ca95ebd4be4cee49b30c03034d61 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Thu, 7 Aug 2014 11:44:22 +0200 Subject: [PATCH 1/4] stringification of function parameters --- arangod/Aql/ExecutionNode.h | 3 +- arangod/Aql/Function.cpp | 180 +++++++++++++++++++++++++++++++++++ arangod/Aql/Function.h | 95 ++++++------------ arangod/Aql/V8Executor.cpp | 70 +++++++++----- arangod/Aql/V8Executor.h | 6 ++ arangod/Aql/V8Expression.cpp | 113 ++++++++++++++++++++++ arangod/Aql/V8Expression.h | 76 +++++---------- arangod/CMakeLists.txt | 2 + arangod/Makefile.files | 2 + 9 files changed, 404 insertions(+), 143 deletions(-) create mode 100644 arangod/Aql/Function.cpp create mode 100644 arangod/Aql/V8Expression.cpp diff --git a/arangod/Aql/ExecutionNode.h b/arangod/Aql/ExecutionNode.h index b36fe7a4e9..b9da67a3ec 100644 --- a/arangod/Aql/ExecutionNode.h +++ b/arangod/Aql/ExecutionNode.h @@ -1025,6 +1025,7 @@ namespace triagens { AggregateNode (std::vector> aggregateVariables, Variable const* outVariable) : ExecutionNode(), _aggregateVariables(aggregateVariables), _outVariable(outVariable) { + // outVariable can be a nullptr } //////////////////////////////////////////////////////////////////////////////// @@ -1068,7 +1069,7 @@ namespace triagens { private: //////////////////////////////////////////////////////////////////////////////// -/// @brief input/output variables for the aggregation (out = in) +/// @brief input/output variables for the aggregation (out, in) //////////////////////////////////////////////////////////////////////////////// std::vector> _aggregateVariables; diff --git a/arangod/Aql/Function.cpp b/arangod/Aql/Function.cpp new file mode 100644 index 0000000000..97cd672ffc --- /dev/null +++ b/arangod/Aql/Function.cpp @@ -0,0 +1,180 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Aql, built-in AQL function +/// +/// @file +/// +/// DISCLAIMER +/// +/// Copyright 2014 ArangoDB GmbH, Cologne, Germany +/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// +/// Copyright holder is ArangoDB GmbH, Cologne, Germany +/// +/// @author Jan Steemann +/// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany +/// @author Copyright 2012-2013, triAGENS GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + +#include "Aql/Function.h" +#include "Utils/Exception.h" + +using namespace triagens::aql; + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors / destructors +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the function +//////////////////////////////////////////////////////////////////////////////// + +Function::Function (std::string const& name, + std::string const& arguments, + bool isDeterministic) + : name(name), + arguments(arguments), + isDeterministic(isDeterministic), + containsCollectionParameter(false) { + + initArguments(); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy the function +//////////////////////////////////////////////////////////////////////////////// + +Function::~Function () { +} + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief whether or not a positional argument needs to be converted from a +/// collection parameter to a collection name parameter +//////////////////////////////////////////////////////////////////////////////// + +bool Function::mustConvertArgument (size_t position) const { + bool foundArg = false; + size_t i = 0; + char const* p = arguments.c_str(); + + while (true) { + char const c = *p++; + + switch (c) { + case '\0': + return false; + + case '|': + case ',': + if (foundArg) { + if (++i > position) { + return false; + } + } + foundArg = false; + break; + + case 'h': + if (i == position) { + // found an argument to convert + return true; + } + foundArg = true; + break; + + default: + foundArg = true; + } + } + + return false; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief parse the argument list and set the minimum and maximum number of +/// arguments +//////////////////////////////////////////////////////////////////////////////// + +void Function::initArguments () { + minRequiredArguments = maxRequiredArguments = 0; + + // setup some parsing state + bool inOptional = false; + bool foundArg = false; + + char const* p = arguments.c_str(); + while (true) { + char const c = *p++; + + switch (c) { + case '\0': + // end of argument list + if (foundArg) { + if (! inOptional) { + ++minRequiredArguments; + } + ++maxRequiredArguments; + } + return; + + case '|': + // beginning of optional arguments + TRI_ASSERT(! inOptional); + if (foundArg) { + ++minRequiredArguments; + ++maxRequiredArguments; + } + inOptional = true; + foundArg = false; + break; + + case ',': + // next argument + TRI_ASSERT(foundArg); + + if (! inOptional) { + ++minRequiredArguments; + } + ++maxRequiredArguments; + foundArg = false; + break; + + case '+': + // repeated optional argument + TRI_ASSERT(inOptional); + maxRequiredArguments = MaxArguments; + return; + + default: + if (c == 'h') { + // note that we found a collection parameter + containsCollectionParameter = true; + } + foundArg = true; + } + } +} + +// ----------------------------------------------------------------------------- +// --SECTION-- END-OF-FILE +// ----------------------------------------------------------------------------- + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Aql/Function.h b/arangod/Aql/Function.h index 45fcf49b95..f5c9039798 100644 --- a/arangod/Aql/Function.h +++ b/arangod/Aql/Function.h @@ -1,5 +1,5 @@ //////////////////////////////////////////////////////////////////////////////// -/// @brief Aql, built-in function +/// @brief Aql, built-in AQL function /// /// @file /// @@ -43,19 +43,20 @@ namespace triagens { Function () = delete; - Function (std::string const& name, - std::string const& arguments, - bool isDeterministic) - : name(name), - arguments(arguments), - isDeterministic(isDeterministic) { +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the function +//////////////////////////////////////////////////////////////////////////////// - initArguments(); - } + Function (std::string const&, + std::string const&, + bool); - ~Function () { - } +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy the function +//////////////////////////////////////////////////////////////////////////////// + ~Function (); + // ----------------------------------------------------------------------------- // --SECTION-- public methods // ----------------------------------------------------------------------------- @@ -77,67 +78,20 @@ namespace triagens { return std::make_pair(minRequiredArguments, maxRequiredArguments); } +//////////////////////////////////////////////////////////////////////////////// +/// @brief whether or not a positional argument needs to be converted from a +/// collection parameter to a collection name parameter +//////////////////////////////////////////////////////////////////////////////// + + bool mustConvertArgument (size_t) const; + //////////////////////////////////////////////////////////////////////////////// /// @brief parse the argument list and set the minimum and maximum number of /// arguments //////////////////////////////////////////////////////////////////////////////// - void initArguments () { - minRequiredArguments = maxRequiredArguments = 0; - - // setup some parsing state - bool inOptional = false; - bool foundArg = false; - - char const* p = arguments.c_str(); - while (true) { - char const c = *p++; - - switch (c) { - case '\0': - // end of argument list - if (foundArg) { - if (! inOptional) { - ++minRequiredArguments; - } - ++maxRequiredArguments; - } - return; - - case '|': - // beginning of optional arguments - TRI_ASSERT(! inOptional); - if (foundArg) { - ++minRequiredArguments; - ++maxRequiredArguments; - } - inOptional = true; - foundArg = false; - break; - - case ',': - // next argument - TRI_ASSERT(foundArg); - - if (! inOptional) { - ++minRequiredArguments; - } - ++maxRequiredArguments; - foundArg = false; - break; - - case '+': - // repeated optional argument - TRI_ASSERT(inOptional); - maxRequiredArguments = MaxArguments; - return; - - default: - foundArg = true; - } - } - } - + void initArguments (); + // ----------------------------------------------------------------------------- // --SECTION-- public variables // ----------------------------------------------------------------------------- @@ -161,6 +115,13 @@ namespace triagens { bool const isDeterministic; +//////////////////////////////////////////////////////////////////////////////// +/// @brief whether or not the function contains a collection parameter that +/// will cause some special conversion during function calls +//////////////////////////////////////////////////////////////////////////////// + + bool containsCollectionParameter; + //////////////////////////////////////////////////////////////////////////////// /// @brief minimum number of required arguments //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/Aql/V8Executor.cpp b/arangod/Aql/V8Executor.cpp index 3e220717ac..8d255878f3 100644 --- a/arangod/Aql/V8Executor.cpp +++ b/arangod/Aql/V8Executor.cpp @@ -404,6 +404,18 @@ void V8Executor::generateCodeExpression (AstNode const* node) { _buffer->appendText("; })"); } +//////////////////////////////////////////////////////////////////////////////// +/// @brief generates code for a string value +//////////////////////////////////////////////////////////////////////////////// + +void V8Executor::generateCodeString (char const* value) { + TRI_ASSERT(value != nullptr); + + _buffer->appendChar('"'); + _buffer->appendJsonEncoded(value); + _buffer->appendChar('"'); +} + //////////////////////////////////////////////////////////////////////////////// /// @brief generate JavaScript code for a list //////////////////////////////////////////////////////////////////////////////// @@ -440,11 +452,12 @@ void V8Executor::generateCodeArray (AstNode const* node) { } auto member = node->getMember(i); - - _buffer->appendText("\""); - _buffer->appendJsonEncoded(member->getStringValue()); - _buffer->appendText("\" : "); - generateCodeNode(member->getMember(0)); + + if (member != nullptr) { + generateCodeString(member->getStringValue()); + _buffer->appendText(" : "); + generateCodeNode(member->getMember(0)); + } } _buffer->appendText(" }"); } @@ -547,9 +560,9 @@ void V8Executor::generateCodeReference (AstNode const* node) { auto variable = static_cast(node->getData()); - _buffer->appendText("vars[\""); - _buffer->appendJsonEncoded(variable->name.c_str()); - _buffer->appendText("\"]"); + _buffer->appendText("vars["); + generateCodeString(variable->name.c_str()); + _buffer->appendText("]"); } //////////////////////////////////////////////////////////////////////////////// @@ -561,10 +574,10 @@ void V8Executor::generateCodeVariable (AstNode const* node) { TRI_ASSERT(node->numMembers() == 0); auto variable = static_cast(node->getData()); - - _buffer->appendText("vars[\""); - _buffer->appendJsonEncoded(variable->name.c_str()); - _buffer->appendText("\"]"); + + _buffer->appendText("vars["); + generateCodeString(variable->name.c_str()); + _buffer->appendText("]"); } //////////////////////////////////////////////////////////////////////////////// @@ -577,9 +590,9 @@ void V8Executor::generateCodeCollection (AstNode const* node) { char const* name = node->getStringValue(); - _buffer->appendText("aql.GET_DOCUMENTS(\""); - _buffer->appendJsonEncoded(name); - _buffer->appendText("\")"); + _buffer->appendText("aql.GET_DOCUMENTS("); + generateCodeString(name); + _buffer->appendText(")"); } //////////////////////////////////////////////////////////////////////////////// @@ -606,7 +619,20 @@ void V8Executor::generateCodeFunctionCall (AstNode const* node) { _buffer->appendText(", "); } - generateCodeNode(args->getMember(i)); + auto member = args->getMember(i); + + if (member != nullptr) { + if (member->type == NODE_TYPE_COLLECTION && + func->containsCollectionParameter) { + // do a parameter conversion from a collection parameter to a collection name parameter + char const* name = member->getStringValue(); + generateCodeString(name); + } + else { + // generate regular code for the node + generateCodeNode(args->getMember(i)); + } + } } _buffer->appendText(")"); } @@ -626,9 +652,9 @@ void V8Executor::generateCodeUserFunctionCall (AstNode const* node) { TRI_ASSERT(args != nullptr); TRI_ASSERT(args->type == NODE_TYPE_LIST); - _buffer->appendText("aql.FCALL_USER(\""); - _buffer->appendJsonEncoded(name); - _buffer->appendText("\", ["); + _buffer->appendText("aql.FCALL_USER("); + generateCodeString(name); + _buffer->appendText(", ["); size_t const n = args->numMembers(); for (size_t i = 0; i < n; ++i) { @@ -693,9 +719,9 @@ void V8Executor::generateCodeNamedAccess (AstNode const* node) { _buffer->appendText("aql.DOCUMENT_MEMBER("); generateCodeNode(node->getMember(0)); - _buffer->appendText(", \""); - _buffer->appendJsonEncoded(node->getStringValue()); - _buffer->appendText("\")"); + _buffer->appendText(", "); + generateCodeString(node->getStringValue()); + _buffer->appendText(")"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/Aql/V8Executor.h b/arangod/Aql/V8Executor.h index 71e7d6b2d8..7d76f3793c 100644 --- a/arangod/Aql/V8Executor.h +++ b/arangod/Aql/V8Executor.h @@ -114,6 +114,12 @@ namespace triagens { void generateCodeExpression (AstNode const*); +//////////////////////////////////////////////////////////////////////////////// +/// @brief generates code for a string value +//////////////////////////////////////////////////////////////////////////////// + + void generateCodeString (char const*); + //////////////////////////////////////////////////////////////////////////////// /// @brief generate JavaScript code for a list //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/Aql/V8Expression.cpp b/arangod/Aql/V8Expression.cpp new file mode 100644 index 0000000000..0d905eac61 --- /dev/null +++ b/arangod/Aql/V8Expression.cpp @@ -0,0 +1,113 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Aql, V8 expression +/// +/// @file +/// +/// DISCLAIMER +/// +/// Copyright 2014 ArangoDB GmbH, Cologne, Germany +/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// +/// Copyright holder is ArangoDB GmbH, Cologne, Germany +/// +/// @author Jan Steemann +/// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany +/// @author Copyright 2012-2013, triAGENS GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + +#include "Aql/V8Expression.h" +#include "Aql/V8Executor.h" +#include "BasicsC/json.h" +#include "V8/v8-conv.h" + +using namespace triagens::aql; + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors / destructors +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the v8 expression +//////////////////////////////////////////////////////////////////////////////// + +V8Expression::V8Expression (v8::Isolate* isolate, + v8::Persistent func) + : isolate(isolate), + func(func) { + +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy the v8 expression +//////////////////////////////////////////////////////////////////////////////// + +V8Expression::~V8Expression () { + func.Dispose(isolate); + func.Clear(); +} + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief execute the expression +//////////////////////////////////////////////////////////////////////////////// + +AqlValue V8Expression::execute (AQL_TRANSACTION_V8* trx, + std::vector& docColls, + std::vector& argv, + size_t startPos, + std::vector const& vars, + std::vector const& regs) { + size_t const n = vars.size(); + TRI_ASSERT(regs.size() == n); // assert same vector length + + v8::Handle values = v8::Object::New(); + for (size_t i = 0; i < n; ++i) { + auto varname = vars[i]->name; + auto reg = regs[i]; + + TRI_ASSERT(! argv[reg].isEmpty()); + + values->Set(v8::String::New(varname.c_str(), (int) varname.size()), argv[startPos + reg].toV8(trx, docColls[reg])); + } + + // set function arguments + v8::Handle args[] = { values }; + + // execute the function + v8::TryCatch tryCatch; + v8::Handle result = func->Call(func, 1, args); + + V8Executor::HandleV8Error(tryCatch, result); + + TRI_json_t* json = TRI_ObjectToJson(result); + + if (json == nullptr) { + THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY); + } + + return AqlValue(new triagens::basics::Json(TRI_UNKNOWN_MEM_ZONE, json)); +} + +// ----------------------------------------------------------------------------- +// --SECTION-- END-OF-FILE +// ----------------------------------------------------------------------------- + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Aql/V8Expression.h b/arangod/Aql/V8Expression.h index add276f11c..086f934fd4 100644 --- a/arangod/Aql/V8Expression.h +++ b/arangod/Aql/V8Expression.h @@ -1,5 +1,5 @@ //////////////////////////////////////////////////////////////////////////////// -/// @brief Aql, V8 execution context +/// @brief Aql, V8 expression /// /// @file /// @@ -31,10 +31,7 @@ #define ARANGODB_AQL_V8_EXPRESSION_H 1 #include "Basics/Common.h" -#include "Basics/JsonHelper.h" -#include "BasicsC/json.h" #include "Aql/Types.h" -#include "V8/v8-conv.h" #include namespace triagens { @@ -46,73 +43,46 @@ namespace triagens { struct V8Expression { +// ----------------------------------------------------------------------------- +// --SECTION-- constructors / destructors +// ----------------------------------------------------------------------------- + //////////////////////////////////////////////////////////////////////////////// /// @brief create the v8 expression //////////////////////////////////////////////////////////////////////////////// - V8Expression (v8::Isolate* isolate, - v8::Persistent func) - : isolate(isolate), - func(func) { - } + V8Expression (v8::Isolate*, + v8::Persistent); //////////////////////////////////////////////////////////////////////////////// /// @brief destroy the v8 expression //////////////////////////////////////////////////////////////////////////////// - ~V8Expression () { - func.Dispose(isolate); - func.Clear(); - } + ~V8Expression (); + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @brief execute the expression //////////////////////////////////////////////////////////////////////////////// - AqlValue execute (AQL_TRANSACTION_V8* trx, - std::vector& docColls, - std::vector& argv, - size_t startPos, - std::vector const& vars, - std::vector const& regs) { - // TODO: decide whether a separate handle scope is needed + AqlValue execute (AQL_TRANSACTION_V8*, + std::vector&, + std::vector&, + size_t, + std::vector const&, + std::vector const&); - size_t const n = vars.size(); - TRI_ASSERT(regs.size() == n); // assert same vector length +// ----------------------------------------------------------------------------- +// --SECTION-- public variables +// ----------------------------------------------------------------------------- - v8::Handle values = v8::Object::New(); - for (size_t i = 0; i < n; ++i) { - auto varname = vars[i]->name; - auto reg = regs[i]; + v8::Isolate* isolate; - TRI_ASSERT(! argv[reg].isEmpty()); - - values->Set(v8::String::New(varname.c_str(), (int) varname.size()), argv[startPos + reg].toV8(trx, docColls[reg])); - } - - // set function arguments - v8::Handle args[] = { values }; - - // execute the function - v8::TryCatch tryCatch; - v8::Handle result = func->Call(func, 1, args); + v8::Persistent func; - V8Executor::HandleV8Error(tryCatch, result); - - TRI_json_t* json = TRI_ObjectToJson(result); - - if (json == nullptr) { - THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY); - } - - return AqlValue(new triagens::basics::Json(TRI_UNKNOWN_MEM_ZONE, json)); - } - - - v8::Isolate* isolate; - - v8::Persistent func; - }; } diff --git a/arangod/CMakeLists.txt b/arangod/CMakeLists.txt index 4bb60a4d82..4d5df1ae53 100644 --- a/arangod/CMakeLists.txt +++ b/arangod/CMakeLists.txt @@ -65,6 +65,7 @@ add_executable( Aql/ExecutionNode.cpp Aql/ExecutionPlan.cpp Aql/Expression.cpp + Aql/Function.cpp Aql/grammar.cpp Aql/Parser.cpp Aql/Query.cpp @@ -72,6 +73,7 @@ add_executable( Aql/Types.cpp Aql/tokens.cpp Aql/V8Executor.cpp + Aql/V8Expression.cpp Aql/Variable.cpp Aql/VariableGenerator.cpp BitIndexes/bitarray.cpp diff --git a/arangod/Makefile.files b/arangod/Makefile.files index 6445df443d..92a86ece3a 100644 --- a/arangod/Makefile.files +++ b/arangod/Makefile.files @@ -46,6 +46,7 @@ arangod_libarangod_a_SOURCES = \ arangod/Aql/ExecutionNode.cpp \ arangod/Aql/ExecutionPlan.cpp \ arangod/Aql/Expression.cpp \ + arangod/Aql/Function.cpp \ arangod/Aql/grammar.cpp \ arangod/Aql/Parser.cpp \ arangod/Aql/Query.cpp \ @@ -53,6 +54,7 @@ arangod_libarangod_a_SOURCES = \ arangod/Aql/Types.cpp \ arangod/Aql/tokens.cpp \ arangod/Aql/V8Executor.cpp \ + arangod/Aql/V8Expression.cpp \ arangod/Aql/Variable.cpp \ arangod/Aql/VariableGenerator.cpp \ arangod/BitIndexes/bitarray.cpp \ From ba5365d9e908ebb66ebb1f4919e45072bd3a7143 Mon Sep 17 00:00:00 2001 From: Willi Goesgens Date: Thu, 7 Aug 2014 11:55:22 +0200 Subject: [PATCH 2/4] v8-vocbase split: clean up includes. --- arangod/V8Server/v8-collection.cpp | 51 ++----------------- arangod/V8Server/v8-collection.h | 4 ++ arangod/V8Server/v8-query.cpp | 2 +- arangod/V8Server/v8-replication.cpp | 63 ++--------------------- arangod/V8Server/v8-util.cpp | 63 ++--------------------- arangod/V8Server/v8-vocbase.cpp | 41 +++------------ arangod/V8Server/v8-vocbaseprivate.h | 6 +++ arangod/V8Server/v8-voccursor.cpp | 63 ++--------------------- arangod/V8Server/v8-voccursor.h | 4 ++ arangod/V8Server/v8-vocindex.cpp | 70 +++----------------------- arangod/V8Server/v8-vocindex.h | 6 +++ arangod/V8Server/v8-wrapshapedjson.cpp | 66 ++---------------------- arangod/V8Server/v8-wrapshapedjson.h | 3 ++ 13 files changed, 57 insertions(+), 385 deletions(-) diff --git a/arangod/V8Server/v8-collection.cpp b/arangod/V8Server/v8-collection.cpp index a9aac4de60..ea0248bbbb 100644 --- a/arangod/V8Server/v8-collection.cpp +++ b/arangod/V8Server/v8-collection.cpp @@ -27,72 +27,29 @@ /// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// -#include "v8-vocbase.h" +#include "v8-collection.h" +#include "v8-vocbaseprivate.h" -#include "Ahuacatl/ahuacatl-codegen.h" #include "Ahuacatl/ahuacatl-collections.h" -#include "Ahuacatl/ahuacatl-context.h" #include "Ahuacatl/ahuacatl-explain.h" -#include "Ahuacatl/ahuacatl-result.h" #include "Aql/ExecutionBlock.h" -#include "Aql/ExecutionNode.h" -#include "Aql/ExecutionPlan.h" -#include "Aql/ExecutionEngine.h" #include "Aql/Query.h" -#include "Basics/StringUtils.h" #include "Basics/Utf8Helper.h" #include "BasicsC/conversions.h" -#include "BasicsC/files.h" -#include "BasicsC/json.h" -#include "BasicsC/json-utilities.h" -#include "BasicsC/logging.h" -#include "BasicsC/tri-strings.h" -#include "CapConstraint/cap-constraint.h" -#include "FulltextIndex/fulltext-index.h" -#include "HttpServer/ApplicationEndpointServer.h" -#include "Replication/InitialSyncer.h" -#include "Rest/SslInterface.h" -#include "ShapedJson/shape-accessor.h" -#include "ShapedJson/shaped-json.h" -#include "Utils/AhuacatlGuard.h" -#include "Utils/AhuacatlTransaction.h" -#include "Utils/DocumentHelper.h" -#include "Utils/transactions.h" #include "Utils/V8ResolverGuard.h" -#include "V8/v8-conv.h" -#include "V8/v8-execution.h" #include "V8/v8-utils.h" #include "Wal/LogfileManager.h" + #include "VocBase/auth.h" -#include "VocBase/datafile.h" -#include "VocBase/document-collection.h" -#include "VocBase/edge-collection.h" -#include "VocBase/general-cursor.h" #include "VocBase/key-generator.h" -#include "VocBase/replication-applier.h" -#include "VocBase/replication-dump.h" -#include "VocBase/server.h" -#include "VocBase/voc-shaper.h" -#include "VocBase/index.h" -#include "v8.h" -#include "V8/JSLoader.h" -#include "Basics/JsonHelper.h" -#include "Cluster/AgencyComm.h" -#include "Cluster/ClusterComm.h" -#include "Cluster/ClusterInfo.h" + #include "Cluster/ClusterMethods.h" -#include "Cluster/ServerState.h" #include "unicode/timezone.h" -#include "unicode/utypes.h" -#include "unicode/datefmt.h" -#include "unicode/smpdtfmt.h" -#include "unicode/dtfmtsym.h" #include "v8-vocbase.h" #include "v8-vocbaseprivate.h" #include "v8-vocindex.h" -#include "v8-collection.h" using namespace std; using namespace triagens::basics; diff --git a/arangod/V8Server/v8-collection.h b/arangod/V8Server/v8-collection.h index b9ae7cc9b6..32cb81e3c9 100644 --- a/arangod/V8Server/v8-collection.h +++ b/arangod/V8Server/v8-collection.h @@ -31,6 +31,10 @@ #ifndef ARANGODB_V8SERVER_V8__COLLECTION_H #define ARANGODB_V8SERVER_V8__COLLECTION_H 1 +#include "Basics/Common.h" +#include "v8-vocbase.h" +#include "Utils/CollectionNameResolver.h" + //////////////////////////////////////////////////////////////////////////////// /// @brief free a coordinator collection //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/V8Server/v8-query.cpp b/arangod/V8Server/v8-query.cpp index adf144111a..487b84e6b9 100644 --- a/arangod/V8Server/v8-query.cpp +++ b/arangod/V8Server/v8-query.cpp @@ -28,6 +28,7 @@ //////////////////////////////////////////////////////////////////////////////// #include "v8-query.h" +#include "v8-vocindex.h" #include "BasicsC/logging.h" #include "BasicsC/random.h" @@ -45,7 +46,6 @@ #include "V8Server/v8-vocbase.h" #include "VocBase/edge-collection.h" #include "VocBase/vocbase.h" -#include "v8-vocindex.h" #include "v8-wrapshapedjson.h" using namespace std; diff --git a/arangod/V8Server/v8-replication.cpp b/arangod/V8Server/v8-replication.cpp index 64df233437..1cd4c7d7e8 100644 --- a/arangod/V8Server/v8-replication.cpp +++ b/arangod/V8Server/v8-replication.cpp @@ -27,69 +27,15 @@ /// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// -#include "v8-vocbase.h" +#include "v8-vocbaseprivate.h" -#include "Ahuacatl/ahuacatl-codegen.h" #include "Ahuacatl/ahuacatl-collections.h" -#include "Ahuacatl/ahuacatl-context.h" -#include "Ahuacatl/ahuacatl-explain.h" -#include "Ahuacatl/ahuacatl-result.h" #include "Aql/ExecutionBlock.h" -#include "Aql/ExecutionNode.h" -#include "Aql/ExecutionPlan.h" -#include "Aql/ExecutionEngine.h" -#include "Aql/Query.h" -#include "Basics/StringUtils.h" -#include "Basics/Utf8Helper.h" -#include "BasicsC/conversions.h" -#include "BasicsC/files.h" -#include "BasicsC/json.h" -#include "BasicsC/json-utilities.h" -#include "BasicsC/logging.h" -#include "BasicsC/tri-strings.h" -#include "CapConstraint/cap-constraint.h" -#include "FulltextIndex/fulltext-index.h" -#include "HttpServer/ApplicationEndpointServer.h" -#include "Replication/InitialSyncer.h" -#include "Rest/SslInterface.h" -#include "ShapedJson/shape-accessor.h" -#include "ShapedJson/shaped-json.h" -#include "Utils/AhuacatlGuard.h" -#include "Utils/AhuacatlTransaction.h" -#include "Utils/DocumentHelper.h" -#include "Utils/transactions.h" -#include "Utils/V8ResolverGuard.h" -#include "V8/v8-conv.h" -#include "V8/v8-execution.h" #include "V8/v8-utils.h" #include "Wal/LogfileManager.h" -#include "VocBase/auth.h" -#include "VocBase/datafile.h" -#include "VocBase/document-collection.h" -#include "VocBase/edge-collection.h" -#include "VocBase/general-cursor.h" -#include "VocBase/key-generator.h" -#include "VocBase/replication-applier.h" + #include "VocBase/replication-dump.h" -#include "VocBase/server.h" -#include "VocBase/voc-shaper.h" -#include "VocBase/index.h" -#include "v8.h" -#include "V8/JSLoader.h" -#include "Basics/JsonHelper.h" -#include "Cluster/AgencyComm.h" -#include "Cluster/ClusterComm.h" -#include "Cluster/ClusterInfo.h" -#include "Cluster/ClusterMethods.h" -#include "Cluster/ServerState.h" - -#include "unicode/timezone.h" -#include "unicode/utypes.h" -#include "unicode/datefmt.h" -#include "unicode/smpdtfmt.h" -#include "unicode/dtfmtsym.h" - -#include "v8-vocbaseprivate.h" +#include "Replication/InitialSyncer.h" using namespace std; using namespace triagens::basics; @@ -650,6 +596,7 @@ void TRI_InitV8replication (v8::Handle context, JSLoader* loader, const size_t threadNumber, TRI_v8_global_t* v8g){ + // replication functions. not intended to be used by end users TRI_AddGlobalFunctionVocbase(context, "REPLICATION_LOGGER_STATE", JS_StateLoggerReplication, true); TRI_AddGlobalFunctionVocbase(context, "REPLICATION_LOGGER_CONFIGURE", JS_ConfigureLoggerReplication, true); @@ -663,6 +610,4 @@ void TRI_InitV8replication (v8::Handle context, TRI_AddGlobalFunctionVocbase(context, "REPLICATION_APPLIER_SHUTDOWN", JS_ShutdownApplierReplication, true); TRI_AddGlobalFunctionVocbase(context, "REPLICATION_APPLIER_STATE", JS_StateApplierReplication, true); TRI_AddGlobalFunctionVocbase(context, "REPLICATION_APPLIER_FORGET", JS_ForgetApplierReplication, true); - - } diff --git a/arangod/V8Server/v8-util.cpp b/arangod/V8Server/v8-util.cpp index dbe87861b6..295c19be84 100644 --- a/arangod/V8Server/v8-util.cpp +++ b/arangod/V8Server/v8-util.cpp @@ -27,67 +27,10 @@ /// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// -#include "v8-vocbase.h" - -#include "Ahuacatl/ahuacatl-codegen.h" -#include "Ahuacatl/ahuacatl-collections.h" -#include "Ahuacatl/ahuacatl-context.h" -#include "Ahuacatl/ahuacatl-explain.h" -#include "Ahuacatl/ahuacatl-result.h" -#include "Aql/ExecutionBlock.h" -#include "Aql/ExecutionNode.h" -#include "Aql/ExecutionPlan.h" -#include "Aql/ExecutionEngine.h" -#include "Aql/Query.h" -#include "Basics/StringUtils.h" -#include "Basics/Utf8Helper.h" -#include "BasicsC/conversions.h" -#include "BasicsC/files.h" -#include "BasicsC/json.h" -#include "BasicsC/json-utilities.h" -#include "BasicsC/logging.h" -#include "BasicsC/tri-strings.h" -#include "CapConstraint/cap-constraint.h" -#include "FulltextIndex/fulltext-index.h" -#include "HttpServer/ApplicationEndpointServer.h" -#include "Rest/SslInterface.h" -#include "ShapedJson/shape-accessor.h" -#include "ShapedJson/shaped-json.h" -#include "Utils/AhuacatlGuard.h" -#include "Utils/AhuacatlTransaction.h" -#include "Utils/DocumentHelper.h" -#include "Utils/transactions.h" -#include "Utils/V8ResolverGuard.h" -#include "V8/v8-conv.h" -#include "V8/v8-execution.h" -#include "V8/v8-utils.h" -#include "Wal/LogfileManager.h" -#include "VocBase/auth.h" -#include "VocBase/datafile.h" -#include "VocBase/document-collection.h" -#include "VocBase/edge-collection.h" -#include "VocBase/key-generator.h" -#include "VocBase/server.h" -#include "VocBase/voc-shaper.h" -#include "VocBase/index.h" -#include "v8.h" -#include "V8/JSLoader.h" -#include "Basics/JsonHelper.h" -#include "Cluster/AgencyComm.h" -#include "Cluster/ClusterComm.h" -#include "Cluster/ClusterInfo.h" -#include "Cluster/ClusterMethods.h" -#include "Cluster/ServerState.h" - -#include "unicode/timezone.h" -#include "unicode/utypes.h" -#include "unicode/datefmt.h" -#include "unicode/smpdtfmt.h" -#include "unicode/dtfmtsym.h" - #include "v8-vocbaseprivate.h" -#include "v8-wrapshapedjson.h" -#include "v8-voccursor.h" +#include "Aql/ExecutionBlock.h" +#include "BasicsC/conversions.h" +#include "VocBase/key-generator.h" using namespace std; using namespace triagens::basics; diff --git a/arangod/V8Server/v8-vocbase.cpp b/arangod/V8Server/v8-vocbase.cpp index a38af3d879..93e4daa909 100644 --- a/arangod/V8Server/v8-vocbase.cpp +++ b/arangod/V8Server/v8-vocbase.cpp @@ -27,52 +27,29 @@ /// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// -#include "v8-vocbase.h" +#include "v8-vocbaseprivate.h" +#include "v8-wrapshapedjson.h" +#include "v8-voccursor.h" +#include "v8-collection.h" -#include "Ahuacatl/ahuacatl-codegen.h" #include "Ahuacatl/ahuacatl-collections.h" -#include "Ahuacatl/ahuacatl-context.h" #include "Ahuacatl/ahuacatl-explain.h" -#include "Ahuacatl/ahuacatl-result.h" #include "Aql/ExecutionBlock.h" -#include "Aql/ExecutionNode.h" -#include "Aql/ExecutionPlan.h" -#include "Aql/ExecutionEngine.h" #include "Aql/Query.h" -#include "Basics/StringUtils.h" #include "Basics/Utf8Helper.h" -#include "BasicsC/conversions.h" -#include "BasicsC/files.h" -#include "BasicsC/json.h" -#include "BasicsC/json-utilities.h" -#include "BasicsC/logging.h" -#include "BasicsC/tri-strings.h" -#include "CapConstraint/cap-constraint.h" -#include "FulltextIndex/fulltext-index.h" #include "HttpServer/ApplicationEndpointServer.h" -#include "Rest/SslInterface.h" -#include "ShapedJson/shape-accessor.h" -#include "ShapedJson/shaped-json.h" #include "Utils/AhuacatlGuard.h" #include "Utils/AhuacatlTransaction.h" -#include "Utils/DocumentHelper.h" -#include "Utils/transactions.h" #include "Utils/V8ResolverGuard.h" #include "V8/v8-conv.h" #include "V8/v8-execution.h" #include "V8/v8-utils.h" #include "Wal/LogfileManager.h" + #include "VocBase/auth.h" -#include "VocBase/datafile.h" -#include "VocBase/document-collection.h" -#include "VocBase/edge-collection.h" -#include "VocBase/key-generator.h" -#include "VocBase/server.h" -#include "VocBase/voc-shaper.h" -#include "VocBase/index.h" #include "v8.h" #include "V8/JSLoader.h" -#include "Basics/JsonHelper.h" + #include "Cluster/AgencyComm.h" #include "Cluster/ClusterComm.h" #include "Cluster/ClusterInfo.h" @@ -80,15 +57,9 @@ #include "Cluster/ServerState.h" #include "unicode/timezone.h" -#include "unicode/utypes.h" -#include "unicode/datefmt.h" #include "unicode/smpdtfmt.h" #include "unicode/dtfmtsym.h" -#include "v8-vocbaseprivate.h" -#include "v8-wrapshapedjson.h" -#include "v8-voccursor.h" -#include "v8-collection.h" using namespace std; using namespace triagens::basics; diff --git a/arangod/V8Server/v8-vocbaseprivate.h b/arangod/V8Server/v8-vocbaseprivate.h index f8e64bacaf..35705df3bb 100644 --- a/arangod/V8Server/v8-vocbaseprivate.h +++ b/arangod/V8Server/v8-vocbaseprivate.h @@ -30,6 +30,12 @@ #ifndef ARANGODB_V8SERVER_V8__VOCBASE_PRIVATE_H #define ARANGODB_V8SERVER_V8__VOCBASE_PRIVATE_H +#include "Basics/Common.h" +#include "V8/v8-utils.h" +#include "v8-vocbase.h" +#include "Ahuacatl/ahuacatl-error.h" + + //////////////////////////////////////////////////////////////////////////////// /// @brief wrapped class for TRI_vocbase_t /// diff --git a/arangod/V8Server/v8-voccursor.cpp b/arangod/V8Server/v8-voccursor.cpp index 8699ecca47..68ba3cf9d7 100644 --- a/arangod/V8Server/v8-voccursor.cpp +++ b/arangod/V8Server/v8-voccursor.cpp @@ -27,70 +27,17 @@ /// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// -#include "v8-vocbase.h" +#include "v8-voccursor.h" +#include "v8-vocbaseprivate.h" + +#include "VocBase/general-cursor.h" #include "Ahuacatl/ahuacatl-codegen.h" #include "Ahuacatl/ahuacatl-collections.h" -#include "Ahuacatl/ahuacatl-context.h" -#include "Ahuacatl/ahuacatl-explain.h" #include "Ahuacatl/ahuacatl-result.h" -#include "Aql/ExecutionBlock.h" -#include "Aql/ExecutionNode.h" -#include "Aql/ExecutionPlan.h" -#include "Aql/ExecutionEngine.h" -#include "Aql/Query.h" -#include "Basics/StringUtils.h" -#include "Basics/Utf8Helper.h" -#include "BasicsC/conversions.h" -#include "BasicsC/files.h" -#include "BasicsC/json.h" -#include "BasicsC/json-utilities.h" -#include "BasicsC/logging.h" -#include "BasicsC/tri-strings.h" -#include "CapConstraint/cap-constraint.h" -#include "FulltextIndex/fulltext-index.h" -#include "HttpServer/ApplicationEndpointServer.h" -#include "Replication/InitialSyncer.h" -#include "Rest/SslInterface.h" -#include "ShapedJson/shape-accessor.h" -#include "ShapedJson/shaped-json.h" -#include "Utils/AhuacatlGuard.h" #include "Utils/AhuacatlTransaction.h" -#include "Utils/DocumentHelper.h" -#include "Utils/transactions.h" -#include "Utils/V8ResolverGuard.h" -#include "V8/v8-conv.h" -#include "V8/v8-execution.h" -#include "V8/v8-utils.h" -#include "Wal/LogfileManager.h" -#include "VocBase/auth.h" -#include "VocBase/datafile.h" -#include "VocBase/document-collection.h" -#include "VocBase/edge-collection.h" -#include "VocBase/general-cursor.h" -#include "VocBase/key-generator.h" -#include "VocBase/replication-applier.h" -#include "VocBase/replication-dump.h" -#include "VocBase/server.h" -#include "VocBase/voc-shaper.h" -#include "VocBase/index.h" -#include "v8.h" -#include "V8/JSLoader.h" -#include "Basics/JsonHelper.h" -#include "Cluster/AgencyComm.h" -#include "Cluster/ClusterComm.h" -#include "Cluster/ClusterInfo.h" -#include "Cluster/ClusterMethods.h" -#include "Cluster/ServerState.h" +#include "Aql/ExecutionBlock.h" -#include "unicode/timezone.h" -#include "unicode/utypes.h" -#include "unicode/datefmt.h" -#include "unicode/smpdtfmt.h" -#include "unicode/dtfmtsym.h" - -#include "v8-vocbaseprivate.h" -#include "v8-voccursor.h" using namespace std; using namespace triagens::basics; diff --git a/arangod/V8Server/v8-voccursor.h b/arangod/V8Server/v8-voccursor.h index b4fc5575f6..d52fc2e7ce 100644 --- a/arangod/V8Server/v8-voccursor.h +++ b/arangod/V8Server/v8-voccursor.h @@ -30,6 +30,10 @@ #ifndef ARANGODB_V8SERVER_V8__CURSOR_H #define ARANGODB_V8SERVER_V8__CURSOR_H 1 +#include "Basics/Common.h" +#include "v8-vocbase.h" +#include "Ahuacatl/ahuacatl-context.h" + //////////////////////////////////////////////////////////////////////////////// /// @brief function that encapsulates execution of an AQL query //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/V8Server/v8-vocindex.cpp b/arangod/V8Server/v8-vocindex.cpp index 0023d5d703..ab649eeacf 100644 --- a/arangod/V8Server/v8-vocindex.cpp +++ b/arangod/V8Server/v8-vocindex.cpp @@ -27,73 +27,17 @@ /// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// -#include "v8-vocbase.h" - -#include "Ahuacatl/ahuacatl-codegen.h" -#include "Ahuacatl/ahuacatl-collections.h" -#include "Ahuacatl/ahuacatl-context.h" -#include "Ahuacatl/ahuacatl-explain.h" -#include "Ahuacatl/ahuacatl-result.h" -#include "Aql/ExecutionBlock.h" -#include "Aql/ExecutionNode.h" -#include "Aql/ExecutionPlan.h" -#include "Aql/ExecutionEngine.h" -#include "Aql/Query.h" -#include "Basics/StringUtils.h" -#include "Basics/Utf8Helper.h" -#include "BasicsC/conversions.h" -#include "BasicsC/files.h" -#include "BasicsC/json.h" -#include "BasicsC/json-utilities.h" -#include "BasicsC/logging.h" -#include "BasicsC/tri-strings.h" -#include "CapConstraint/cap-constraint.h" -#include "FulltextIndex/fulltext-index.h" -#include "HttpServer/ApplicationEndpointServer.h" -#include "Replication/InitialSyncer.h" -#include "Rest/SslInterface.h" -#include "ShapedJson/shape-accessor.h" -#include "ShapedJson/shaped-json.h" -#include "Utils/AhuacatlGuard.h" -#include "Utils/AhuacatlTransaction.h" -#include "Utils/DocumentHelper.h" -#include "Utils/transactions.h" -#include "Utils/V8ResolverGuard.h" -#include "V8/v8-conv.h" -#include "V8/v8-execution.h" -#include "V8/v8-utils.h" -#include "Wal/LogfileManager.h" -#include "VocBase/auth.h" -#include "VocBase/datafile.h" -#include "VocBase/document-collection.h" -#include "VocBase/edge-collection.h" -#include "VocBase/general-cursor.h" -#include "VocBase/key-generator.h" -#include "VocBase/replication-applier.h" -#include "VocBase/replication-dump.h" -#include "VocBase/server.h" -#include "VocBase/voc-shaper.h" -#include "VocBase/index.h" -#include "v8.h" -#include "V8/JSLoader.h" -#include "Basics/JsonHelper.h" -#include "Cluster/AgencyComm.h" -#include "Cluster/ClusterComm.h" -#include "Cluster/ClusterInfo.h" -#include "Cluster/ClusterMethods.h" -#include "Cluster/ServerState.h" - -#include "unicode/timezone.h" -#include "unicode/utypes.h" -#include "unicode/datefmt.h" -#include "unicode/smpdtfmt.h" -#include "unicode/dtfmtsym.h" - +#include "v8-vocindex.h" #include "v8-vocbase.h" #include "v8-vocbaseprivate.h" -#include "v8-vocindex.h" #include "v8-collection.h" +#include "Aql/ExecutionBlock.h" +#include "BasicsC/conversions.h" +#include "CapConstraint/cap-constraint.h" +#include "Utils/AhuacatlGuard.h" +#include "V8/v8-utils.h" + using namespace std; using namespace triagens::basics; using namespace triagens::arango; diff --git a/arangod/V8Server/v8-vocindex.h b/arangod/V8Server/v8-vocindex.h index d9bcbffd08..18e275e74c 100644 --- a/arangod/V8Server/v8-vocindex.h +++ b/arangod/V8Server/v8-vocindex.h @@ -30,6 +30,12 @@ #ifndef ARANGODB_V8SERVER_V8__INDEX_H #define ARANGODB_V8SERVER_V8__INDEX_H 1 +#include "Basics/Common.h" + +#include "V8/v8-globals.h" +#include "VocBase/index.h" +#include "Utils/CollectionNameResolver.h" + //////////////////////////////////////////////////////////////////////////////// /// @brief looks up a index identifier //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/V8Server/v8-wrapshapedjson.cpp b/arangod/V8Server/v8-wrapshapedjson.cpp index 9950c31a97..33c2127d98 100644 --- a/arangod/V8Server/v8-wrapshapedjson.cpp +++ b/arangod/V8Server/v8-wrapshapedjson.cpp @@ -27,70 +27,12 @@ /// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// -#include "v8-vocbase.h" - -#include "Ahuacatl/ahuacatl-codegen.h" -#include "Ahuacatl/ahuacatl-collections.h" -#include "Ahuacatl/ahuacatl-context.h" -#include "Ahuacatl/ahuacatl-explain.h" -#include "Ahuacatl/ahuacatl-result.h" -#include "Aql/ExecutionBlock.h" -#include "Aql/ExecutionNode.h" -#include "Aql/ExecutionPlan.h" -#include "Aql/ExecutionEngine.h" -#include "Aql/Query.h" -#include "Basics/StringUtils.h" -#include "Basics/Utf8Helper.h" -#include "BasicsC/conversions.h" -#include "BasicsC/files.h" -#include "BasicsC/json.h" -#include "BasicsC/json-utilities.h" -#include "BasicsC/logging.h" -#include "BasicsC/tri-strings.h" -#include "CapConstraint/cap-constraint.h" -#include "FulltextIndex/fulltext-index.h" -#include "HttpServer/ApplicationEndpointServer.h" -#include "Replication/InitialSyncer.h" -#include "Rest/SslInterface.h" -#include "ShapedJson/shape-accessor.h" -#include "ShapedJson/shaped-json.h" -#include "Utils/AhuacatlGuard.h" -#include "Utils/AhuacatlTransaction.h" -#include "Utils/DocumentHelper.h" -#include "Utils/transactions.h" -#include "Utils/V8ResolverGuard.h" -#include "V8/v8-conv.h" -#include "V8/v8-execution.h" -#include "V8/v8-utils.h" -#include "Wal/LogfileManager.h" -#include "VocBase/auth.h" -#include "VocBase/datafile.h" -#include "VocBase/document-collection.h" -#include "VocBase/edge-collection.h" -#include "VocBase/general-cursor.h" -#include "VocBase/key-generator.h" -#include "VocBase/replication-applier.h" -#include "VocBase/replication-dump.h" -#include "VocBase/server.h" -#include "VocBase/voc-shaper.h" -#include "VocBase/index.h" -#include "v8.h" -#include "V8/JSLoader.h" -#include "Basics/JsonHelper.h" -#include "Cluster/AgencyComm.h" -#include "Cluster/ClusterComm.h" -#include "Cluster/ClusterInfo.h" -#include "Cluster/ClusterMethods.h" -#include "Cluster/ServerState.h" - -#include "unicode/timezone.h" -#include "unicode/utypes.h" -#include "unicode/datefmt.h" -#include "unicode/smpdtfmt.h" -#include "unicode/dtfmtsym.h" - +#include "v8-wrapshapedjson.h" #include "v8-vocbaseprivate.h" +#include "Aql/ExecutionBlock.h" +#include "BasicsC/conversions.h" + using namespace std; using namespace triagens::basics; using namespace triagens::arango; diff --git a/arangod/V8Server/v8-wrapshapedjson.h b/arangod/V8Server/v8-wrapshapedjson.h index 4b2859182c..9e38d23fb5 100644 --- a/arangod/V8Server/v8-wrapshapedjson.h +++ b/arangod/V8Server/v8-wrapshapedjson.h @@ -30,6 +30,9 @@ #ifndef ARANGODB_V8SERVER_V8__WRAPSHAPEDJSON_H #define ARANGODB_V8SERVER_V8__WRAPSHAPEDJSON_H +#include "Basics/Common.h" +#include "v8-vocbase.h" + //////////////////////////////////////////////////////////////////////////////// /// @brief wraps a TRI_shaped_json_t //////////////////////////////////////////////////////////////////////////////// From 1d6f7bc3d2a83da8ec526c0a12fbeda877034619 Mon Sep 17 00:00:00 2001 From: Max Neunhoeffer Date: Thu, 7 Aug 2014 11:56:26 +0200 Subject: [PATCH 3/4] Sort out bind as a preparation for subqueries. --- arangod/Aql/ExecutionBlock.cpp | 15 +++++--- arangod/Aql/ExecutionBlock.h | 67 ++++++++++++++++++++++------------ arangod/Aql/ExecutionNode.h | 2 +- 3 files changed, 54 insertions(+), 30 deletions(-) diff --git a/arangod/Aql/ExecutionBlock.cpp b/arangod/Aql/ExecutionBlock.cpp index c92646d9d3..1c3981f793 100644 --- a/arangod/Aql/ExecutionBlock.cpp +++ b/arangod/Aql/ExecutionBlock.cpp @@ -35,7 +35,14 @@ using namespace triagens::aql; ExecutionBlock::~ExecutionBlock () { } -int ExecutionBlock::bind (std::map* params) { +int ExecutionBlock::bind (AqlItemBlock* items, size_t pos) { + int res; + for (auto d : _dependencies) { + res = d->bind(items, pos); + if (res != TRI_ERROR_NO_ERROR) { + return res; + } + } return TRI_ERROR_NO_ERROR; } @@ -51,10 +58,8 @@ void ExecutionBlock::walk (WalkerWorker* worker) { worker->before(this); // Now the children in their natural order: - for (auto it = _dependencies.begin(); - it != _dependencies.end(); - ++it) { - (*it)->walk(worker); + for (auto c : _dependencies) { + c->walk(worker); } // Now handle a subquery: if (_exeNode->getType() == ExecutionNode::SUBQUERY) { diff --git a/arangod/Aql/ExecutionBlock.h b/arangod/Aql/ExecutionBlock.h index 80df468eea..e74503c1e5 100644 --- a/arangod/Aql/ExecutionBlock.h +++ b/arangod/Aql/ExecutionBlock.h @@ -191,10 +191,10 @@ namespace triagens { // Copy constructor used for a subquery: VarOverview (VarOverview const& v) - : varInfo(v.varInfo), nrRegsHere(v.nrRegs), nrRegs(v.nrRegs), + : varInfo(v.varInfo), nrRegsHere(v.nrRegsHere), nrRegs(v.nrRegs), depth(v.depth+1), totalNrRegs(v.totalNrRegs), me(nullptr) { nrRegsHere.push_back(0); - nrRegs.push_back(0); + nrRegs.push_back(nrRegs.back()); } ~VarOverview () {}; @@ -294,11 +294,6 @@ namespace triagens { v->setSharedPtr(&v); walk(v.get()); v->reset(); - std::cout << "Varinfo:\n"; - for (auto x : v->varInfo) { - std::cout << x.first << " => " << x.second.depth << "," - << x.second.registerId << std::endl; - } } //////////////////////////////////////////////////////////////////////////////// @@ -334,13 +329,7 @@ namespace triagens { /// @brief bind //////////////////////////////////////////////////////////////////////////////// - virtual int bind (std::map* params); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief getParameters -//////////////////////////////////////////////////////////////////////////////// - - std::map* getParameters (); + virtual int bind (AqlItemBlock* items, size_t pos); //////////////////////////////////////////////////////////////////////////////// /// @brief execute @@ -645,7 +634,7 @@ namespace triagens { //////////////////////////////////////////////////////////////////////////////// SingletonBlock (AQL_TRANSACTION_V8* trx, SingletonNode const* ep) - : ExecutionBlock(trx, ep) { + : ExecutionBlock(trx, ep), _inputRegisterValues(nullptr) { } //////////////////////////////////////////////////////////////////////////////// @@ -660,9 +649,23 @@ namespace triagens { //////////////////////////////////////////////////////////////////////////////// int initialize () { + _inputRegisterValues = nullptr; // just in case return ExecutionBlock::initialize(); } +//////////////////////////////////////////////////////////////////////////////// +/// @brief bind, store a copy of the register values coming from above +//////////////////////////////////////////////////////////////////////////////// + + int bind (AqlItemBlock* items, size_t pos) { + // Create a deep copy of the register values given to us: + if (_inputRegisterValues != nullptr) { + delete _inputRegisterValues; + } + _inputRegisterValues = items->slice(pos, pos+1); + return TRI_ERROR_NO_ERROR; + } + //////////////////////////////////////////////////////////////////////////////// /// @brief execute, just call base class //////////////////////////////////////////////////////////////////////////////// @@ -676,7 +679,12 @@ namespace triagens { //////////////////////////////////////////////////////////////////////////////// int shutdown () { - return ExecutionBlock::shutdown(); + int res = ExecutionBlock::shutdown(); + if (_inputRegisterValues != nullptr) { + delete _inputRegisterValues; + _inputRegisterValues = nullptr; + } + return res; } //////////////////////////////////////////////////////////////////////////////// @@ -688,7 +696,16 @@ namespace triagens { return nullptr; } - AqlItemBlock* res(new AqlItemBlock(1, _varOverview->nrRegs[_depth])); + AqlItemBlock* res = new AqlItemBlock(1, _varOverview->nrRegs[_depth]); + if (_inputRegisterValues != nullptr) { + for (RegisterId reg = 0; reg < _inputRegisterValues->getNrRegs(); ++reg) { + res->setValue(0, reg, _inputRegisterValues->getValue(0, reg)); + _inputRegisterValues->eraseValue(0, reg); + res->setDocumentCollection(reg, + _inputRegisterValues->getDocumentCollection(reg)); + + } + } _done = true; return res; } @@ -698,13 +715,7 @@ namespace triagens { //////////////////////////////////////////////////////////////////////////////// AqlItemBlock* getSome (size_t atLeast, size_t atMost) { - if (_done) { - return nullptr; - } - - AqlItemBlock* res(new AqlItemBlock(1, _varOverview->nrRegs[_depth])); - _done = true; - return res; + return getOne(); } //////////////////////////////////////////////////////////////////////////////// @@ -745,6 +756,14 @@ namespace triagens { return _done ? 0 : 1; } +//////////////////////////////////////////////////////////////////////////////// +/// @brief the bind data coming from outside +//////////////////////////////////////////////////////////////////////////////// + + private: + + AqlItemBlock* _inputRegisterValues; + }; diff --git a/arangod/Aql/ExecutionNode.h b/arangod/Aql/ExecutionNode.h index b36fe7a4e9..2e68794734 100644 --- a/arangod/Aql/ExecutionNode.h +++ b/arangod/Aql/ExecutionNode.h @@ -68,7 +68,7 @@ namespace triagens { CALCULATION, // done SUBQUERY, // done SORT, // done - AGGREGATE, // todo + AGGREGATE, // done LOOKUP_JOIN, MERGE_JOIN, LOOKUP_INDEX_UNIQUE, From 0f9f01b686d452b4dbb4c2340e8af5515f42fcc5 Mon Sep 17 00:00:00 2001 From: Max Neunhoeffer Date: Thu, 7 Aug 2014 16:15:41 +0200 Subject: [PATCH 4/4] Remove getOne except in the base class. --- arangod/Aql/ExecutionBlock.h | 219 +---------------------------------- 1 file changed, 4 insertions(+), 215 deletions(-) diff --git a/arangod/Aql/ExecutionBlock.h b/arangod/Aql/ExecutionBlock.h index e74503c1e5..1d67d765c8 100644 --- a/arangod/Aql/ExecutionBlock.h +++ b/arangod/Aql/ExecutionBlock.h @@ -389,36 +389,9 @@ namespace triagens { public: virtual AqlItemBlock* getOne () { - if (_done) { - return nullptr; - } - - if (_buffer.empty()) { - if (! getBlock(1, DefaultBatchSize)) { - _done = true; - return nullptr; - } - _pos = 0; - } - - TRI_ASSERT(! _buffer.empty()); - - // Here, _buffer.size() is > 0 and _pos points to a valid place - // in it. - - AqlItemBlock* res; - AqlItemBlock* cur; - cur = _buffer.front(); - res = cur->slice(_pos, _pos + 1); - _pos++; - if (_pos >= cur->size()) { - _buffer.pop_front(); - delete cur; - _pos = 0; - } - return res; + return getSome (1, 1); } - + virtual AqlItemBlock* getSome (size_t atLeast, size_t atMost) { if (_done) { @@ -688,10 +661,10 @@ namespace triagens { } //////////////////////////////////////////////////////////////////////////////// -/// @brief getOne +/// @brief getSome //////////////////////////////////////////////////////////////////////////////// - AqlItemBlock* getOne () { + AqlItemBlock* getSome (size_t, size_t) { if (_done) { return nullptr; } @@ -710,14 +683,6 @@ namespace triagens { return res; } -//////////////////////////////////////////////////////////////////////////////// -/// @brief getSome -//////////////////////////////////////////////////////////////////////////////// - - AqlItemBlock* getSome (size_t atLeast, size_t atMost) { - return getOne(); - } - //////////////////////////////////////////////////////////////////////////////// /// @brief hasMore //////////////////////////////////////////////////////////////////////////////// @@ -894,60 +859,6 @@ namespace triagens { return res; } -//////////////////////////////////////////////////////////////////////////////// -/// @brief getOne -//////////////////////////////////////////////////////////////////////////////// - - AqlItemBlock* getOne () { - if (_done) { - return nullptr; - } - - if (_buffer.empty()) { - if (! ExecutionBlock::getBlock(1, DefaultBatchSize)) { - _done = true; - return nullptr; - } - _pos = 0; // this is in the first block - _posInAllDocs = 0; // Note that we know _allDocs.size() > 0, - // otherwise _done would be true already - } - - // If we get here, we do have _buffer.front() - AqlItemBlock* cur = _buffer.front(); - - // Copy stuff from frames above: - auto res = new AqlItemBlock(1, _varOverview->nrRegs[_depth]); - TRI_ASSERT(cur->getNrRegs() <= res->getNrRegs()); - for (RegisterId i = 0; i < cur->getNrRegs(); i++) { - res->setValue(0, i, cur->getValue(_pos, i).clone()); - } - - // The result is in the first variable of this depth, - // we do not need to do a lookup in _varOverview->varInfo, - // but can just take cur->getNrRegs() as registerId: - res->setValue(0, cur->getNrRegs(), AqlValue(reinterpret_cast(_documents[_posInAllDocs++].getDataPtr()))); - res->getDocumentCollections().at(cur->getNrRegs()) - = _trx->documentCollection(); - - // Advance read position: - if (_posInAllDocs >= _documents.size()) { - // we have exhausted our local documents buffer - _posInAllDocs = 0; - - // fetch more documents into our buffer - if (! moreDocuments()) { - initDocuments(); - if (++_pos >= cur->size()) { - _buffer.pop_front(); - delete cur; - _pos = 0; - } - } - } - return res; - } - //////////////////////////////////////////////////////////////////////////////// /// @brief getSome //////////////////////////////////////////////////////////////////////////////// @@ -1128,29 +1039,6 @@ namespace triagens { } } -//////////////////////////////////////////////////////////////////////////////// -/// @brief getOne -//////////////////////////////////////////////////////////////////////////////// - - public: - - virtual AqlItemBlock* getOne () { - AqlItemBlock* res = ExecutionBlock::getOne(); - - if (res == nullptr) { - return nullptr; - } - - try { - doEvaluation(res); - return res; - } - catch (...) { - delete res; - throw; - } - } - //////////////////////////////////////////////////////////////////////////////// /// @brief getSome //////////////////////////////////////////////////////////////////////////////// @@ -1286,41 +1174,6 @@ namespace triagens { return true; } -//////////////////////////////////////////////////////////////////////////////// -/// @brief getOne -//////////////////////////////////////////////////////////////////////////////// - - AqlItemBlock* getOne () { - if (_done) { - return nullptr; - } - - if (_buffer.empty()) { - if (! getBlock(1, DefaultBatchSize)) { - _done = true; - return nullptr; - } - _pos = 0; - } - - TRI_ASSERT(_buffer.size() > 0); - - // Here, _buffer.size() is > 0 and _pos points to a valid place - // in it. - - AqlItemBlock* res; - AqlItemBlock* cur; - cur = _buffer.front(); - res = cur->slice(_chosen[_pos], _chosen[_pos+ 1]); - _pos++; - if (_pos >= _chosen.size()) { - _buffer.pop_front(); - delete cur; - _pos = 0; - } - return res; - } - //////////////////////////////////////////////////////////////////////////////// /// @brief getSome //////////////////////////////////////////////////////////////////////////////// @@ -1679,44 +1532,6 @@ namespace triagens { return TRI_ERROR_NO_ERROR; } -//////////////////////////////////////////////////////////////////////////////// -/// @brief getOne -//////////////////////////////////////////////////////////////////////////////// - - virtual AqlItemBlock* getOne () { - if (_state == 2) { - return nullptr; - } - - if (_state == 0) { - if (_offset > 0) { - ExecutionBlock::skip(_offset); - _state = 1; - _count = 0; - if (_limit == 0) { - _state = 2; - return nullptr; - } - } - } - - // If we get to here, _state == 1 and _count < _limit - - // Fetch one from above, possibly using our _buffer: - auto res = ExecutionBlock::getOne(); - if (res == nullptr) { - _state = 2; - return res; - } - TRI_ASSERT(res->size() == 1); - - if (++_count >= _limit) { - _state = 2; - } - - return res; - } - //////////////////////////////////////////////////////////////////////////////// /// @brief getSome //////////////////////////////////////////////////////////////////////////////// @@ -1809,32 +1624,6 @@ namespace triagens { ~ReturnBlock () { } -//////////////////////////////////////////////////////////////////////////////// -/// @brief getOne -//////////////////////////////////////////////////////////////////////////////// - - virtual AqlItemBlock* getOne () { - // Fetch one from above, possibly using our _buffer: - auto res = ExecutionBlock::getOne(); - if (res == nullptr) { - return res; - } - TRI_ASSERT(res->size() == 1); - - // Let's steal the actual result and throw away the vars: - AqlItemBlock* stripped = new AqlItemBlock(1, 1); - auto ep = static_cast(getPlanNode()); - auto it = _varOverview->varInfo.find(ep->_inVariable->id); - TRI_ASSERT(it != _varOverview->varInfo.end()); - RegisterId registerId = it->second.registerId; - stripped->setValue(0, 0, res->getValue(0, registerId)); - res->eraseValue(0, registerId); - stripped->setDocumentCollection(0, res->getDocumentCollection(registerId)); - - delete res; - return stripped; - } - //////////////////////////////////////////////////////////////////////////////// /// @brief getSome ////////////////////////////////////////////////////////////////////////////////