mirror of https://gitee.com/bigwinds/arangodb
Suppress false positives about "potential null pointer dereference" (#8501)
This commit is contained in:
parent
44810a1218
commit
ff06c5244f
|
@ -100,9 +100,30 @@ bool ShortestPathExecutorInfos::usesOutputRegister(OutputName type) const {
|
||||||
return _registerMapping.find(type) != _registerMapping.end();
|
return _registerMapping.find(type) != _registerMapping.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string typeToString(ShortestPathExecutorInfos::OutputName type) {
|
||||||
|
switch(type) {
|
||||||
|
case ShortestPathExecutorInfos::VERTEX:
|
||||||
|
return std::string{"VERTEX"};
|
||||||
|
case ShortestPathExecutorInfos::EDGE:
|
||||||
|
return std::string{"EDGE"};
|
||||||
|
default:
|
||||||
|
return std::string{"<INVALID("} + std::to_string(type) + ")>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterId ShortestPathExecutorInfos::findRegisterChecked(OutputName type) const {
|
||||||
|
auto const& it = _registerMapping.find(type);
|
||||||
|
if (ADB_UNLIKELY(it == _registerMapping.end())) {
|
||||||
|
THROW_ARANGO_EXCEPTION_MESSAGE(
|
||||||
|
TRI_ERROR_INTERNAL,
|
||||||
|
"Logic error: requested unused register type " + typeToString(type));
|
||||||
|
}
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
RegisterId ShortestPathExecutorInfos::getOutputRegister(OutputName type) const {
|
RegisterId ShortestPathExecutorInfos::getOutputRegister(OutputName type) const {
|
||||||
TRI_ASSERT(usesOutputRegister(type));
|
TRI_ASSERT(usesOutputRegister(type));
|
||||||
return _registerMapping.find(type)->second;
|
return findRegisterChecked(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
graph::TraverserCache* ShortestPathExecutorInfos::cache() const {
|
graph::TraverserCache* ShortestPathExecutorInfos::cache() const {
|
||||||
|
|
|
@ -122,6 +122,9 @@ class ShortestPathExecutorInfos : public ExecutorInfos {
|
||||||
|
|
||||||
graph::TraverserCache* cache() const;
|
graph::TraverserCache* cache() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
RegisterId findRegisterChecked(OutputName type) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @brief the shortest path finder.
|
/// @brief the shortest path finder.
|
||||||
std::unique_ptr<arangodb::graph::ShortestPathFinder> _finder;
|
std::unique_ptr<arangodb::graph::ShortestPathFinder> _finder;
|
||||||
|
|
|
@ -64,31 +64,60 @@ Traverser& TraversalExecutorInfos::traverser() {
|
||||||
return *_traverser.get();
|
return *_traverser.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TraversalExecutorInfos::useVertexOutput() const {
|
bool TraversalExecutorInfos::usesOutputRegister(OutputName type) const {
|
||||||
return _registerMapping.find(OutputName::VERTEX) != _registerMapping.end();
|
return _registerMapping.find(type) != _registerMapping.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterId TraversalExecutorInfos::vertexRegister() const {
|
bool TraversalExecutorInfos::useVertexOutput() const {
|
||||||
TRI_ASSERT(useVertexOutput());
|
return usesOutputRegister(OutputName::VERTEX);
|
||||||
return _registerMapping.find(OutputName::VERTEX)->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TraversalExecutorInfos::useEdgeOutput() const {
|
bool TraversalExecutorInfos::useEdgeOutput() const {
|
||||||
return _registerMapping.find(OutputName::EDGE) != _registerMapping.end();
|
return usesOutputRegister(OutputName::EDGE);
|
||||||
}
|
|
||||||
|
|
||||||
RegisterId TraversalExecutorInfos::edgeRegister() const {
|
|
||||||
TRI_ASSERT(useEdgeOutput());
|
|
||||||
return _registerMapping.find(OutputName::EDGE)->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TraversalExecutorInfos::usePathOutput() const {
|
bool TraversalExecutorInfos::usePathOutput() const {
|
||||||
return _registerMapping.find(OutputName::PATH) != _registerMapping.end();
|
return usesOutputRegister(OutputName::PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string typeToString(TraversalExecutorInfos::OutputName type) {
|
||||||
|
switch(type) {
|
||||||
|
case TraversalExecutorInfos::VERTEX:
|
||||||
|
return std::string{"VERTEX"};
|
||||||
|
case TraversalExecutorInfos::EDGE:
|
||||||
|
return std::string{"EDGE"};
|
||||||
|
case TraversalExecutorInfos::PATH:
|
||||||
|
return std::string{"PATH"};
|
||||||
|
default:
|
||||||
|
return std::string{"<INVALID("} + std::to_string(type) + ")>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterId TraversalExecutorInfos::findRegisterChecked(OutputName type) const {
|
||||||
|
auto const& it = _registerMapping.find(type);
|
||||||
|
if (ADB_UNLIKELY(it == _registerMapping.end())) {
|
||||||
|
THROW_ARANGO_EXCEPTION_MESSAGE(
|
||||||
|
TRI_ERROR_INTERNAL,
|
||||||
|
"Logic error: requested unused register type " + typeToString(type));
|
||||||
|
}
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterId TraversalExecutorInfos::getOutputRegister(OutputName type) const {
|
||||||
|
TRI_ASSERT(usesOutputRegister(type));
|
||||||
|
return findRegisterChecked(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterId TraversalExecutorInfos::vertexRegister() const {
|
||||||
|
return getOutputRegister(OutputName::VERTEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterId TraversalExecutorInfos::edgeRegister() const {
|
||||||
|
return getOutputRegister(OutputName::EDGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterId TraversalExecutorInfos::pathRegister() const {
|
RegisterId TraversalExecutorInfos::pathRegister() const {
|
||||||
TRI_ASSERT(usePathOutput());
|
return getOutputRegister(OutputName::PATH);
|
||||||
return _registerMapping.find(OutputName::PATH)->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TraversalExecutorInfos::usesFixedSource() const {
|
bool TraversalExecutorInfos::usesFixedSource() const {
|
||||||
|
|
|
@ -67,6 +67,10 @@ class TraversalExecutorInfos : public ExecutorInfos {
|
||||||
|
|
||||||
traverser::Traverser& traverser();
|
traverser::Traverser& traverser();
|
||||||
|
|
||||||
|
bool usesOutputRegister(OutputName type) const;
|
||||||
|
|
||||||
|
RegisterId getOutputRegister(OutputName type) const;
|
||||||
|
|
||||||
bool useVertexOutput() const;
|
bool useVertexOutput() const;
|
||||||
|
|
||||||
RegisterId vertexRegister() const;
|
RegisterId vertexRegister() const;
|
||||||
|
@ -87,6 +91,9 @@ class TraversalExecutorInfos : public ExecutorInfos {
|
||||||
|
|
||||||
std::vector<std::pair<Variable const*, RegisterId>> const& filterConditionVariables() const;
|
std::vector<std::pair<Variable const*, RegisterId>> const& filterConditionVariables() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
RegisterId findRegisterChecked(OutputName type) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<traverser::Traverser> _traverser;
|
std::unique_ptr<traverser::Traverser> _traverser;
|
||||||
std::unordered_map<OutputName, RegisterId, OutputNameHash> _registerMapping;
|
std::unordered_map<OutputName, RegisterId, OutputNameHash> _registerMapping;
|
||||||
|
|
Loading…
Reference in New Issue