1
0
Fork 0

clear traverser cache in-between (#8772)

This commit is contained in:
Jan 2019-04-17 15:27:37 +02:00 committed by GitHub
parent 8ab9ae96cd
commit 6ee9206e46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 5 deletions

View File

@ -26,6 +26,7 @@
#include "Aql/Query.h"
#include "Aql/SingleRowFetcher.h"
#include "Graph/Traverser.h"
#include "Graph/TraverserCache.h"
#include "Graph/TraverserOptions.h"
using namespace arangodb;
@ -246,6 +247,8 @@ ExecutionState TraversalExecutor::computeState() const {
}
bool TraversalExecutor::resetTraverser() {
_traverser.traverserCache()->clear();
// Initialize the Expressions within the options.
// We need to find the variable and read its value here. Everything is
// computed right now.

View File

@ -53,6 +53,12 @@ TraverserCache::TraverserCache(aql::Query* query)
TraverserCache::~TraverserCache() {}
void TraverserCache::clear() {
_stringHeap->clear();
_persistedStrings.clear();
_mmdr->clear();
}
VPackSlice TraverserCache::lookupToken(EdgeDocumentToken const& idToken) {
TRI_ASSERT(!ServerState::instance()->isCoordinator());
auto col = _trx->vocbase().lookupCollection(idToken.cid());

View File

@ -59,6 +59,9 @@ class TraverserCache {
virtual ~TraverserCache();
/// @brief clears all allocated memory in the underlying StringHeap
void clear();
//////////////////////////////////////////////////////////////////////////////
/// @brief Inserts the real document stored within the token
/// into the given builder.

View File

@ -48,11 +48,6 @@ class TraversalNode;
struct Variable;
} // namespace aql
namespace graph {
class EdgeUniquenessChecker;
class TraverserCache;
} // namespace graph
namespace traverser {
class ClusterTraverser;

View File

@ -58,6 +58,16 @@ arangodb::velocypack::StringRef StringHeap::registerString(char const* ptr, size
return arangodb::velocypack::StringRef(position, length);
}
void StringHeap::clear() {
_current = nullptr;
_end = nullptr;
for (auto& it : _blocks) {
delete[] it;
}
_blocks.clear();
}
void StringHeap::merge(StringHeap&& heap) {
_blocks.reserve(_blocks.size() + heap._blocks.size());
_blocks.insert(_blocks.end(), heap._blocks.begin(), heap._blocks.end());

View File

@ -44,6 +44,11 @@ class StringHeap {
return registerString(str.data(), str.size());
}
/// @brief clear all data from the StringHeap, not releasing any occupied memory
/// the caller must make sure that nothing points into the data of the StringHeap
/// when calling this method
void clear();
void merge(StringHeap&& heap);
private: