mirror of https://gitee.com/bigwinds/arangodb
Bug fix/cppcheck 13042019 (#8752)
This commit is contained in:
parent
a75196bc61
commit
449ab1ed8e
|
@ -294,13 +294,13 @@ size_t Job::countGoodOrBadServersInList(Node const& snap, std::vector<std::strin
|
||||||
/// @brief Check if a server is cleaned or to be cleaned out:
|
/// @brief Check if a server is cleaned or to be cleaned out:
|
||||||
bool Job::isInServerList(Node const& snap, std::string const& prefix, std::string const& server, bool isArray) {
|
bool Job::isInServerList(Node const& snap, std::string const& prefix, std::string const& server, bool isArray) {
|
||||||
VPackSlice slice;
|
VPackSlice slice;
|
||||||
bool has;
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (isArray) {
|
if (isArray) {
|
||||||
|
bool has;
|
||||||
std::tie(slice, has) = snap.hasAsSlice(prefix);
|
std::tie(slice, has) = snap.hasAsSlice(prefix);
|
||||||
if (has && slice.isArray()) {
|
if (has && slice.isArray()) {
|
||||||
for (auto const& srv : VPackArrayIterator(slice)) {
|
for (auto const& srv : VPackArrayIterator(slice)) {
|
||||||
if (srv.copyString() == server) {
|
if (srv.isEqualString(server)) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -331,11 +331,10 @@ std::vector<std::string> Job::availableServers(Node const& snapshot) {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto excludePrefix = [&ret, &snapshot](std::string const& prefix, bool isArray) {
|
auto excludePrefix = [&ret, &snapshot](std::string const& prefix, bool isArray) {
|
||||||
|
|
||||||
bool has;
|
|
||||||
VPackSlice slice;
|
VPackSlice slice;
|
||||||
|
|
||||||
if (isArray) {
|
if (isArray) {
|
||||||
|
bool has;
|
||||||
std::tie(slice, has) = snapshot.hasAsSlice(prefix);
|
std::tie(slice, has) = snapshot.hasAsSlice(prefix);
|
||||||
if (has) {
|
if (has) {
|
||||||
for (auto const& srv : VPackArrayIterator(slice)) {
|
for (auto const& srv : VPackArrayIterator(slice)) {
|
||||||
|
|
|
@ -231,8 +231,8 @@ std::pair<ExecutionState, NoStats> HashedCollectExecutor::produceRow(OutputAqlIt
|
||||||
// produce output
|
// produce output
|
||||||
if (_currentGroup != _allGroups.end()) {
|
if (_currentGroup != _allGroups.end()) {
|
||||||
writeCurrentGroupToOutput(output);
|
writeCurrentGroupToOutput(output);
|
||||||
_currentGroup++;
|
++_currentGroup;
|
||||||
_returnedGroups++;
|
++_returnedGroups;
|
||||||
TRI_ASSERT(_returnedGroups <= _allGroups.size());
|
TRI_ASSERT(_returnedGroups <= _allGroups.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,4 +316,4 @@ std::pair<ExecutionState, size_t> HashedCollectExecutor::expectedNumberOfRows(si
|
||||||
return {ExecutionState::HASMORE, rowsLeft};
|
return {ExecutionState::HASMORE, rowsLeft};
|
||||||
}
|
}
|
||||||
return {ExecutionState::DONE, rowsLeft};
|
return {ExecutionState::DONE, rowsLeft};
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ using namespace arangodb::maintenance;
|
||||||
/// @brief ctor
|
/// @brief ctor
|
||||||
ActionDescription::ActionDescription(std::map<std::string, std::string> const& d,
|
ActionDescription::ActionDescription(std::map<std::string, std::string> const& d,
|
||||||
int priority,
|
int priority,
|
||||||
std::shared_ptr<VPackBuilder> const p)
|
std::shared_ptr<VPackBuilder> const& p)
|
||||||
: _description(d), _properties(p), _priority(priority) {
|
: _description(d), _properties(p), _priority(priority) {
|
||||||
TRI_ASSERT(d.find(NAME) != d.end());
|
TRI_ASSERT(d.find(NAME) != d.end());
|
||||||
TRI_ASSERT(p == nullptr || p->isEmpty() || p->slice().isObject());
|
TRI_ASSERT(p == nullptr || p->isEmpty() || p->slice().isObject());
|
||||||
|
|
|
@ -68,7 +68,7 @@ struct ActionDescription {
|
||||||
explicit ActionDescription(
|
explicit ActionDescription(
|
||||||
std::map<std::string, std::string> const& desc,
|
std::map<std::string, std::string> const& desc,
|
||||||
int priority,
|
int priority,
|
||||||
std::shared_ptr<VPackBuilder> const suppl = std::make_shared<VPackBuilder>());
|
std::shared_ptr<VPackBuilder> const& properties = std::make_shared<VPackBuilder>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clean up
|
* @brief Clean up
|
||||||
|
|
|
@ -806,12 +806,12 @@ size_t ClusterComm::performRequests(std::vector<ClusterCommRequest>& requests,
|
||||||
dueTime.push_back(startTime);
|
dueTime.push_back(startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t nrDone = 0;
|
|
||||||
size_t nrGood = 0;
|
size_t nrGood = 0;
|
||||||
|
|
||||||
std::unordered_map<OperationID, size_t> opIDtoIndex;
|
std::unordered_map<OperationID, size_t> opIDtoIndex;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
size_t nrDone = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
now = TRI_microtime();
|
now = TRI_microtime();
|
||||||
if (now > endTime || application_features::ApplicationServer::isStopping()) {
|
if (now > endTime || application_features::ApplicationServer::isStopping()) {
|
||||||
|
|
|
@ -46,10 +46,8 @@ struct DBServerAgencySyncResult {
|
||||||
DBServerAgencySyncResult(bool s, std::string const& e, uint64_t p, uint64_t c)
|
DBServerAgencySyncResult(bool s, std::string const& e, uint64_t p, uint64_t c)
|
||||||
: success(s), errorMessage(e), planVersion(p), currentVersion(c) {}
|
: success(s), errorMessage(e), planVersion(p), currentVersion(c) {}
|
||||||
|
|
||||||
DBServerAgencySyncResult(const DBServerAgencySyncResult& other)
|
DBServerAgencySyncResult(DBServerAgencySyncResult const& other) = default;
|
||||||
: success(other.success),
|
DBServerAgencySyncResult& operator=(DBServerAgencySyncResult const& other) = default;
|
||||||
planVersion(other.planVersion),
|
|
||||||
currentVersion(other.currentVersion) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DBServerAgencySync {
|
class DBServerAgencySync {
|
||||||
|
|
|
@ -397,7 +397,7 @@ double BaseOptions::costForLookupInfoList(std::vector<BaseOptions::LookupInfo> c
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeCursor* BaseOptions::nextCursorLocal(arangodb::velocypack::StringRef vid,
|
EdgeCursor* BaseOptions::nextCursorLocal(arangodb::velocypack::StringRef vid,
|
||||||
std::vector<LookupInfo>& list) {
|
std::vector<LookupInfo> const& list) {
|
||||||
auto allCursor = std::make_unique<SingleServerEdgeCursor>(this, list.size());
|
auto allCursor = std::make_unique<SingleServerEdgeCursor>(this, list.size());
|
||||||
auto& opCursors = allCursor->getCursors();
|
auto& opCursors = allCursor->getCursors();
|
||||||
for (auto& info : list) {
|
for (auto& info : list) {
|
||||||
|
@ -412,7 +412,7 @@ EdgeCursor* BaseOptions::nextCursorLocal(arangodb::velocypack::StringRef vid,
|
||||||
auto idNode = dirCmp->getMemberUnchecked(1);
|
auto idNode = dirCmp->getMemberUnchecked(1);
|
||||||
TRI_ASSERT(idNode->type == aql::NODE_TYPE_VALUE);
|
TRI_ASSERT(idNode->type == aql::NODE_TYPE_VALUE);
|
||||||
TRI_ASSERT(idNode->isValueType(aql::VALUE_TYPE_STRING));
|
TRI_ASSERT(idNode->isValueType(aql::VALUE_TYPE_STRING));
|
||||||
// must edit node inplace; TODO replace node?
|
// must edit node in place; TODO replace node?
|
||||||
TEMPORARILY_UNLOCK_NODE(idNode);
|
TEMPORARILY_UNLOCK_NODE(idNode);
|
||||||
idNode->setStringValue(vid.data(), vid.length());
|
idNode->setStringValue(vid.data(), vid.length());
|
||||||
}
|
}
|
||||||
|
@ -420,6 +420,7 @@ EdgeCursor* BaseOptions::nextCursorLocal(arangodb::velocypack::StringRef vid,
|
||||||
csrs.reserve(info.idxHandles.size());
|
csrs.reserve(info.idxHandles.size());
|
||||||
IndexIteratorOptions opts;
|
IndexIteratorOptions opts;
|
||||||
for (auto const& it : info.idxHandles) {
|
for (auto const& it : info.idxHandles) {
|
||||||
|
// the emplace_back cannot throw here, as we reserved enough space before
|
||||||
csrs.emplace_back(new OperationCursor(_trx->indexScanForCondition(it, node, _tmpVar, opts)));
|
csrs.emplace_back(new OperationCursor(_trx->indexScanForCondition(it, node, _tmpVar, opts)));
|
||||||
}
|
}
|
||||||
opCursors.emplace_back(std::move(csrs));
|
opCursors.emplace_back(std::move(csrs));
|
||||||
|
|
|
@ -68,6 +68,7 @@ struct BaseOptions {
|
||||||
~LookupInfo();
|
~LookupInfo();
|
||||||
|
|
||||||
LookupInfo(LookupInfo const&);
|
LookupInfo(LookupInfo const&);
|
||||||
|
LookupInfo& operator=(LookupInfo const&) = delete;
|
||||||
|
|
||||||
LookupInfo(arangodb::aql::Query*, arangodb::velocypack::Slice const&,
|
LookupInfo(arangodb::aql::Query*, arangodb::velocypack::Slice const&,
|
||||||
arangodb::velocypack::Slice const&);
|
arangodb::velocypack::Slice const&);
|
||||||
|
@ -88,6 +89,7 @@ struct BaseOptions {
|
||||||
/// @brief This copy constructor is only working during planning phase.
|
/// @brief This copy constructor is only working during planning phase.
|
||||||
/// After planning this node should not be copied anywhere.
|
/// After planning this node should not be copied anywhere.
|
||||||
explicit BaseOptions(BaseOptions const&);
|
explicit BaseOptions(BaseOptions const&);
|
||||||
|
BaseOptions& operator=(BaseOptions const&) = delete;
|
||||||
|
|
||||||
BaseOptions(arangodb::aql::Query*, arangodb::velocypack::Slice, arangodb::velocypack::Slice);
|
BaseOptions(arangodb::aql::Query*, arangodb::velocypack::Slice, arangodb::velocypack::Slice);
|
||||||
|
|
||||||
|
@ -151,7 +153,7 @@ struct BaseOptions {
|
||||||
std::string const& attributeName, aql::AstNode* condition);
|
std::string const& attributeName, aql::AstNode* condition);
|
||||||
|
|
||||||
EdgeCursor* nextCursorLocal(arangodb::velocypack::StringRef vid,
|
EdgeCursor* nextCursorLocal(arangodb::velocypack::StringRef vid,
|
||||||
std::vector<LookupInfo>&);
|
std::vector<LookupInfo> const&);
|
||||||
|
|
||||||
void injectTestCache(std::unique_ptr<TraverserCache>&& cache);
|
void injectTestCache(std::unique_ptr<TraverserCache>&& cache);
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,6 @@ BreadthFirstEnumerator::PathStep::PathStep(size_t sourceIdx, EdgeDocumentToken&&
|
||||||
|
|
||||||
BreadthFirstEnumerator::PathStep::~PathStep() {}
|
BreadthFirstEnumerator::PathStep::~PathStep() {}
|
||||||
|
|
||||||
BreadthFirstEnumerator::PathStep::PathStep(PathStep& other)
|
|
||||||
: sourceIdx(other.sourceIdx), edge(other.edge), vertex(other.vertex) {}
|
|
||||||
|
|
||||||
BreadthFirstEnumerator::BreadthFirstEnumerator(Traverser* traverser, VPackSlice startVertex,
|
BreadthFirstEnumerator::BreadthFirstEnumerator(Traverser* traverser, VPackSlice startVertex,
|
||||||
TraverserOptions* opts)
|
TraverserOptions* opts)
|
||||||
: PathEnumerator(traverser, startVertex.copyString(), opts),
|
: PathEnumerator(traverser, startVertex.copyString(), opts),
|
||||||
|
|
|
@ -55,7 +55,8 @@ class BreadthFirstEnumerator final : public arangodb::traverser::PathEnumerator
|
||||||
|
|
||||||
~PathStep();
|
~PathStep();
|
||||||
|
|
||||||
PathStep(PathStep& other);
|
PathStep(PathStep const& other) = default;
|
||||||
|
PathStep& operator=(PathStep const& other) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -153,7 +153,6 @@ void KShortestPathsFinder::computeNeighbourhoodOfVertex(
|
||||||
bool KShortestPathsFinder::advanceFrontier(
|
bool KShortestPathsFinder::advanceFrontier(
|
||||||
Ball& source, Ball const& target, std::unordered_set<VertexRef> const& forbiddenVertices,
|
Ball& source, Ball const& target, std::unordered_set<VertexRef> const& forbiddenVertices,
|
||||||
std::unordered_set<Edge> const& forbiddenEdges, VertexRef& join) {
|
std::unordered_set<Edge> const& forbiddenEdges, VertexRef& join) {
|
||||||
std::vector<Step> neighbours;
|
|
||||||
VertexRef vr;
|
VertexRef vr;
|
||||||
FoundVertex* v;
|
FoundVertex* v;
|
||||||
|
|
||||||
|
@ -162,7 +161,7 @@ bool KShortestPathsFinder::advanceFrontier(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
neighbours.clear();
|
std::vector<Step> neighbours;
|
||||||
computeNeighbourhoodOfVertex(vr, source._direction, neighbours);
|
computeNeighbourhoodOfVertex(vr, source._direction, neighbours);
|
||||||
|
|
||||||
for (auto& s : neighbours) {
|
for (auto& s : neighbours) {
|
||||||
|
@ -193,8 +192,8 @@ bool KShortestPathsFinder::advanceFrontier(
|
||||||
}
|
}
|
||||||
|
|
||||||
void KShortestPathsFinder::reconstructPath(Ball const& left, Ball const& right,
|
void KShortestPathsFinder::reconstructPath(Ball const& left, Ball const& right,
|
||||||
VertexRef const& join,
|
VertexRef const& join,
|
||||||
Path& result) {
|
Path& result) {
|
||||||
result.clear();
|
result.clear();
|
||||||
TRI_ASSERT(!join.empty());
|
TRI_ASSERT(!join.empty());
|
||||||
result._vertices.emplace_back(join);
|
result._vertices.emplace_back(join);
|
||||||
|
|
|
@ -69,8 +69,8 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
||||||
_edges.clear();
|
_edges.clear();
|
||||||
_weights.clear();
|
_weights.clear();
|
||||||
_weight = 0;
|
_weight = 0;
|
||||||
};
|
}
|
||||||
size_t length() const { return _vertices.size(); };
|
size_t length() const { return _vertices.size(); }
|
||||||
void append(Path const& p, size_t a, size_t b) {
|
void append(Path const& p, size_t a, size_t b) {
|
||||||
if (this->length() == 0) {
|
if (this->length() == 0) {
|
||||||
_vertices.emplace_back(p._vertices.at(a));
|
_vertices.emplace_back(p._vertices.at(a));
|
||||||
|
@ -108,7 +108,7 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
struct Step {
|
struct Step {
|
||||||
Edge _edge;
|
Edge _edge;
|
||||||
|
@ -116,7 +116,7 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
||||||
double _weight;
|
double _weight;
|
||||||
|
|
||||||
Step(Edge const& edge, VertexRef const& vertex, double weight)
|
Step(Edge const& edge, VertexRef const& vertex, double weight)
|
||||||
: _edge(edge), _vertex(vertex), _weight(weight){};
|
: _edge(edge), _vertex(vertex), _weight(weight) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FoundVertex {
|
struct FoundVertex {
|
||||||
|
@ -126,12 +126,12 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
||||||
double _weight;
|
double _weight;
|
||||||
|
|
||||||
// Using negative weight to signifiy start/end vertex
|
// Using negative weight to signifiy start/end vertex
|
||||||
FoundVertex(VertexRef const& vertex) : _vertex(vertex), _weight(0){};
|
explicit FoundVertex(VertexRef const& vertex) : _vertex(vertex), _weight(0) {}
|
||||||
FoundVertex(VertexRef const& vertex, VertexRef const& pred, Edge&& edge, double weight)
|
FoundVertex(VertexRef const& vertex, VertexRef const& pred, Edge&& edge, double weight)
|
||||||
: _vertex(vertex), _pred(pred), _edge(std::move(edge)), _weight(weight){};
|
: _vertex(vertex), _pred(pred), _edge(std::move(edge)), _weight(weight) {}
|
||||||
double weight() { return _weight; };
|
double weight() const { return _weight; }
|
||||||
void setWeight(double weight) { _weight = weight; };
|
void setWeight(double weight) { _weight = weight; }
|
||||||
VertexRef const& getKey() { return _vertex; };
|
VertexRef const& getKey() const { return _vertex; }
|
||||||
};
|
};
|
||||||
// typedef std::deque<VertexRef> Frontier;
|
// typedef std::deque<VertexRef> Frontier;
|
||||||
typedef ShortestPathPriorityQueue<VertexRef, FoundVertex, double> Frontier;
|
typedef ShortestPathPriorityQueue<VertexRef, FoundVertex, double> Frontier;
|
||||||
|
@ -147,12 +147,17 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
||||||
Direction _direction;
|
Direction _direction;
|
||||||
Frontier _frontier;
|
Frontier _frontier;
|
||||||
|
|
||||||
Ball(void){};
|
Ball(void) {}
|
||||||
Ball(VertexRef const& centre, Direction direction)
|
Ball(VertexRef const& centre, Direction direction)
|
||||||
: _centre(centre), _direction(direction) {
|
: _centre(centre), _direction(direction) {
|
||||||
auto v = new FoundVertex(centre);
|
auto v = new FoundVertex(centre);
|
||||||
_frontier.insert(centre, v);
|
try {
|
||||||
};
|
_frontier.insert(centre, v);
|
||||||
|
} catch (...) {
|
||||||
|
delete v;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
~Ball() {
|
~Ball() {
|
||||||
// TODO free all vertices
|
// TODO free all vertices
|
||||||
}
|
}
|
||||||
|
@ -166,10 +171,10 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
||||||
// TODO: Remove
|
// TODO: Remove
|
||||||
bool shortestPath(arangodb::velocypack::Slice const& start,
|
bool shortestPath(arangodb::velocypack::Slice const& start,
|
||||||
arangodb::velocypack::Slice const& target,
|
arangodb::velocypack::Slice const& target,
|
||||||
arangodb::graph::ShortestPathResult& result) {
|
arangodb::graph::ShortestPathResult& result) override {
|
||||||
TRI_ASSERT(false);
|
TRI_ASSERT(false);
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
bool startKShortestPathsTraversal(arangodb::velocypack::Slice const& start,
|
bool startKShortestPathsTraversal(arangodb::velocypack::Slice const& start,
|
||||||
|
@ -183,7 +188,7 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
||||||
bool getNextPathShortestPathResult(ShortestPathResult& path);
|
bool getNextPathShortestPathResult(ShortestPathResult& path);
|
||||||
// get the next available path as a Path
|
// get the next available path as a Path
|
||||||
bool getNextPath(Path& path);
|
bool getNextPath(Path& path);
|
||||||
bool isPathAvailable(void) { return _pathAvailable; };
|
bool isPathAvailable(void) { return _pathAvailable; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool computeShortestPath(VertexRef const& start, VertexRef const& end,
|
bool computeShortestPath(VertexRef const& start, VertexRef const& end,
|
||||||
|
|
|
@ -173,7 +173,7 @@ void ShortestPathOptions::addReverseLookupInfo(aql::ExecutionPlan* plan,
|
||||||
injectLookupInfoInList(_reverseLookupInfos, plan, collectionName, attributeName, condition);
|
injectLookupInfoInList(_reverseLookupInfos, plan, collectionName, attributeName, condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
double ShortestPathOptions::weightEdge(VPackSlice edge) {
|
double ShortestPathOptions::weightEdge(VPackSlice edge) const {
|
||||||
TRI_ASSERT(useWeight());
|
TRI_ASSERT(useWeight());
|
||||||
return arangodb::basics::VelocyPackHelper::getNumericValue<double>(
|
return arangodb::basics::VelocyPackHelper::getNumericValue<double>(
|
||||||
edge, weightAttribute.c_str(), defaultWeight);
|
edge, weightAttribute.c_str(), defaultWeight);
|
||||||
|
|
|
@ -89,7 +89,7 @@ struct ShortestPathOptions : public BaseOptions {
|
||||||
std::string const& attributeName, aql::AstNode* condition);
|
std::string const& attributeName, aql::AstNode* condition);
|
||||||
|
|
||||||
// Compute the weight of the given edge
|
// Compute the weight of the given edge
|
||||||
double weightEdge(arangodb::velocypack::Slice const);
|
double weightEdge(arangodb::velocypack::Slice const) const;
|
||||||
|
|
||||||
EdgeCursor* nextCursor(arangodb::velocypack::StringRef vid);
|
EdgeCursor* nextCursor(arangodb::velocypack::StringRef vid);
|
||||||
|
|
||||||
|
|
|
@ -500,13 +500,10 @@ EdgeCursor* arangodb::traverser::TraverserOptions::nextCursor(
|
||||||
return nextCursorCoordinator(vid, depth);
|
return nextCursorCoordinator(vid, depth);
|
||||||
}
|
}
|
||||||
auto specific = _depthLookupInfo.find(depth);
|
auto specific = _depthLookupInfo.find(depth);
|
||||||
std::vector<LookupInfo> list;
|
|
||||||
if (specific != _depthLookupInfo.end()) {
|
if (specific != _depthLookupInfo.end()) {
|
||||||
list = specific->second;
|
return nextCursorLocal(vid, specific->second);
|
||||||
} else {
|
}
|
||||||
list = _baseLookupInfos;
|
return nextCursorLocal(vid, _baseLookupInfos);
|
||||||
}
|
|
||||||
return nextCursorLocal(vid, list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeCursor* TraverserOptions::nextCursorCoordinator(arangodb::velocypack::StringRef vid,
|
EdgeCursor* TraverserOptions::nextCursorCoordinator(arangodb::velocypack::StringRef vid,
|
||||||
|
|
|
@ -97,6 +97,7 @@ struct TraverserOptions : public graph::BaseOptions {
|
||||||
/// @brief This copy constructor is only working during planning phase.
|
/// @brief This copy constructor is only working during planning phase.
|
||||||
/// After planning this node should not be copied anywhere.
|
/// After planning this node should not be copied anywhere.
|
||||||
TraverserOptions(TraverserOptions const&);
|
TraverserOptions(TraverserOptions const&);
|
||||||
|
TraverserOptions& operator=(TraverserOptions const&) = delete;
|
||||||
|
|
||||||
virtual ~TraverserOptions();
|
virtual ~TraverserOptions();
|
||||||
|
|
||||||
|
|
|
@ -339,9 +339,9 @@ bool CtrlHandler(DWORD eventType) {
|
||||||
#else
|
#else
|
||||||
|
|
||||||
extern "C" void c_exit_handler(int signal) {
|
extern "C" void c_exit_handler(int signal) {
|
||||||
static bool seen = false;
|
|
||||||
|
|
||||||
if (signal == SIGQUIT || signal == SIGTERM || signal == SIGINT) {
|
if (signal == SIGQUIT || signal == SIGTERM || signal == SIGINT) {
|
||||||
|
static bool seen = false;
|
||||||
|
|
||||||
if (!seen) {
|
if (!seen) {
|
||||||
LOG_TOPIC("b4133", INFO, arangodb::Logger::FIXME)
|
LOG_TOPIC("b4133", INFO, arangodb::Logger::FIXME)
|
||||||
<< "control-c received, beginning shut down sequence";
|
<< "control-c received, beginning shut down sequence";
|
||||||
|
|
|
@ -72,6 +72,7 @@ transaction::Context::Context(TRI_vocbase_t& vocbase)
|
||||||
_strings{_strArena},
|
_strings{_strArena},
|
||||||
_options(arangodb::velocypack::Options::Defaults),
|
_options(arangodb::velocypack::Options::Defaults),
|
||||||
_dumpOptions(arangodb::velocypack::Options::Defaults),
|
_dumpOptions(arangodb::velocypack::Options::Defaults),
|
||||||
|
_contextData(EngineSelectorFeature::ENGINE->createTransactionContextData()),
|
||||||
_transaction{0, false},
|
_transaction{0, false},
|
||||||
_ownsResolver(false) {
|
_ownsResolver(false) {
|
||||||
/// dump options contain have the escapeUnicode attribute set to true
|
/// dump options contain have the escapeUnicode attribute set to true
|
||||||
|
@ -81,8 +82,6 @@ transaction::Context::Context(TRI_vocbase_t& vocbase)
|
||||||
/// which speculate on ASCII strings first and only fall back to slower
|
/// which speculate on ASCII strings first and only fall back to slower
|
||||||
/// multibyte strings on first actual occurrence of a multibyte character.
|
/// multibyte strings on first actual occurrence of a multibyte character.
|
||||||
_dumpOptions.escapeUnicode = true;
|
_dumpOptions.escapeUnicode = true;
|
||||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
|
||||||
_contextData = engine->createTransactionContextData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief destroy the context
|
/// @brief destroy the context
|
||||||
|
|
|
@ -46,7 +46,10 @@ using namespace arangodb::basics;
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/// @brief lookup table for key checks
|
/// @brief lookup table for key checks
|
||||||
static std::array<bool, 256> const keyCharLookupTable = {
|
/// in case this table is changed, the regex in file
|
||||||
|
/// js/common/modules/@arangodb/common.js for function isValidDocumentKey
|
||||||
|
/// should be adjusted too
|
||||||
|
std::array<bool, 256> const keyCharLookupTable = {
|
||||||
{/* 0x00 . */ false, /* 0x01 . */ false,
|
{/* 0x00 . */ false, /* 0x01 . */ false,
|
||||||
/* 0x02 . */ false, /* 0x03 . */ false,
|
/* 0x02 . */ false, /* 0x03 . */ false,
|
||||||
/* 0x04 . */ false, /* 0x05 . */ false,
|
/* 0x04 . */ false, /* 0x05 . */ false,
|
||||||
|
|
|
@ -116,6 +116,8 @@ class LogicalDataSource {
|
||||||
_guid(other._guid),
|
_guid(other._guid),
|
||||||
_deleted(other._deleted),
|
_deleted(other._deleted),
|
||||||
_system(other._system) {}
|
_system(other._system) {}
|
||||||
|
|
||||||
|
LogicalDataSource& operator=(LogicalDataSource const& other) = delete;
|
||||||
|
|
||||||
virtual ~LogicalDataSource() = default;
|
virtual ~LogicalDataSource() = default;
|
||||||
|
|
||||||
|
|
|
@ -38,12 +38,16 @@ void GreetingsFeature::prepare() {
|
||||||
|
|
||||||
// building in maintainer mode or enabling catch test code will incur runtime overhead,
|
// building in maintainer mode or enabling catch test code will incur runtime overhead,
|
||||||
// so warn users about this
|
// so warn users about this
|
||||||
bool warn = false;
|
|
||||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||||
warn = true;
|
// maintainer mode
|
||||||
|
bool warn = true;
|
||||||
#else
|
#else
|
||||||
|
// catch-tests on (enables TEST_VIRTUAL)
|
||||||
#ifdef ARANGODB_USE_CATCH_TESTS
|
#ifdef ARANGODB_USE_CATCH_TESTS
|
||||||
warn = true;
|
bool warn = true;
|
||||||
|
#else
|
||||||
|
// neither maintainer mode nor catch tests
|
||||||
|
bool warn = false;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if (warn) {
|
if (warn) {
|
||||||
|
|
|
@ -911,6 +911,7 @@ void VelocyPackHelper::patchDouble(VPackSlice slice, double value) {
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// other platforms support unaligned writes
|
// other platforms support unaligned writes
|
||||||
|
// cppcheck-suppress *
|
||||||
*reinterpret_cast<double*>(p + 1) = value;
|
*reinterpret_cast<double*>(p + 1) = value;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1572,91 +1572,87 @@ std::string TRI_GetInstallRoot(std::string const& binaryPath, char const* instal
|
||||||
static bool CopyFileContents(int srcFD, int dstFD, ssize_t fileSize, std::string& error) {
|
static bool CopyFileContents(int srcFD, int dstFD, ssize_t fileSize, std::string& error) {
|
||||||
bool rc = true;
|
bool rc = true;
|
||||||
#if TRI_LINUX_SPLICE
|
#if TRI_LINUX_SPLICE
|
||||||
bool enableSplice = true;
|
int splicePipe[2];
|
||||||
if (enableSplice) {
|
ssize_t pipeSize = 0;
|
||||||
int splicePipe[2];
|
long chunkSendRemain = fileSize;
|
||||||
ssize_t pipeSize = 0;
|
loff_t totalSentAlready = 0;
|
||||||
long chunkSendRemain = fileSize;
|
|
||||||
loff_t totalSentAlready = 0;
|
|
||||||
|
|
||||||
if (pipe(splicePipe) != 0) {
|
if (pipe(splicePipe) != 0) {
|
||||||
error = std::string("splice failed to create pipes: ") + strerror(errno);
|
error = std::string("splice failed to create pipes: ") + strerror(errno);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
while (chunkSendRemain > 0) {
|
while (chunkSendRemain > 0) {
|
||||||
if (pipeSize == 0) {
|
if (pipeSize == 0) {
|
||||||
pipeSize = splice(srcFD, &totalSentAlready, splicePipe[1], nullptr,
|
pipeSize = splice(srcFD, &totalSentAlready, splicePipe[1], nullptr,
|
||||||
chunkSendRemain, SPLICE_F_MOVE);
|
chunkSendRemain, SPLICE_F_MOVE);
|
||||||
if (pipeSize == -1) {
|
if (pipeSize == -1) {
|
||||||
error = std::string("splice read failed: ") + strerror(errno);
|
|
||||||
rc = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ssize_t sent = splice(splicePipe[0], nullptr, dstFD, nullptr, pipeSize,
|
|
||||||
SPLICE_F_MORE | SPLICE_F_MOVE | SPLICE_F_NONBLOCK);
|
|
||||||
if (sent == -1) {
|
|
||||||
error = std::string("splice read failed: ") + strerror(errno);
|
error = std::string("splice read failed: ") + strerror(errno);
|
||||||
rc = false;
|
rc = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pipeSize -= sent;
|
|
||||||
chunkSendRemain -= sent;
|
|
||||||
}
|
}
|
||||||
close(splicePipe[0]);
|
ssize_t sent = splice(splicePipe[0], nullptr, dstFD, nullptr, pipeSize,
|
||||||
close(splicePipe[1]);
|
SPLICE_F_MORE | SPLICE_F_MOVE | SPLICE_F_NONBLOCK);
|
||||||
} else
|
if (sent == -1) {
|
||||||
#endif
|
error = std::string("splice read failed: ") + strerror(errno);
|
||||||
{
|
|
||||||
// 128k:
|
|
||||||
constexpr size_t C128 = 128 * 1024;
|
|
||||||
char* buf = static_cast<char*>(TRI_Allocate(C128));
|
|
||||||
|
|
||||||
if (buf == nullptr) {
|
|
||||||
error = "failed to allocate temporary buffer";
|
|
||||||
rc = false;
|
rc = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pipeSize -= sent;
|
||||||
|
chunkSendRemain -= sent;
|
||||||
|
}
|
||||||
|
close(splicePipe[0]);
|
||||||
|
close(splicePipe[1]);
|
||||||
|
#else
|
||||||
|
// 128k:
|
||||||
|
constexpr size_t C128 = 128 * 1024;
|
||||||
|
char* buf = static_cast<char*>(TRI_Allocate(C128));
|
||||||
|
|
||||||
|
if (buf == nullptr) {
|
||||||
|
error = "failed to allocate temporary buffer";
|
||||||
|
rc = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t chunkRemain = fileSize;
|
||||||
|
while (rc && (chunkRemain > 0)) {
|
||||||
|
size_t readChunk = (std::min)(C128, chunkRemain);
|
||||||
|
ssize_t nRead = TRI_READ(srcFD, buf, static_cast<TRI_read_t>(readChunk));
|
||||||
|
|
||||||
|
if (nRead < 0) {
|
||||||
|
error = std::string("failed to read a chunk: ") + strerror(errno);
|
||||||
|
rc = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t chunkRemain = fileSize;
|
if (nRead == 0) {
|
||||||
while (rc && (chunkRemain > 0)) {
|
// EOF. done
|
||||||
size_t readChunk = (std::min)(C128, chunkRemain);
|
break;
|
||||||
ssize_t nRead = TRI_READ(srcFD, buf, static_cast<TRI_read_t>(readChunk));
|
}
|
||||||
|
|
||||||
if (nRead < 0) {
|
size_t writeOffset = 0;
|
||||||
|
size_t writeRemaining = static_cast<size_t>(nRead);
|
||||||
|
while (writeRemaining > 0) {
|
||||||
|
// write can write less data than requested. so we must go on writing
|
||||||
|
// until we have written out all data
|
||||||
|
ssize_t nWritten = TRI_WRITE(dstFD, buf + writeOffset,
|
||||||
|
static_cast<TRI_write_t>(writeRemaining));
|
||||||
|
|
||||||
|
if (nWritten < 0) {
|
||||||
|
// error during write
|
||||||
error = std::string("failed to read a chunk: ") + strerror(errno);
|
error = std::string("failed to read a chunk: ") + strerror(errno);
|
||||||
rc = false;
|
rc = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nRead == 0) {
|
writeOffset += static_cast<size_t>(nWritten);
|
||||||
// EOF. done
|
writeRemaining -= static_cast<size_t>(nWritten);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t writeOffset = 0;
|
|
||||||
size_t writeRemaining = static_cast<size_t>(nRead);
|
|
||||||
while (writeRemaining > 0) {
|
|
||||||
// write can write less data than requested. so we must go on writing
|
|
||||||
// until we have written out all data
|
|
||||||
ssize_t nWritten = TRI_WRITE(dstFD, buf + writeOffset,
|
|
||||||
static_cast<TRI_write_t>(writeRemaining));
|
|
||||||
|
|
||||||
if (nWritten < 0) {
|
|
||||||
// error during write
|
|
||||||
error = std::string("failed to read a chunk: ") + strerror(errno);
|
|
||||||
rc = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
writeOffset += static_cast<size_t>(nWritten);
|
|
||||||
writeRemaining -= static_cast<size_t>(nWritten);
|
|
||||||
}
|
|
||||||
|
|
||||||
chunkRemain -= nRead;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_Free(buf);
|
chunkRemain -= nRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRI_Free(buf);
|
||||||
|
#endif
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1175,9 +1175,8 @@ static ExternalProcess* getExternalProcess(TRI_pid_t pid) {
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static ExternalProcess* getExternalProcess(TRI_pid_t pid) {
|
static ExternalProcess* getExternalProcess(TRI_pid_t pid) {
|
||||||
HANDLE hProcess;
|
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
|
||||||
|
|
||||||
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
|
|
||||||
if (hProcess != nullptr) {
|
if (hProcess != nullptr) {
|
||||||
ExternalProcess* external = new ExternalProcess();
|
ExternalProcess* external = new ExternalProcess();
|
||||||
|
|
||||||
|
@ -1191,12 +1190,14 @@ static ExternalProcess* getExternalProcess(TRI_pid_t pid) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/// @brief check for a process we didn't spawn, and check for access rights to
|
||||||
// @brief check for a process we didn't spawn, and check for access rights to
|
/// send it signals.
|
||||||
// send it signals.
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
static bool killProcess(ExternalProcess* pid, int signal) {
|
static bool killProcess(ExternalProcess* pid, int signal) {
|
||||||
TRI_ASSERT(pid != nullptr);
|
TRI_ASSERT(pid != nullptr);
|
||||||
|
if (pid == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (signal == SIGKILL) {
|
if (signal == SIGKILL) {
|
||||||
LOG_TOPIC("021b9", WARN, arangodb::Logger::FIXME) << "sending SIGKILL signal to process: " << pid->_pid;
|
LOG_TOPIC("021b9", WARN, arangodb::Logger::FIXME) << "sending SIGKILL signal to process: " << pid->_pid;
|
||||||
}
|
}
|
||||||
|
@ -1210,6 +1211,10 @@ static bool killProcess(ExternalProcess* pid, int signal) {
|
||||||
static bool killProcess(ExternalProcess* pid, int signal) {
|
static bool killProcess(ExternalProcess* pid, int signal) {
|
||||||
TRI_ASSERT(pid != nullptr);
|
TRI_ASSERT(pid != nullptr);
|
||||||
UINT uExitCode = 0;
|
UINT uExitCode = 0;
|
||||||
|
|
||||||
|
if (pid == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// kill worker process
|
// kill worker process
|
||||||
if (0 != TerminateProcess(pid->_process, uExitCode)) {
|
if (0 != TerminateProcess(pid->_process, uExitCode)) {
|
||||||
|
|
Loading…
Reference in New Issue