1
0
Fork 0

More updates

This commit is contained in:
Markus Pfeiffer 2019-09-12 16:58:52 +01:00
parent 4b9b530785
commit afd15ebc0e
9 changed files with 33 additions and 31 deletions

View File

@ -551,7 +551,7 @@ void ExecutionNode::cloneDependencies(ExecutionPlan* plan, ExecutionNode* theClo
} }
} }
bool ExecutionNode::isEqualTo(ExecutionNode const& other) { bool ExecutionNode::isEqualTo(ExecutionNode const& other) const {
meta::details::static_assert_size<ExecutionNode, 456>(); meta::details::static_assert_size<ExecutionNode, 456>();

View File

@ -334,7 +334,7 @@ class ExecutionNode {
void cloneDependencies(ExecutionPlan* plan, ExecutionNode* theClone, bool withProperties) const; void cloneDependencies(ExecutionPlan* plan, ExecutionNode* theClone, bool withProperties) const;
/// @brief check equality of ExecutionNodes /// @brief check equality of ExecutionNodes
virtual bool isEqualTo(ExecutionNode const& other); virtual bool isEqualTo(ExecutionNode const& other) const;
/// @brief invalidate the cost estimate for the node and its dependencies /// @brief invalidate the cost estimate for the node and its dependencies
virtual void invalidateCost(); virtual void invalidateCost();

View File

@ -4556,6 +4556,8 @@ void arangodb::aql::distributeSortToClusterRule(Optimizer* opt,
break; break;
} }
case EN::SUBQUERY_START:
case EN::SUBQUERY_END:
case EN::MAX_NODE_TYPE_VALUE: { case EN::MAX_NODE_TYPE_VALUE: {
// should not reach this point // should not reach this point
TRI_ASSERT(false); TRI_ASSERT(false);

View File

@ -74,18 +74,18 @@ void SubqueryEndNode::replaceOutVariable(Variable const* var) {
} }
CostEstimate SubqueryEndNode::estimateCost() const { CostEstimate SubqueryEndNode::estimateCost() const {
TRI_ASSERT(!_dependencies.size() == 1); TRI_ASSERT(_dependencies.size() == 1);
CostEstimate estimate = _dependencies.at(0)->getCost(); CostEstimate estimate = _dependencies.at(0)->getCost();
return estimate; return estimate;
} }
bool SubqueryEndNode::isEqualTo(SubqueryEndNode const& other) bool SubqueryEndNode::isEqualTo(SubqueryEndNode const& other) const
{ {
TRI_ASSERT(_outVariable); TRI_ASSERT(other->_outVariable); TRI_ASSERT(_outVariable != nullptr); TRI_ASSERT(other._outVariable != nullptr);
return ExecutionNode::isEqualTo(other) && return ExecutionNode::isEqualTo(other) &&
_outVariable->isEqualTo(*other->_outVariable); _outVariable->isEqualTo(*(other._outVariable));
} }
} // namespace aql } // namespace aql

View File

@ -57,7 +57,7 @@ class SubqueryEndNode : public ExecutionNode {
ExecutionNode* clone(ExecutionPlan* plan, bool withDependencies, ExecutionNode* clone(ExecutionPlan* plan, bool withDependencies,
bool withProperties) const override final; bool withProperties) const override final;
bool isEqualTo(SubqueryEndNode const &other); bool isEqualTo(SubqueryEndNode const &other) const;
std::vector<Variable const*> getVariablesSetHere() const override final { std::vector<Variable const*> getVariablesSetHere() const override final {
return std::vector<Variable const*>{_outVariable}; return std::vector<Variable const*>{_outVariable};

View File

@ -69,10 +69,6 @@ bool SubqueryStartNode::isEqualTo(SubqueryStartNode const& other) {
return ExecutionNode::isEqualTo(other); return ExecutionNode::isEqualTo(other);
} }
bool SubqueryStartNode::isEqualTo(SubqueryStartNode const* other) {
return ExecutionNode::isEqualTo(other);
}
} // namespace aql } // namespace aql
} // namespace arangodb } // namespace arangodb

View File

@ -25,6 +25,7 @@
#include "Aql/Ast.h" #include "Aql/Ast.h"
#include "Aql/VariableGenerator.h" #include "Aql/VariableGenerator.h"
#include "Basics/VelocyPackHelper.h" #include "Basics/VelocyPackHelper.h"
#include "Meta/static_assert_size.h"
#include <velocypack/Slice.h> #include <velocypack/Slice.h>
#include <velocypack/velocypack-aliases.h> #include <velocypack/velocypack-aliases.h>
@ -93,7 +94,7 @@ Variable* Variable::varFromVPack(Ast* ast, arangodb::velocypack::Slice const& ba
return ast->variables()->createVariable(variable); return ast->variables()->createVariable(variable);
} }
bool Variable::isEqualTo(Variable const& other) { bool Variable::isEqualTo(Variable const& other) const {
meta::details::static_assert_size<Variable, 16>(); meta::details::static_assert_size<Variable, 48>();
return (id == other.id) && (name == other.name); return (id == other.id) && (name == other.name);
} }

View File

@ -80,6 +80,9 @@ struct Variable {
static Variable* varFromVPack(Ast* ast, arangodb::velocypack::Slice const& base, static Variable* varFromVPack(Ast* ast, arangodb::velocypack::Slice const& base,
char const* variableName, bool optional = false); char const* variableName, bool optional = false);
bool isEqualTo(Variable const& other) const;
/// @brief variable name /// @brief variable name
std::string name; std::string name;

View File

@ -60,55 +60,55 @@ public:
TEST_F(ExecutionNodeTest, start_node_velocypack_roundtrip) { TEST_F(ExecutionNodeTest, start_node_velocypack_roundtrip) {
VPackBuilder builder; VPackBuilder builder;
SubqueryStartNode *node, *nodeFromVPack; std::unique_ptr<SubqueryStartNode> node, nodeFromVPack;
node = new SubqueryStartNode(&plan, 0); node = std::make_unique<SubqueryStartNode>(&plan, 0);
builder.openArray(); builder.openArray();
node->toVelocyPackHelper(builder, ExecutionNode::SERIALIZE_DETAILS); node->toVelocyPackHelper(builder, ExecutionNode::SERIALIZE_DETAILS);
builder.close(); builder.close();
nodeFromVPack = new SubqueryStartNode(&plan, builder.slice()[0]); nodeFromVPack = std::make_unique<SubqueryStartNode>(&plan, builder.slice()[0]);
ASSERT_TRUE(node->isEqualTo(nodeFromVPack)); ASSERT_TRUE(node->isEqualTo(*nodeFromVPack));
} }
TEST_F(ExecutionNodeTest, start_node_not_equal_different_id) { TEST_F(ExecutionNodeTest, start_node_not_equal_different_id) {
SubqueryStartNode *node1, *node2; std::unique_ptr<SubqueryStartNode> node1, node2;
node1 = new SubqueryStartNode(&plan, 0); node1 = std::make_unique<SubqueryStartNode>(&plan, 0);
node1 = new SubqueryStartNode(&plan, 1); node2 = std::make_unique<SubqueryStartNode>(&plan, 1);
ASSERT_FALSE(node1->isEqualTo(node2)); ASSERT_FALSE(node1->isEqualTo(*node2));
} }
TEST_F(ExecutionNodeTest, end_node_velocypack_roundtrip) { TEST_F(ExecutionNodeTest, end_node_velocypack_roundtrip) {
VPackBuilder builder; VPackBuilder builder;
Variable *outvar = new Variable("name", 1); Variable outvar("name", 1);
SubqueryEndNode *node, *nodeFromVPack; std::unique_ptr<SubqueryEndNode> node, nodeFromVPack;
node = new SubqueryEndNode(&plan, 0, outvar); node = std::make_unique<SubqueryEndNode>(&plan, 0, &outvar);
builder.openArray(); builder.openArray();
node->toVelocyPackHelper(builder, ExecutionNode::SERIALIZE_DETAILS); node->toVelocyPackHelper(builder, ExecutionNode::SERIALIZE_DETAILS);
builder.close(); builder.close();
nodeFromVPack = new SubqueryEndNode(&plan, builder.slice()[0]); nodeFromVPack = std::make_unique<SubqueryEndNode>(&plan, builder.slice()[0]);
ASSERT_TRUE(node->isEqualTo(nodeFromVPack)); ASSERT_TRUE(node->isEqualTo(*nodeFromVPack));
} }
TEST_F(ExecutionNodeTest, end_node_not_equal_different_id) { TEST_F(ExecutionNodeTest, end_node_not_equal_different_id) {
SubqueryEndNode *node1, *node2; std::unique_ptr<SubqueryEndNode> node1, node2;
Variable *outvar = new Variable("name", 1); Variable outvar("name", 1);
node1 = new SubqueryEndNode(&plan, 0, outvar); node1 = std::make_unique<SubqueryEndNode>(&plan, 0, &outvar);
node1 = new SubqueryEndNode(&plan, 1, outvar); node2 = std::make_unique<SubqueryEndNode>(&plan, 1, &outvar);
ASSERT_FALSE(node1->isEqualTo(node2)); ASSERT_FALSE(node1->isEqualTo(*node2));
} }