1
0
Fork 0

Bug fix/smart joins (#9050)

This commit is contained in:
Jan 2019-05-21 17:49:12 +02:00 committed by GitHub
parent 6cea7528fb
commit 82b1e26686
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 1 deletions

View File

@ -327,6 +327,22 @@ void EngineInfoContainerDBServer::EngineInfo::serializeSnippet(
infoBuilder.add(VPackValue(arangodb::basics::StringUtils::itoa(_idOfRemoteNode) + ":" + id));
TRI_ASSERT(!_nodes.empty());
// build up a map of prototypes, e.g. c1 => c2, c2 => c3, c3 => c4,
// so we can determine a common prototype ancestor in case we have 3- or 4-way joins
std::unordered_map<aql::Collection const*, aql::Collection const*> prototypes;
for (auto enIt = _nodes.rbegin(), end = _nodes.rend(); enIt != end; ++enIt) {
auto const nodeType = (*enIt)->getType();
if (nodeType == ExecutionNode::INDEX || nodeType == ExecutionNode::ENUMERATE_COLLECTION) {
auto x = dynamic_cast<CollectionAccessingNode*>(*enIt);
auto const* prototype = x->prototypeCollection();
if (prototype == nullptr) {
continue;
}
prototypes[x->collection()] = prototype;
}
}
// copy the relevant fragment of the plan for each shard
// Note that in these parts of the query there are no SubqueryNodes,
// since they are all on the coordinator!
@ -336,6 +352,7 @@ void EngineInfoContainerDBServer::EngineInfo::serializeSnippet(
std::unordered_set<aql::Collection*> cleanup;
cleanup.emplace(collection->collection);
collection->collection->setCurrentShard(id);
ExecutionPlan plan(query.ast());
@ -353,6 +370,15 @@ void EngineInfoContainerDBServer::EngineInfo::serializeSnippet(
if (nodeType == ExecutionNode::INDEX || nodeType == ExecutionNode::ENUMERATE_COLLECTION) {
auto x = dynamic_cast<CollectionAccessingNode*>(clone);
auto const* prototype = x->prototypeCollection();
// find prototypes of prototypes
while (prototype != nullptr) {
auto it = prototypes.find(prototype);
if (it == prototypes.end()) {
break;
}
prototype = (*it).second;
}
if (prototype != nullptr) {
auto s1 = prototype->shardIds();
auto s2 = x->collection()->shardIds();

View File

@ -89,7 +89,11 @@ class ExecutionPlan {
}
/// @brief note that an optimizer rule was applied
inline void addAppliedRule(int level) { _appliedRules.emplace_back(level); }
inline void addAppliedRule(int level) {
if (_appliedRules.empty() || _appliedRules.back() != level) {
_appliedRules.emplace_back(level);
}
}
/// @brief get a list of all applied rules
std::vector<std::string> getAppliedRules() const;

View File

@ -65,6 +65,12 @@ ShardingInfo::ShardingInfo(arangodb::velocypack::Slice info, LogicalCollection*
"invalid number of shards");
}
}
VPackSlice distributeShardsLike = info.get(StaticStrings::DistributeShardsLike);
if (!distributeShardsLike.isNone() && !distributeShardsLike.isString()) {
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_BAD_PARAMETER,
"invalid non-string value for 'distributeShardsLike'");
}
VPackSlice v = info.get(StaticStrings::NumberOfShards);
if (!v.isNone() && !v.isNumber() && !v.isNull()) {