mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel
This commit is contained in:
commit
1cdf01970e
|
@ -571,7 +571,7 @@ int SingletonBlock::getOrSkipSome (size_t, // atLeast,
|
|||
}
|
||||
|
||||
if(! skipping){
|
||||
result = new AqlItemBlock(1, getPlanNode()->getVarOverview()->nrRegs[getPlanNode()->getDepth()]);
|
||||
result = new AqlItemBlock(1, getPlanNode()->getRegisterPlan()->nrRegs[getPlanNode()->getDepth()]);
|
||||
try {
|
||||
if (_inputRegisterValues != nullptr) {
|
||||
skipped++;
|
||||
|
@ -697,7 +697,7 @@ AqlItemBlock* EnumerateCollectionBlock::getSome (size_t, // atLeast,
|
|||
size_t available = _documents.size() - _posInAllDocs;
|
||||
size_t toSend = (std::min)(atMost, available);
|
||||
|
||||
unique_ptr<AqlItemBlock> res(new AqlItemBlock(toSend, getPlanNode()->getVarOverview()->nrRegs[getPlanNode()->getDepth()]));
|
||||
unique_ptr<AqlItemBlock> res(new AqlItemBlock(toSend, getPlanNode()->getRegisterPlan()->nrRegs[getPlanNode()->getDepth()]));
|
||||
// automatically freed if we throw
|
||||
TRI_ASSERT(curRegs <= res->getNrRegs());
|
||||
|
||||
|
@ -718,7 +718,7 @@ AqlItemBlock* EnumerateCollectionBlock::getSome (size_t, // atLeast,
|
|||
}
|
||||
|
||||
// The result is in the first variable of this depth,
|
||||
// we do not need to do a lookup in getPlanNode()->_varOverview->varInfo,
|
||||
// we do not need to do a lookup in getPlanNode()->_registerPlan->varInfo,
|
||||
// but can just take cur->getNrRegs() as registerId:
|
||||
res->setValue(j, static_cast<triagens::aql::RegisterId>(curRegs),
|
||||
AqlValue(reinterpret_cast<TRI_df_marker_t
|
||||
|
@ -855,8 +855,8 @@ int IndexRangeBlock::initialize () {
|
|||
std::unordered_set<Variable*> inVars = e->variables();
|
||||
for (auto v : inVars) {
|
||||
inVarsCur.push_back(v);
|
||||
auto it = getPlanNode()->getVarOverview()->varInfo.find(v->id);
|
||||
TRI_ASSERT(it != getPlanNode()->getVarOverview()->varInfo.end());
|
||||
auto it = getPlanNode()->getRegisterPlan()->varInfo.find(v->id);
|
||||
TRI_ASSERT(it != getPlanNode()->getRegisterPlan()->varInfo.end());
|
||||
TRI_ASSERT(it->second.registerId < ExecutionNode::MaxRegisterId);
|
||||
inRegsCur.push_back(it->second.registerId);
|
||||
}
|
||||
|
@ -1062,7 +1062,7 @@ AqlItemBlock* IndexRangeBlock::getSome (size_t, // atLeast
|
|||
|
||||
if (toSend > 0) {
|
||||
|
||||
res.reset(new AqlItemBlock(toSend, getPlanNode()->getVarOverview()->nrRegs[getPlanNode()->getDepth()]));
|
||||
res.reset(new AqlItemBlock(toSend, getPlanNode()->getRegisterPlan()->nrRegs[getPlanNode()->getDepth()]));
|
||||
|
||||
// automatically freed should we throw
|
||||
TRI_ASSERT(curRegs <= res->getNrRegs());
|
||||
|
@ -1084,7 +1084,7 @@ AqlItemBlock* IndexRangeBlock::getSome (size_t, // atLeast
|
|||
}
|
||||
|
||||
// The result is in the first variable of this depth,
|
||||
// we do not need to do a lookup in getPlanNode()->_varOverview->varInfo,
|
||||
// we do not need to do a lookup in getPlanNode()->_registerPlan->varInfo,
|
||||
// but can just take cur->getNrRegs() as registerId:
|
||||
res->setValue(j, static_cast<triagens::aql::RegisterId>(curRegs),
|
||||
AqlValue(reinterpret_cast<TRI_df_marker_t
|
||||
|
@ -1506,8 +1506,8 @@ EnumerateListBlock::EnumerateListBlock (ExecutionEngine* engine,
|
|||
: ExecutionBlock(engine, en),
|
||||
_inVarRegId(ExecutionNode::MaxRegisterId) {
|
||||
|
||||
auto it = en->getVarOverview()->varInfo.find(en->_inVariable->id);
|
||||
if (it == en->getVarOverview()->varInfo.end()){
|
||||
auto it = en->getRegisterPlan()->varInfo.find(en->_inVariable->id);
|
||||
if (it == en->getRegisterPlan()->varInfo.end()){
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "variable not found");
|
||||
}
|
||||
_inVarRegId = (*it).second.registerId;
|
||||
|
@ -1620,7 +1620,7 @@ AqlItemBlock* EnumerateListBlock::getSome (size_t, size_t atMost) {
|
|||
size_t toSend = (std::min)(atMost, sizeInVar - _index);
|
||||
|
||||
// create the result
|
||||
res.reset(new AqlItemBlock(toSend, getPlanNode()->getVarOverview()->nrRegs[getPlanNode()->getDepth()]));
|
||||
res.reset(new AqlItemBlock(toSend, getPlanNode()->getRegisterPlan()->nrRegs[getPlanNode()->getDepth()]));
|
||||
|
||||
inheritRegisters(cur, res.get(), _pos);
|
||||
|
||||
|
@ -1794,9 +1794,9 @@ CalculationBlock::CalculationBlock (ExecutionEngine* engine,
|
|||
|
||||
for (auto it = inVars.begin(); it != inVars.end(); ++it) {
|
||||
_inVars.push_back(*it);
|
||||
auto it2 = en->getVarOverview()->varInfo.find((*it)->id);
|
||||
auto it2 = en->getRegisterPlan()->varInfo.find((*it)->id);
|
||||
|
||||
TRI_ASSERT(it2 != en->getVarOverview()->varInfo.end());
|
||||
TRI_ASSERT(it2 != en->getRegisterPlan()->varInfo.end());
|
||||
TRI_ASSERT(it2->second.registerId < ExecutionNode::MaxRegisterId);
|
||||
_inRegs.push_back(it2->second.registerId);
|
||||
}
|
||||
|
@ -1809,8 +1809,8 @@ CalculationBlock::CalculationBlock (ExecutionEngine* engine,
|
|||
TRI_ASSERT(_inRegs.size() == 1);
|
||||
}
|
||||
|
||||
auto it3 = en->getVarOverview()->varInfo.find(en->_outVariable->id);
|
||||
TRI_ASSERT(it3 != en->getVarOverview()->varInfo.end());
|
||||
auto it3 = en->getRegisterPlan()->varInfo.find(en->_outVariable->id);
|
||||
TRI_ASSERT(it3 != en->getRegisterPlan()->varInfo.end());
|
||||
_outReg = it3->second.registerId;
|
||||
TRI_ASSERT(_outReg < ExecutionNode::MaxRegisterId);
|
||||
}
|
||||
|
@ -1905,8 +1905,8 @@ SubqueryBlock::SubqueryBlock (ExecutionEngine* engine,
|
|||
_outReg(ExecutionNode::MaxRegisterId),
|
||||
_subquery(subquery) {
|
||||
|
||||
auto it = en->getVarOverview()->varInfo.find(en->_outVariable->id);
|
||||
TRI_ASSERT(it != en->getVarOverview()->varInfo.end());
|
||||
auto it = en->getRegisterPlan()->varInfo.find(en->_outVariable->id);
|
||||
TRI_ASSERT(it != en->getRegisterPlan()->varInfo.end());
|
||||
_outReg = it->second.registerId;
|
||||
TRI_ASSERT(_outReg < ExecutionNode::MaxRegisterId);
|
||||
}
|
||||
|
@ -1973,8 +1973,8 @@ FilterBlock::FilterBlock (ExecutionEngine* engine,
|
|||
: ExecutionBlock(engine, en),
|
||||
_inReg(ExecutionNode::MaxRegisterId) {
|
||||
|
||||
auto it = en->getVarOverview()->varInfo.find(en->_inVariable->id);
|
||||
TRI_ASSERT(it != en->getVarOverview()->varInfo.end());
|
||||
auto it = en->getRegisterPlan()->varInfo.find(en->_inVariable->id);
|
||||
TRI_ASSERT(it != en->getRegisterPlan()->varInfo.end());
|
||||
_inReg = it->second.registerId;
|
||||
TRI_ASSERT(_inReg < ExecutionNode::MaxRegisterId);
|
||||
}
|
||||
|
@ -2154,33 +2154,33 @@ AggregateBlock::AggregateBlock (ExecutionEngine* engine,
|
|||
|
||||
for (auto p : en->_aggregateVariables) {
|
||||
// We know that planRegisters() has been run, so
|
||||
// getPlanNode()->_varOverview is set up
|
||||
auto itOut = en->getVarOverview()->varInfo.find(p.first->id);
|
||||
TRI_ASSERT(itOut != en->getVarOverview()->varInfo.end());
|
||||
// getPlanNode()->_registerPlan is set up
|
||||
auto itOut = en->getRegisterPlan()->varInfo.find(p.first->id);
|
||||
TRI_ASSERT(itOut != en->getRegisterPlan()->varInfo.end());
|
||||
|
||||
auto itIn = en->getVarOverview()->varInfo.find(p.second->id);
|
||||
TRI_ASSERT(itIn != en->getVarOverview()->varInfo.end());
|
||||
auto itIn = en->getRegisterPlan()->varInfo.find(p.second->id);
|
||||
TRI_ASSERT(itIn != en->getRegisterPlan()->varInfo.end());
|
||||
TRI_ASSERT((*itIn).second.registerId < ExecutionNode::MaxRegisterId);
|
||||
TRI_ASSERT((*itOut).second.registerId < ExecutionNode::MaxRegisterId);
|
||||
_aggregateRegisters.emplace_back(make_pair((*itOut).second.registerId, (*itIn).second.registerId));
|
||||
}
|
||||
|
||||
if (en->_outVariable != nullptr) {
|
||||
auto it = en->getVarOverview()->varInfo.find(en->_outVariable->id);
|
||||
TRI_ASSERT(it != en->getVarOverview()->varInfo.end());
|
||||
auto it = en->getRegisterPlan()->varInfo.find(en->_outVariable->id);
|
||||
TRI_ASSERT(it != en->getRegisterPlan()->varInfo.end());
|
||||
_groupRegister = (*it).second.registerId;
|
||||
TRI_ASSERT(_groupRegister > 0 && _groupRegister < ExecutionNode::MaxRegisterId);
|
||||
|
||||
// construct a mapping of all register ids to variable names
|
||||
// we need this mapping to generate the grouped output
|
||||
|
||||
for (size_t i = 0; i < en->getVarOverview()->varInfo.size(); ++i) {
|
||||
for (size_t i = 0; i < en->getRegisterPlan()->varInfo.size(); ++i) {
|
||||
_variableNames.push_back(""); // initialize with some default value
|
||||
}
|
||||
|
||||
// iterate over all our variables
|
||||
for (auto it = en->getVarOverview()->varInfo.begin();
|
||||
it != en->getVarOverview()->varInfo.end(); ++it) {
|
||||
for (auto it = en->getRegisterPlan()->varInfo.begin();
|
||||
it != en->getRegisterPlan()->varInfo.end(); ++it) {
|
||||
// find variable in the global variable map
|
||||
auto itVar = en->_variableMap.find((*it).first);
|
||||
|
||||
|
@ -2239,7 +2239,7 @@ int AggregateBlock::getOrSkipSome (size_t atLeast,
|
|||
unique_ptr<AqlItemBlock> res;
|
||||
|
||||
if (! skipping) {
|
||||
res.reset(new AqlItemBlock(atMost, getPlanNode()->getVarOverview()->nrRegs[getPlanNode()->getDepth()]));
|
||||
res.reset(new AqlItemBlock(atMost, getPlanNode()->getRegisterPlan()->nrRegs[getPlanNode()->getDepth()]));
|
||||
|
||||
TRI_ASSERT(cur->getNrRegs() <= res->getNrRegs());
|
||||
inheritRegisters(cur, res.get(), _pos);
|
||||
|
@ -2402,8 +2402,8 @@ SortBlock::SortBlock (ExecutionEngine* engine,
|
|||
_stable(en->_stable) {
|
||||
|
||||
for (auto p : en->_elements) {
|
||||
auto it = en->getVarOverview()->varInfo.find(p.first->id);
|
||||
TRI_ASSERT(it != en->getVarOverview()->varInfo.end());
|
||||
auto it = en->getRegisterPlan()->varInfo.find(p.first->id);
|
||||
TRI_ASSERT(it != en->getRegisterPlan()->varInfo.end());
|
||||
TRI_ASSERT(it->second.registerId < ExecutionNode::MaxRegisterId);
|
||||
_sortRegisters.push_back(make_pair(it->second.registerId, p.second));
|
||||
}
|
||||
|
@ -2698,8 +2698,8 @@ AqlItemBlock* ReturnBlock::getSome (size_t atLeast,
|
|||
|
||||
// Let's steal the actual result and throw away the vars:
|
||||
auto ep = static_cast<ReturnNode const*>(getPlanNode());
|
||||
auto it = ep->getVarOverview()->varInfo.find(ep->_inVariable->id);
|
||||
TRI_ASSERT(it != ep->getVarOverview()->varInfo.end());
|
||||
auto it = ep->getRegisterPlan()->varInfo.find(ep->_inVariable->id);
|
||||
TRI_ASSERT(it != ep->getRegisterPlan()->varInfo.end());
|
||||
RegisterId const registerId = it->second.registerId;
|
||||
AqlItemBlock* stripped = new AqlItemBlock(n, 1);
|
||||
|
||||
|
@ -2852,8 +2852,8 @@ RemoveBlock::~RemoveBlock () {
|
|||
|
||||
void RemoveBlock::work (std::vector<AqlItemBlock*>& blocks) {
|
||||
auto ep = static_cast<RemoveNode const*>(getPlanNode());
|
||||
auto it = ep->getVarOverview()->varInfo.find(ep->_inVariable->id);
|
||||
TRI_ASSERT(it != ep->getVarOverview()->varInfo.end());
|
||||
auto it = ep->getRegisterPlan()->varInfo.find(ep->_inVariable->id);
|
||||
TRI_ASSERT(it != ep->getRegisterPlan()->varInfo.end());
|
||||
RegisterId const registerId = it->second.registerId;
|
||||
|
||||
auto trxCollection = _trx->trxCollection(_collection->cid());
|
||||
|
@ -2929,8 +2929,8 @@ InsertBlock::~InsertBlock () {
|
|||
|
||||
void InsertBlock::work (std::vector<AqlItemBlock*>& blocks) {
|
||||
auto ep = static_cast<InsertNode const*>(getPlanNode());
|
||||
auto it = ep->getVarOverview()->varInfo.find(ep->_inVariable->id);
|
||||
TRI_ASSERT(it != ep->getVarOverview()->varInfo.end());
|
||||
auto it = ep->getRegisterPlan()->varInfo.find(ep->_inVariable->id);
|
||||
TRI_ASSERT(it != ep->getRegisterPlan()->varInfo.end());
|
||||
RegisterId const registerId = it->second.registerId;
|
||||
|
||||
auto trxCollection = _trx->trxCollection(_collection->cid());
|
||||
|
@ -3041,16 +3041,16 @@ UpdateBlock::~UpdateBlock () {
|
|||
|
||||
void UpdateBlock::work (std::vector<AqlItemBlock*>& blocks) {
|
||||
auto ep = static_cast<UpdateNode const*>(getPlanNode());
|
||||
auto it = ep->getVarOverview()->varInfo.find(ep->_inDocVariable->id);
|
||||
TRI_ASSERT(it != ep->getVarOverview()->varInfo.end());
|
||||
auto it = ep->getRegisterPlan()->varInfo.find(ep->_inDocVariable->id);
|
||||
TRI_ASSERT(it != ep->getRegisterPlan()->varInfo.end());
|
||||
RegisterId const docRegisterId = it->second.registerId;
|
||||
RegisterId keyRegisterId = 0; // default initialization
|
||||
|
||||
bool const hasKeyVariable = (ep->_inKeyVariable != nullptr);
|
||||
|
||||
if (hasKeyVariable) {
|
||||
it = ep->getVarOverview()->varInfo.find(ep->_inKeyVariable->id);
|
||||
TRI_ASSERT(it != ep->getVarOverview()->varInfo.end());
|
||||
it = ep->getRegisterPlan()->varInfo.find(ep->_inKeyVariable->id);
|
||||
TRI_ASSERT(it != ep->getRegisterPlan()->varInfo.end());
|
||||
keyRegisterId = it->second.registerId;
|
||||
}
|
||||
|
||||
|
@ -3159,16 +3159,16 @@ ReplaceBlock::~ReplaceBlock () {
|
|||
|
||||
void ReplaceBlock::work (std::vector<AqlItemBlock*>& blocks) {
|
||||
auto ep = static_cast<ReplaceNode const*>(getPlanNode());
|
||||
auto it = ep->getVarOverview()->varInfo.find(ep->_inDocVariable->id);
|
||||
TRI_ASSERT(it != ep->getVarOverview()->varInfo.end());
|
||||
auto it = ep->getRegisterPlan()->varInfo.find(ep->_inDocVariable->id);
|
||||
TRI_ASSERT(it != ep->getRegisterPlan()->varInfo.end());
|
||||
RegisterId const registerId = it->second.registerId;
|
||||
RegisterId keyRegisterId = 0; // default initialization
|
||||
|
||||
bool const hasKeyVariable = (ep->_inKeyVariable != nullptr);
|
||||
|
||||
if (hasKeyVariable) {
|
||||
it = ep->getVarOverview()->varInfo.find(ep->_inKeyVariable->id);
|
||||
TRI_ASSERT(it != ep->getVarOverview()->varInfo.end());
|
||||
it = ep->getRegisterPlan()->varInfo.find(ep->_inKeyVariable->id);
|
||||
TRI_ASSERT(it != ep->getRegisterPlan()->varInfo.end());
|
||||
keyRegisterId = it->second.registerId;
|
||||
}
|
||||
|
||||
|
@ -3265,9 +3265,9 @@ GatherBlock::GatherBlock (ExecutionEngine* engine,
|
|||
if (! _isSimple) {
|
||||
for (auto p : en->getElements()) {
|
||||
// We know that planRegisters has been run, so
|
||||
// getPlanNode()->_varOverview is set up
|
||||
auto it = en->getVarOverview()->varInfo.find(p.first->id);
|
||||
TRI_ASSERT(it != en->getVarOverview()->varInfo.end());
|
||||
// getPlanNode()->_registerPlan is set up
|
||||
auto it = en->getRegisterPlan()->varInfo.find(p.first->id);
|
||||
TRI_ASSERT(it != en->getRegisterPlan()->varInfo.end());
|
||||
TRI_ASSERT(it->second.registerId < ExecutionNode::MaxRegisterId);
|
||||
_sortRegisters.emplace_back(make_pair(it->second.registerId, p.second));
|
||||
}
|
||||
|
@ -3821,7 +3821,7 @@ bool BlockWithClients::preInitCursor () {
|
|||
|
||||
int ScatterBlock::initializeCursor (AqlItemBlock* items, size_t pos) {
|
||||
|
||||
if (!preInitCursor()) {
|
||||
if (! preInitCursor()) {
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -3842,7 +3842,7 @@ int ScatterBlock::initializeCursor (AqlItemBlock* items, size_t pos) {
|
|||
/// @brief hasMoreForShard: any more for shard <shardId>?
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool ScatterBlock::hasMoreForShard (std::string const& shardId){
|
||||
bool ScatterBlock::hasMoreForShard (std::string const& shardId) {
|
||||
size_t clientId = getClientId(shardId);
|
||||
|
||||
if (_doneForClient.at(clientId)) {
|
||||
|
@ -3897,7 +3897,7 @@ int64_t ScatterBlock::remainingForShard (std::string const& shardId) {
|
|||
|
||||
int ScatterBlock::getOrSkipSomeForShard (size_t atLeast,
|
||||
size_t atMost, bool skipping, AqlItemBlock*& result,
|
||||
size_t& skipped, std::string const& shardId){
|
||||
size_t& skipped, std::string const& shardId) {
|
||||
|
||||
TRI_ASSERT(0 < atLeast && atLeast <= atMost);
|
||||
TRI_ASSERT(result == nullptr && skipped == 0);
|
||||
|
@ -3967,15 +3967,15 @@ DistributeBlock::DistributeBlock (ExecutionEngine* engine,
|
|||
DistributeNode const* ep,
|
||||
std::vector<std::string> const& shardIds,
|
||||
Collection const* collection)
|
||||
: BlockWithClients(engine, ep, shardIds),
|
||||
_collection(collection) {
|
||||
: BlockWithClients(engine, ep, shardIds),
|
||||
_collection(collection) {
|
||||
|
||||
// get the variable to inspect . . .
|
||||
VariableId varId = ep->_varId;
|
||||
|
||||
// get the register id of the variable to inspect . . .
|
||||
auto it = ep->getVarOverview()->varInfo.find(varId);
|
||||
TRI_ASSERT(it != ep->getVarOverview()->varInfo.end());
|
||||
auto it = ep->getRegisterPlan()->varInfo.find(varId);
|
||||
TRI_ASSERT(it != ep->getRegisterPlan()->varInfo.end());
|
||||
_regId = (*it).second.registerId;
|
||||
}
|
||||
|
||||
|
|
|
@ -1684,13 +1684,15 @@ namespace triagens {
|
|||
ScatterBlock (ExecutionEngine* engine,
|
||||
ScatterNode const* ep,
|
||||
std::vector<std::string> const& shardIds)
|
||||
: BlockWithClients(engine, ep, shardIds) {}
|
||||
: BlockWithClients(engine, ep, shardIds) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
~ScatterBlock () {}
|
||||
~ScatterBlock () {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initializeCursor
|
||||
|
@ -1755,7 +1757,8 @@ namespace triagens {
|
|||
/// @brief destructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
~DistributeBlock () {}
|
||||
~DistributeBlock () {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initializeCursor
|
||||
|
@ -1767,7 +1770,7 @@ namespace triagens {
|
|||
/// @brief remainingForShard: remaining for shard <shardId>?
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int64_t remainingForShard (std::string const& shardId){
|
||||
int64_t remainingForShard (std::string const& shardId) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -222,11 +222,11 @@ ExecutionNode::ExecutionNode (ExecutionPlan* plan,
|
|||
_plan(plan),
|
||||
_depth(JsonHelper::checkAndGetNumericValue<int>(json.json(), "depth")) {
|
||||
|
||||
TRI_ASSERT(_varOverview.get() == nullptr);
|
||||
_varOverview.reset(new VarOverview());
|
||||
_varOverview->clear();
|
||||
_varOverview->depth = _depth;
|
||||
_varOverview->totalNrRegs = JsonHelper::checkAndGetNumericValue<unsigned int>(json.json(), "totalNrRegs");
|
||||
TRI_ASSERT(_registerPlan.get() == nullptr);
|
||||
_registerPlan.reset(new RegisterPlan());
|
||||
_registerPlan->clear();
|
||||
_registerPlan->depth = _depth;
|
||||
_registerPlan->totalNrRegs = JsonHelper::checkAndGetNumericValue<unsigned int>(json.json(), "totalNrRegs");
|
||||
|
||||
auto jsonVarInfoList = json.get("varInfoList");
|
||||
if (! jsonVarInfoList.isList()) {
|
||||
|
@ -234,7 +234,7 @@ ExecutionNode::ExecutionNode (ExecutionPlan* plan,
|
|||
}
|
||||
|
||||
size_t len = jsonVarInfoList.size();
|
||||
_varOverview->varInfo.reserve(len);
|
||||
_registerPlan->varInfo.reserve(len);
|
||||
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
auto jsonVarInfo = jsonVarInfoList.at(i);
|
||||
|
@ -245,7 +245,7 @@ ExecutionNode::ExecutionNode (ExecutionPlan* plan,
|
|||
RegisterId registerId = JsonHelper::checkAndGetNumericValue<RegisterId> (jsonVarInfo.json(), "RegisterId");
|
||||
unsigned int depth = JsonHelper::checkAndGetNumericValue<unsigned int>(jsonVarInfo.json(), "depth");
|
||||
|
||||
_varOverview->varInfo.emplace(make_pair(variableId, VarInfo(depth, registerId)));
|
||||
_registerPlan->varInfo.emplace(make_pair(variableId, VarInfo(depth, registerId)));
|
||||
}
|
||||
|
||||
auto jsonNrRegsList = json.get("nrRegs");
|
||||
|
@ -254,10 +254,10 @@ ExecutionNode::ExecutionNode (ExecutionPlan* plan,
|
|||
}
|
||||
|
||||
len = jsonNrRegsList.size();
|
||||
_varOverview->nrRegs.reserve(len);
|
||||
_registerPlan->nrRegs.reserve(len);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
RegisterId oneReg = JsonHelper::getNumericValue<RegisterId>(jsonNrRegsList.at(i).json(), 0);
|
||||
_varOverview->nrRegs.push_back(oneReg);
|
||||
_registerPlan->nrRegs.push_back(oneReg);
|
||||
}
|
||||
|
||||
auto jsonNrRegsHereList = json.get("nrRegsHere");
|
||||
|
@ -266,10 +266,10 @@ ExecutionNode::ExecutionNode (ExecutionPlan* plan,
|
|||
}
|
||||
|
||||
len = jsonNrRegsHereList.size();
|
||||
_varOverview->nrRegsHere.reserve(len);
|
||||
_registerPlan->nrRegsHere.reserve(len);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
RegisterId oneReg = JsonHelper::getNumericValue<RegisterId>(jsonNrRegsHereList.at(i).json(), 0);
|
||||
_varOverview->nrRegsHere.push_back(oneReg);
|
||||
_registerPlan->nrRegsHere.push_back(oneReg);
|
||||
}
|
||||
|
||||
auto jsonRegsToClearList = json.get("regsToClear");
|
||||
|
@ -375,9 +375,9 @@ void ExecutionNode::CloneHelper (ExecutionNode* other,
|
|||
TRI_ASSERT(var != nullptr);
|
||||
other->_varsValid.insert(var);
|
||||
}
|
||||
if (_varOverview.get() != nullptr) {
|
||||
auto othervarOverview = std::shared_ptr<VarOverview>(_varOverview->clone(plan, _plan));
|
||||
other->_varOverview = othervarOverview;
|
||||
if (_registerPlan.get() != nullptr) {
|
||||
auto otherRegisterPlan = std::shared_ptr<RegisterPlan>(_registerPlan->clone(plan, _plan));
|
||||
other->_registerPlan = otherRegisterPlan;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -387,7 +387,7 @@ void ExecutionNode::CloneHelper (ExecutionNode* other,
|
|||
other->_varUsageValid = _varUsageValid;
|
||||
other->_varsUsedLater = _varsUsedLater;
|
||||
other->_varsValid = _varsValid;
|
||||
other->_varOverview = _varOverview;
|
||||
other->_registerPlan = _registerPlan;
|
||||
}
|
||||
plan->registerNode(other);
|
||||
|
||||
|
@ -636,9 +636,9 @@ triagens::basics::Json ExecutionNode::toJsonHelperGeneric (triagens::basics::Jso
|
|||
if (verbose) {
|
||||
json("depth", triagens::basics::Json(static_cast<double>(_depth)));
|
||||
|
||||
if (_varOverview) {
|
||||
triagens::basics::Json jsonVarInfoList(triagens::basics::Json::List, _varOverview->varInfo.size());
|
||||
for (auto oneVarInfo: _varOverview->varInfo) {
|
||||
if (_registerPlan) {
|
||||
triagens::basics::Json jsonVarInfoList(triagens::basics::Json::List, _registerPlan->varInfo.size());
|
||||
for (auto oneVarInfo: _registerPlan->varInfo) {
|
||||
triagens::basics::Json jsonOneVarInfoArray(triagens::basics::Json::Array, 2);
|
||||
jsonOneVarInfoArray(
|
||||
"VariableId",
|
||||
|
@ -650,18 +650,18 @@ triagens::basics::Json ExecutionNode::toJsonHelperGeneric (triagens::basics::Jso
|
|||
}
|
||||
json("varInfoList", jsonVarInfoList);
|
||||
|
||||
triagens::basics::Json jsonNRRegsList(triagens::basics::Json::List, _varOverview->nrRegs.size());
|
||||
for (auto oneRegisterID: _varOverview->nrRegs) {
|
||||
triagens::basics::Json jsonNRRegsList(triagens::basics::Json::List, _registerPlan->nrRegs.size());
|
||||
for (auto oneRegisterID: _registerPlan->nrRegs) {
|
||||
jsonNRRegsList(triagens::basics::Json(static_cast<double>(oneRegisterID)));
|
||||
}
|
||||
json("nrRegs", jsonNRRegsList);
|
||||
|
||||
triagens::basics::Json jsonNRRegsHereList(triagens::basics::Json::List, _varOverview->nrRegsHere.size());
|
||||
for (auto oneRegisterID: _varOverview->nrRegsHere) {
|
||||
triagens::basics::Json jsonNRRegsHereList(triagens::basics::Json::List, _registerPlan->nrRegsHere.size());
|
||||
for (auto oneRegisterID: _registerPlan->nrRegsHere) {
|
||||
jsonNRRegsHereList(triagens::basics::Json(static_cast<double>(oneRegisterID)));
|
||||
}
|
||||
json("nrRegsHere", jsonNRRegsHereList);
|
||||
json("totalNrRegs", triagens::basics::Json(static_cast<double>(_varOverview->totalNrRegs)));
|
||||
json("totalNrRegs", triagens::basics::Json(static_cast<double>(_registerPlan->totalNrRegs)));
|
||||
}
|
||||
else {
|
||||
json("varInfoList", triagens::basics::Json(triagens::basics::Json::List));
|
||||
|
@ -719,12 +719,12 @@ struct RegisterPlanningDebugger : public WalkerWorker<ExecutionNode> {
|
|||
std::cout << ep->getTypeString() << " ";
|
||||
std::cout << "regsUsedHere: ";
|
||||
for (auto v : ep->getVariablesUsedHere()) {
|
||||
std::cout << ep->getVarOverview()->varInfo.find(v->id)->second.registerId
|
||||
std::cout << ep->getRegisterPlan()->varInfo.find(v->id)->second.registerId
|
||||
<< " ";
|
||||
}
|
||||
std::cout << "regsSetHere: ";
|
||||
for (auto v : ep->getVariablesSetHere()) {
|
||||
std::cout << ep->getVarOverview()->varInfo.find(v->id)->second.registerId
|
||||
std::cout << ep->getRegisterPlan()->varInfo.find(v->id)->second.registerId
|
||||
<< " ";
|
||||
}
|
||||
std::cout << "regsToClear: ";
|
||||
|
@ -742,12 +742,12 @@ struct RegisterPlanningDebugger : public WalkerWorker<ExecutionNode> {
|
|||
void ExecutionNode::planRegisters (ExecutionNode* super) {
|
||||
// std::cout << triagens::arango::ServerState::instance()->getId() << ": PLAN REGISTERS\n";
|
||||
// The super is only for the case of subqueries.
|
||||
shared_ptr<VarOverview> v;
|
||||
shared_ptr<RegisterPlan> v;
|
||||
if (super == nullptr) {
|
||||
v.reset(new VarOverview());
|
||||
v.reset(new RegisterPlan());
|
||||
}
|
||||
else {
|
||||
v.reset(new VarOverview(*(super->_varOverview), super->_depth));
|
||||
v.reset(new RegisterPlan(*(super->_registerPlan), super->_depth));
|
||||
}
|
||||
v->setSharedPtr(&v);
|
||||
|
||||
|
@ -769,12 +769,12 @@ void ExecutionNode::planRegisters (ExecutionNode* super) {
|
|||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- struct ExecutionNode::VarOverview
|
||||
// --SECTION-- struct ExecutionNode::RegisterPlan
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Copy constructor used for a subquery:
|
||||
ExecutionNode::VarOverview::VarOverview (VarOverview const& v,
|
||||
unsigned int newdepth)
|
||||
ExecutionNode::RegisterPlan::RegisterPlan (RegisterPlan const& v,
|
||||
unsigned int newdepth)
|
||||
: varInfo(v.varInfo),
|
||||
nrRegsHere(v.nrRegsHere),
|
||||
nrRegs(v.nrRegs),
|
||||
|
@ -788,7 +788,7 @@ ExecutionNode::VarOverview::VarOverview (VarOverview const& v,
|
|||
nrRegs.push_back(nrRegs.back());
|
||||
}
|
||||
|
||||
void ExecutionNode::VarOverview::clear () {
|
||||
void ExecutionNode::RegisterPlan::clear () {
|
||||
varInfo.clear();
|
||||
nrRegsHere.clear();
|
||||
nrRegs.clear();
|
||||
|
@ -797,8 +797,8 @@ void ExecutionNode::VarOverview::clear () {
|
|||
totalNrRegs = 0;
|
||||
}
|
||||
|
||||
ExecutionNode::VarOverview* ExecutionNode::VarOverview::clone (ExecutionPlan* otherPlan, ExecutionPlan* plan) {
|
||||
VarOverview* other = new VarOverview();
|
||||
ExecutionNode::RegisterPlan* ExecutionNode::RegisterPlan::clone (ExecutionPlan* otherPlan, ExecutionPlan* plan) {
|
||||
std::unique_ptr<RegisterPlan> other(new RegisterPlan());
|
||||
|
||||
other->nrRegsHere = nrRegsHere;
|
||||
other->nrRegs = nrRegs;
|
||||
|
@ -807,17 +807,13 @@ ExecutionNode::VarOverview* ExecutionNode::VarOverview::clone (ExecutionPlan* ot
|
|||
|
||||
other->varInfo = varInfo;
|
||||
|
||||
/* we don't need these.
|
||||
for (auto en: subQueryNodes) {
|
||||
auto otherId = en->id();
|
||||
auto otherEN = otherPlan->getNodeById(otherId);
|
||||
other->subQueryNodes.push_back(otherEN);
|
||||
}
|
||||
*/
|
||||
return other;
|
||||
// No need to clone subQueryNodes because this was only used during
|
||||
// the buildup.
|
||||
|
||||
return other.release();
|
||||
}
|
||||
|
||||
void ExecutionNode::VarOverview::after (ExecutionNode *en) {
|
||||
void ExecutionNode::RegisterPlan::after (ExecutionNode *en) {
|
||||
switch (en->getType()) {
|
||||
case ExecutionNode::ENUMERATE_COLLECTION:
|
||||
case ExecutionNode::INDEX_RANGE: {
|
||||
|
@ -968,7 +964,7 @@ void ExecutionNode::VarOverview::after (ExecutionNode *en) {
|
|||
}
|
||||
|
||||
en->_depth = depth;
|
||||
en->_varOverview = *me;
|
||||
en->_registerPlan = *me;
|
||||
|
||||
// Now find out which registers ought to be erased after this node:
|
||||
if (en->getType() != ExecutionNode::RETURN) {
|
||||
|
|
|
@ -513,7 +513,7 @@ namespace triagens {
|
|||
}
|
||||
};
|
||||
|
||||
struct VarOverview : public WalkerWorker<ExecutionNode> {
|
||||
struct RegisterPlan : public WalkerWorker<ExecutionNode> {
|
||||
// The following are collected for global usage in the ExecutionBlock,
|
||||
// although they are stored here in the node:
|
||||
|
||||
|
@ -536,10 +536,14 @@ namespace triagens {
|
|||
unsigned int depth;
|
||||
unsigned int totalNrRegs;
|
||||
|
||||
// This is used to tell all nodes and share a pointer to ourselves
|
||||
shared_ptr<VarOverview>* me;
|
||||
private:
|
||||
|
||||
VarOverview ()
|
||||
// This is used to tell all nodes and share a pointer to ourselves
|
||||
shared_ptr<RegisterPlan>* me;
|
||||
|
||||
public:
|
||||
|
||||
RegisterPlan ()
|
||||
: depth(0), totalNrRegs(0), me(nullptr) {
|
||||
nrRegsHere.push_back(0);
|
||||
nrRegs.push_back(0);
|
||||
|
@ -547,13 +551,13 @@ namespace triagens {
|
|||
|
||||
void clear ();
|
||||
|
||||
void setSharedPtr (shared_ptr<VarOverview>* shared) {
|
||||
void setSharedPtr (shared_ptr<RegisterPlan>* shared) {
|
||||
me = shared;
|
||||
}
|
||||
|
||||
// Copy constructor used for a subquery:
|
||||
VarOverview (VarOverview const& v, unsigned int newdepth);
|
||||
~VarOverview () {};
|
||||
RegisterPlan (RegisterPlan const& v, unsigned int newdepth);
|
||||
~RegisterPlan () {};
|
||||
|
||||
virtual bool enterSubquery (ExecutionNode*,
|
||||
ExecutionNode*) {
|
||||
|
@ -562,7 +566,7 @@ namespace triagens {
|
|||
|
||||
virtual void after (ExecutionNode *eb);
|
||||
|
||||
VarOverview* clone(ExecutionPlan* otherPlan, ExecutionPlan* plan);
|
||||
RegisterPlan* clone(ExecutionPlan* otherPlan, ExecutionPlan* plan);
|
||||
|
||||
};
|
||||
|
||||
|
@ -573,12 +577,12 @@ namespace triagens {
|
|||
void planRegisters (ExecutionNode* super = nullptr);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get varOverview
|
||||
/// @brief get RegisterPlan
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VarOverview const* getVarOverview () const {
|
||||
TRI_ASSERT(_varOverview.get() != nullptr);
|
||||
return _varOverview.get();
|
||||
RegisterPlan const* getRegisterPlan () const {
|
||||
TRI_ASSERT(_registerPlan.get() != nullptr);
|
||||
return _registerPlan.get();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -702,7 +706,7 @@ namespace triagens {
|
|||
/// @brief info about variables, filled in by planRegisters
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::shared_ptr<VarOverview> _varOverview;
|
||||
std::shared_ptr<RegisterPlan> _registerPlan;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief depth of the current frame, will be filled in by planRegisters
|
||||
|
|
|
@ -280,7 +280,7 @@ static int SetupExampleObject (v8::Handle<v8::Object> const example,
|
|||
static TRI_index_operator_t* SetupConditionsSkiplist (TRI_index_t* idx,
|
||||
TRI_shaper_t* shaper,
|
||||
v8::Handle<v8::Object> conditions) {
|
||||
TRI_index_operator_t* lastOperator = 0;
|
||||
TRI_index_operator_t* lastOperator = nullptr;
|
||||
size_t numEq = 0;
|
||||
size_t lastNonEq = 0;
|
||||
|
||||
|
@ -449,7 +449,7 @@ static TRI_index_operator_t* SetupConditionsSkiplist (TRI_index_t* idx,
|
|||
MEM_ERROR:
|
||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, parameters);
|
||||
|
||||
if (lastOperator == nullptr) {
|
||||
if (lastOperator != nullptr) {
|
||||
TRI_FreeIndexOperator(lastOperator);
|
||||
}
|
||||
|
||||
|
|
|
@ -411,8 +411,8 @@
|
|||
|
||||
this.collection.each(function(model) {
|
||||
self.customQueries.push({
|
||||
name: model.attributes.name,
|
||||
value: model.attributes.value
|
||||
name: model.get("name"),
|
||||
value: model.get("value")
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
|
@ -4589,7 +4589,6 @@ function TRAVERSAL_VISITOR (config, result, vertex, path) {
|
|||
|
||||
function TRAVERSAL_NEIGHBOR_VISITOR (config, result, vertex, path) {
|
||||
"use strict";
|
||||
|
||||
result.push(CLONE({ vertex: vertex, path: path, startVertex : config.startVertex }));
|
||||
}
|
||||
|
||||
|
@ -4653,10 +4652,23 @@ function TRAVERSAL_EDGE_EXAMPLE_FILTER (config, vertex, edge, path) {
|
|||
|
||||
function TRAVERSAL_VERTEX_FILTER (config, vertex, path) {
|
||||
"use strict";
|
||||
|
||||
if (! MATCHES(vertex, config.filterVertexExamples)) {
|
||||
if (config.filterVertexExamples && !MATCHES(vertex, config.filterVertexExamples)) {
|
||||
if (config.filterVertexCollections
|
||||
&& config.vertexFilterMethod.indexOf("exclude") === -1
|
||||
&& config.filterVertexCollections.indexOf(vertex._id.split("/")[0]) === -1
|
||||
) {
|
||||
if (config.vertexFilterMethod.indexOf("prune") === -1) {
|
||||
return ["exclude"];
|
||||
}
|
||||
return ["prune", "exclude"];
|
||||
}
|
||||
return config.vertexFilterMethod;
|
||||
}
|
||||
if (config.filterVertexCollections
|
||||
&& config.filterVertexCollections.indexOf(vertex._id.split("/")[0]) === -1
|
||||
){
|
||||
return ["exclude"];
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -4789,6 +4801,11 @@ function TRAVERSAL_FUNC (func,
|
|||
config.vertexFilterMethod = params.vertexFilterMethod || ["prune", "exclude"];
|
||||
}
|
||||
}
|
||||
if (params.filterVertexCollections) {
|
||||
config.filter = config.filter || TRAVERSAL_VERTEX_FILTER;
|
||||
config.vertexFilterMethod = config.vertexFilterMethod || ["prune", "exclude"];
|
||||
config.filterVertexCollections = params.filterVertexCollections;
|
||||
}
|
||||
|
||||
if (params._sort) {
|
||||
config.sort = function (l, r) { return l._key < r._key ? -1 : 1; };
|
||||
|
@ -6020,8 +6037,8 @@ function GRAPH_NEIGHBORS (vertexCollection,
|
|||
/// * *edgeCollectionRestriction* : One or multiple edge
|
||||
/// collection names. Only edges from these collections will be considered for the path.
|
||||
/// * *vertexCollectionRestriction* : One or multiple vertex
|
||||
/// collection names. Only vertices from these collections will be considered as
|
||||
/// neighbor.
|
||||
/// collection names. Only vertices from these collections will be contained in the
|
||||
/// result. This does not effect vertices on the path.
|
||||
/// * *minDepth* : Defines the minimal
|
||||
/// depth a path to a neighbor must have to be returned (default is 1).
|
||||
/// * *maxDepth* : Defines the maximal
|
||||
|
@ -6064,21 +6081,12 @@ function GENERAL_GRAPH_NEIGHBORS (graphName,
|
|||
}
|
||||
|
||||
options.fromVertexExample = vertexExample;
|
||||
if (! options.direction) {
|
||||
if (! options.hasOwnProperty("direction")) {
|
||||
options.direction = 'any';
|
||||
}
|
||||
|
||||
if (options.vertexCollectionRestriction) {
|
||||
if (options.direction === "inbound") {
|
||||
options.endVertexCollectionRestriction = options.vertexCollectionRestriction;
|
||||
} else {
|
||||
options.startVertexCollectionRestriction = options.vertexCollectionRestriction;
|
||||
}
|
||||
}
|
||||
if (options.neighborExamples) {
|
||||
if (typeof options.neighborExamples === "string") {
|
||||
options.neighborExamples = {_id : options.neighborExamples};
|
||||
}
|
||||
if (options.hasOwnProperty("neighborExamples") && typeof options.neighborExamples === "string") {
|
||||
options.neighborExamples = {_id : options.neighborExamples};
|
||||
}
|
||||
var neighbors = [],
|
||||
params = TRAVERSAL_PARAMS(),
|
||||
|
@ -6094,6 +6102,9 @@ function GENERAL_GRAPH_NEIGHBORS (graphName,
|
|||
if (options.edgeCollectionRestriction) {
|
||||
params.edgeCollectionRestriction = options.edgeCollectionRestriction;
|
||||
}
|
||||
if (options.vertexCollectionRestriction) {
|
||||
params.filterVertexCollections = options.vertexCollectionRestriction;
|
||||
}
|
||||
fromVertices.forEach(function (v) {
|
||||
var e = TRAVERSAL_FUNC("GRAPH_NEIGHBORS",
|
||||
factory,
|
||||
|
|
|
@ -33,6 +33,7 @@ var TRAVERSAL = require("org/arangodb/graph/traversal");
|
|||
var ArangoError = require("org/arangodb").ArangoError;
|
||||
var ShapedJson = INTERNAL.ShapedJson;
|
||||
var isCoordinator = require("org/arangodb/cluster").isCoordinator();
|
||||
var console = require("console");
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private variables
|
||||
|
@ -491,9 +492,14 @@ function FCALL_USER (name, parameters) {
|
|||
}
|
||||
|
||||
if (UserFunctions[prefix].hasOwnProperty(name)) {
|
||||
var result = UserFunctions[prefix][name].func.apply(null, parameters);
|
||||
|
||||
return FIX_VALUE(result);
|
||||
try {
|
||||
var result = UserFunctions[prefix][name].func.apply(null, parameters);
|
||||
return FIX_VALUE(result);
|
||||
}
|
||||
catch (err) {
|
||||
console.warn("AQL user function '%s' returned an exception. result is converted to null", name);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
THROW(INTERNAL.errors.ERROR_QUERY_FUNCTION_NOT_FOUND, NORMALIZE_FNAME(name));
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue