1
0
Fork 0

yet more micro optimizations (#7399)

This commit is contained in:
Jan 2018-11-21 17:09:16 +01:00 committed by GitHub
parent ef239cbe4e
commit 19dc2ca0b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 115 additions and 88 deletions

View File

@ -99,7 +99,7 @@ void QueryResources::addNode(AstNode* node) {
_resourceMonitor->increaseMemoryUsage(sizeof(AstNode));
// will not fail
_nodes.emplace_back(node);
_nodes.push_back(node);
// safely took over the ownership for the node, cancel the deletion now
guard.cancel();
@ -189,7 +189,7 @@ char* QueryResources::registerLongString(char* copy, size_t length) {
}
// will not fail
_strings.emplace_back(copy);
_strings.push_back(copy);
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
_stringsLength += length;
#endif

View File

@ -358,7 +358,6 @@ SET(ARANGOD_SOURCES
Indexes/Index.cpp
Indexes/IndexFactory.cpp
Indexes/IndexIterator.cpp
Indexes/IndexLookupContext.cpp
Indexes/PersistentIndexAttributeMatcher.cpp
Indexes/SimpleAttributeEqualityMatcher.cpp
Indexes/SkiplistIndexAttributeMatcher.cpp

View File

@ -23,6 +23,7 @@ set(MMFILES_SOURCES
MMFiles/MMFilesExportCursor.cpp
MMFiles/MMFilesIndexElement.cpp
MMFiles/MMFilesIndexFactory.cpp
MMFiles/MMFilesIndexLookupContext.cpp
MMFiles/MMFilesLogfileManager.cpp
MMFiles/MMFilesFulltextIndex.cpp
MMFiles/MMFilesGeoIndex.cpp

View File

@ -28,7 +28,7 @@
#include "Basics/Mutex.h"
#include "Basics/ReadWriteLock.h"
#include "Indexes/IndexIterator.h"
#include "Indexes/IndexLookupContext.h"
#include "MMFiles/MMFilesIndexLookupContext.h"
#include "MMFiles/MMFilesDatafileStatistics.h"
#include "MMFiles/MMFilesDatafileStatisticsContainer.h"
#include "MMFiles/MMFilesDitch.h"
@ -82,7 +82,7 @@ class MMFilesCollection final : public PhysicalCollection {
MMFilesDatafileStatisticsContainer* _dfi{nullptr};
transaction::Methods* _trx;
ManagedDocumentResult _mmdr;
IndexLookupContext _context;
MMFilesIndexLookupContext _context;
uint64_t _deletions{0};
uint64_t _documents{0};
uint64_t _operations{0};

View File

@ -30,7 +30,7 @@
#include "Basics/StringRef.h"
#include "Basics/fasthash.h"
#include "Basics/hashes.h"
#include "Indexes/IndexLookupContext.h"
#include "MMFiles/MMFilesIndexLookupContext.h"
#include "Indexes/IndexResult.h"
#include "Indexes/SimpleAttributeEqualityMatcher.h"
#include "MMFiles/MMFilesCollection.h"
@ -281,7 +281,7 @@ Result MMFilesEdgeIndex::insert(transaction::Methods* trx,
MMFilesSimpleIndexElement fromElement(buildFromElement(documentId, doc));
MMFilesSimpleIndexElement toElement(buildToElement(documentId, doc));
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, 1);
MMFilesIndexLookupContext context(trx, &_collection, &result, 1);
_edgesFrom->insert(&context, fromElement, true,
mode == OperationMode::rollback);
@ -311,7 +311,7 @@ Result MMFilesEdgeIndex::remove(transaction::Methods* trx,
MMFilesSimpleIndexElement fromElement(buildFromElement(documentId, doc));
MMFilesSimpleIndexElement toElement(buildToElement(documentId, doc));
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, 1);
MMFilesIndexLookupContext context(trx, &_collection, &result, 1);
try {
_edgesFrom->remove(&context, fromElement);
@ -347,10 +347,10 @@ void MMFilesEdgeIndex::batchInsert(
auto creator = [&trx, this]() -> void* {
ManagedDocumentResult* result = new ManagedDocumentResult;
return new IndexLookupContext(trx, &_collection, result, 1);
return new MMFilesIndexLookupContext(trx, &_collection, result, 1);
};
auto destroyer = [](void* userData) {
IndexLookupContext* context = static_cast<IndexLookupContext*>(userData);
MMFilesIndexLookupContext* context = static_cast<MMFilesIndexLookupContext*>(userData);
delete context->result();
delete context;
};
@ -390,7 +390,7 @@ int MMFilesEdgeIndex::sizeHint(transaction::Methods* trx, size_t size) {
// set an initial size for the index for some new nodes to be created
// without resizing
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, 1);
MMFilesIndexLookupContext context(trx, &_collection, &result, 1);
int err = _edgesFrom->resize(&context, size + 2049);
if (err != TRI_ERROR_NO_ERROR) {

View File

@ -29,7 +29,7 @@
#include "Basics/fasthash.h"
#include "Indexes/Index.h"
#include "Indexes/IndexIterator.h"
#include "Indexes/IndexLookupContext.h"
#include "MMFiles/MMFilesIndexLookupContext.h"
#include "MMFiles/MMFilesIndex.h"
#include "MMFiles/MMFilesIndexElement.h"
#include "VocBase/voc-types.h"
@ -70,7 +70,7 @@ struct MMFilesEdgeIndexHelper {
inline bool IsEqualKeyElement(void* userData, VPackSlice const* left,
MMFilesSimpleIndexElement const& right) const {
TRI_ASSERT(left != nullptr);
IndexLookupContext* context = static_cast<IndexLookupContext*>(userData);
MMFilesIndexLookupContext* context = static_cast<MMFilesIndexLookupContext*>(userData);
TRI_ASSERT(context != nullptr);
try {
@ -92,7 +92,7 @@ struct MMFilesEdgeIndexHelper {
inline bool IsEqualElementElementByKey(void* userData,
MMFilesSimpleIndexElement const& left,
MMFilesSimpleIndexElement const& right) const {
IndexLookupContext* context = static_cast<IndexLookupContext*>(userData);
MMFilesIndexLookupContext* context = static_cast<MMFilesIndexLookupContext*>(userData);
try {
VPackSlice lSlice = left.slice(context);
VPackSlice rSlice = right.slice(context);
@ -131,7 +131,7 @@ class MMFilesEdgeIndexIterator final : public IndexIterator {
private:
TRI_MMFilesEdgeIndexHash_t const* _index;
IndexLookupContext _context;
MMFilesIndexLookupContext _context;
std::unique_ptr<arangodb::velocypack::Builder> _keys;
arangodb::velocypack::ArrayIterator _iterator;
std::vector<MMFilesSimpleIndexElement> _buffer;

View File

@ -28,12 +28,13 @@
#include "Basics/Exceptions.h"
#include "Basics/FixedSizeAllocator.h"
#include "Basics/LocalTaskQueue.h"
#include "Basics/SmallVector.h"
#include "Basics/StaticStrings.h"
#include "Basics/VelocyPackHelper.h"
#include "Indexes/IndexLookupContext.h"
#include "Indexes/IndexResult.h"
#include "Indexes/SimpleAttributeEqualityMatcher.h"
#include "MMFiles/MMFilesCollection.h"
#include "MMFiles/MMFilesIndexLookupContext.h"
#include "StorageEngine/TransactionState.h"
#include "Transaction/Context.h"
#include "Transaction/Helpers.h"
@ -48,7 +49,11 @@ MMFilesHashIndexLookupBuilder::MMFilesHashIndexLookupBuilder(
transaction::Methods* trx, arangodb::aql::AstNode const* node,
arangodb::aql::Variable const* reference,
std::vector<std::vector<arangodb::basics::AttributeName>> const& fields)
: _builder(trx), _usesIn(false), _isEmpty(false), _inStorage(trx) {
: _builder(trx),
_usesIn(false),
_isEmpty(false),
_mappingFieldCondition{_mappingFieldConditionArena},
_inStorage(trx) {
TRI_ASSERT(node->type == aql::NODE_TYPE_OPERATOR_NARY_AND);
_coveredFields = fields.size();
TRI_ASSERT(node->numMembers() == _coveredFields);
@ -56,7 +61,11 @@ MMFilesHashIndexLookupBuilder::MMFilesHashIndexLookupBuilder(
std::pair<arangodb::aql::Variable const*,
std::vector<arangodb::basics::AttributeName>>
paramPair;
std::vector<size_t> storageOrder;
_mappingFieldCondition.reserve(_coveredFields);
SmallVector<size_t>::allocator_type::arena_type a;
SmallVector<size_t> storageOrder{a};
for (size_t i = 0; i < _coveredFields; ++i) {
auto comp = node->getMemberUnchecked(i);
@ -82,7 +91,7 @@ MMFilesHashIndexLookupBuilder::MMFilesHashIndexLookupBuilder(
TRI_IF_FAILURE("HashIndex::permutationArrayIN") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
_mappingFieldCondition.emplace(j, valNode);
_mappingFieldCondition.push_back(valNode);
} else {
TRI_IF_FAILURE("HashIndex::permutationEQ") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
@ -98,14 +107,18 @@ MMFilesHashIndexLookupBuilder::MMFilesHashIndexLookupBuilder(
std::make_pair(0, std::vector<arangodb::velocypack::Slice>()));
_usesIn = true;
storageOrder.emplace_back(j);
_mappingFieldCondition.push_back(nullptr);
} else {
_mappingFieldCondition.emplace(j, valNode);
_mappingFieldCondition.push_back(valNode);
}
}
break;
}
}
}
TRI_ASSERT(_mappingFieldCondition.size() == _coveredFields);
if (_usesIn) {
_inStorage->close();
arangodb::basics::VelocyPackHelper::VPackLess<true> sorter;
@ -192,16 +205,20 @@ void MMFilesHashIndexLookupBuilder::buildNextSearchValue() {
if (_isEmpty) {
return;
}
_builder->openArray();
TRI_ASSERT(_mappingFieldCondition.size() >= _coveredFields);
_builder->openArray(true);
if (!_usesIn) {
// Fast path, do no search and checks
for (size_t i = 0; i < _coveredFields; ++i) {
TRI_ASSERT(_mappingFieldCondition[i] != nullptr);
_mappingFieldCondition[i]->toVelocyPackValue(*(_builder.get()));
}
} else {
for (size_t i = 0; i < _coveredFields; ++i) {
auto in = _inPosition.find(i);
if (in != _inPosition.end()) {
TRI_ASSERT(_mappingFieldCondition[i] == nullptr);
_builder->add(in->second.second[in->second.first]);
} else {
_mappingFieldCondition[i]->toVelocyPackValue(*(_builder.get()));
@ -536,7 +553,7 @@ int MMFilesHashIndex::sizeHint(transaction::Methods* trx, size_t size) {
}
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, numPaths());
MMFilesIndexLookupContext context(trx, &_collection, &result, numPaths());
if (_unique) {
return _uniqueArray->_hashArray->resize(&context, size);
@ -554,7 +571,7 @@ int MMFilesHashIndex::lookup(
}
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, numPaths());
MMFilesIndexLookupContext context(trx, &_collection, &result, numPaths());
if (_unique) {
MMFilesHashIndexElement* found =
@ -596,7 +613,7 @@ Result MMFilesHashIndex::insertUnique(transaction::Methods* trx,
}
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, numPaths());
MMFilesIndexLookupContext context(trx, &_collection, &result, numPaths());
auto work = [this, &context](MMFilesHashIndexElement* element,
OperationMode) -> int {
@ -673,10 +690,10 @@ void MMFilesHashIndex::batchInsertUnique(
auto creator = [&trx, this]() -> void* {
ManagedDocumentResult* result = new ManagedDocumentResult;
return new IndexLookupContext(trx, &_collection, result, numPaths());
return new MMFilesIndexLookupContext(trx, &_collection, result, numPaths());
};
auto destroyer = [](void* userData) {
IndexLookupContext* context = static_cast<IndexLookupContext*>(userData);
MMFilesIndexLookupContext* context = static_cast<MMFilesIndexLookupContext*>(userData);
delete context->result();
delete context;
};
@ -714,7 +731,7 @@ int MMFilesHashIndex::insertMulti(transaction::Methods* trx,
}
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, numPaths());
MMFilesIndexLookupContext context(trx, &_collection, &result, numPaths());
auto work = [this, &context](MMFilesHashIndexElement*& element,
OperationMode) {
TRI_IF_FAILURE("InsertHashIndex") {
@ -796,10 +813,10 @@ void MMFilesHashIndex::batchInsertMulti(
// functions that will be called for each thread
auto creator = [&trx, this]() -> void* {
ManagedDocumentResult* result = new ManagedDocumentResult;
return new IndexLookupContext(trx, &_collection, result, numPaths());
return new MMFilesIndexLookupContext(trx, &_collection, result, numPaths());
};
auto destroyer = [](void* userData) {
IndexLookupContext* context = static_cast<IndexLookupContext*>(userData);
MMFilesIndexLookupContext* context = static_cast<MMFilesIndexLookupContext*>(userData);
delete context->result();
delete context;
};
@ -827,7 +844,7 @@ int MMFilesHashIndex::removeUniqueElement(transaction::Methods* trx,
OperationMode mode) {
TRI_IF_FAILURE("RemoveHashIndex") { return TRI_ERROR_DEBUG; }
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, numPaths());
MMFilesIndexLookupContext context(trx, &_collection, &result, numPaths());
MMFilesHashIndexElement* old =
_uniqueArray->_hashArray->remove(&context, element);
@ -851,7 +868,7 @@ int MMFilesHashIndex::removeMultiElement(transaction::Methods* trx,
OperationMode mode) {
TRI_IF_FAILURE("RemoveHashIndex") { return TRI_ERROR_DEBUG; }
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, numPaths());
MMFilesIndexLookupContext context(trx, &_collection, &result, numPaths());
MMFilesHashIndexElement* old =
_multiArray->_hashArray->remove(&context, element);

View File

@ -27,10 +27,11 @@
#include "Basics/AssocMulti.h"
#include "Basics/AssocUnique.h"
#include "Basics/Common.h"
#include "Basics/SmallVector.h"
#include "Basics/VelocyPackHelper.h"
#include "Basics/fasthash.h"
#include "Indexes/IndexIterator.h"
#include "Indexes/IndexLookupContext.h"
#include "MMFiles/MMFilesIndexLookupContext.h"
#include "MMFiles/MMFilesIndexElement.h"
#include "MMFiles/MMFilesPathBasedIndex.h"
#include "Transaction/Helpers.h"
@ -74,7 +75,7 @@ struct MMFilesHashIndexHelper {
MMFilesHashIndexElement const* right) const {
TRI_ASSERT(left->isArray());
TRI_ASSERT(right->isSet());
IndexLookupContext* context = static_cast<IndexLookupContext*>(userData);
MMFilesIndexLookupContext* context = static_cast<MMFilesIndexLookupContext*>(userData);
TRI_ASSERT(context != nullptr);
// TODO: is it a performance improvement to compare the hash values first?
@ -103,7 +104,7 @@ struct MMFilesHashIndexHelper {
return true;
}
IndexLookupContext* context = static_cast<IndexLookupContext*>(userData);
MMFilesIndexLookupContext* context = static_cast<MMFilesIndexLookupContext*>(userData);
for (size_t i = 0; i < _numFields; ++i) {
VPackSlice leftData = left->slice(context, i);
@ -153,7 +154,7 @@ struct MMFilesMultiHashIndexHelper : public MMFilesHashIndexHelper {
return false;
}
IndexLookupContext* context = static_cast<IndexLookupContext*>(userData);
MMFilesIndexLookupContext* context = static_cast<MMFilesIndexLookupContext*>(userData);
TRI_ASSERT(context != nullptr);
for (size_t i = 0; i < context->numFields(); ++i) {
@ -179,8 +180,10 @@ class MMFilesHashIndexLookupBuilder {
bool _usesIn;
bool _isEmpty;
size_t _coveredFields;
std::unordered_map<size_t, arangodb::aql::AstNode const*>
_mappingFieldCondition;
SmallVector<arangodb::aql::AstNode const*> _mappingFieldCondition;
SmallVector<arangodb::aql::AstNode const*>::allocator_type::arena_type _mappingFieldConditionArena;
std::unordered_map<
size_t, std::pair<size_t, std::vector<arangodb::velocypack::Slice>>>
_inPosition;

View File

@ -23,7 +23,7 @@
#include "MMFilesIndexElement.h"
#include "Basics/VelocyPackHelper.h"
#include "Indexes/IndexLookupContext.h"
#include "MMFiles/MMFilesIndexLookupContext.h"
using namespace arangodb;
@ -46,7 +46,7 @@ MMFilesHashIndexElement* MMFilesHashIndexElement::initialize(MMFilesHashIndexEle
/// if offset is non-zero, then it is an offset into the VelocyPack data in
/// the datafile or WAL file. If offset is 0, then data contains the actual data
/// in place.
arangodb::velocypack::Slice MMFilesHashIndexElement::slice(IndexLookupContext* context, size_t position) const {
arangodb::velocypack::Slice MMFilesHashIndexElement::slice(MMFilesIndexLookupContext* context, size_t position) const {
TRI_ASSERT(context->result() != nullptr);
MMFilesIndexElementValue const* sub = subObject(position);
@ -124,7 +124,7 @@ MMFilesSkiplistIndexElement* MMFilesSkiplistIndexElement::initialize(MMFilesSkip
/// if offset is non-zero, then it is an offset into the VelocyPack data in
/// the datafile or WAL file. If offset is 0, then data contains the actual data
/// in place.
arangodb::velocypack::Slice MMFilesSkiplistIndexElement::slice(IndexLookupContext* context, size_t position) const {
arangodb::velocypack::Slice MMFilesSkiplistIndexElement::slice(MMFilesIndexLookupContext* context, size_t position) const {
TRI_ASSERT(context->result() != nullptr);
MMFilesIndexElementValue const* sub = subObject(position);
@ -152,7 +152,7 @@ uint64_t MMFilesSimpleIndexElement::hash(arangodb::velocypack::Slice const& valu
return value.hashString() & 0x00000000FFFFFFFFULL;
}
VPackSlice MMFilesSimpleIndexElement::slice(IndexLookupContext* context) const {
VPackSlice MMFilesSimpleIndexElement::slice(MMFilesIndexLookupContext* context) const {
TRI_ASSERT(context->result() != nullptr);
uint8_t const* vpack = context->lookup(_localDocumentId);
if (vpack == nullptr) {

View File

@ -30,7 +30,7 @@
#include "VocBase/voc-types.h"
namespace arangodb {
class IndexLookupContext;
class MMFilesIndexLookupContext;
namespace velocypack {
class Slice;
@ -62,7 +62,7 @@ struct MMFilesIndexElementValue {
/// if offset is non-zero, then it is an offset into the VelocyPack data in
/// the data or WAL file. If offset is 0, then data contains the actual data
/// in place.
velocypack::Slice slice(IndexLookupContext* context) const;
velocypack::Slice slice(MMFilesIndexLookupContext* context) const;
inline bool isOffset() const noexcept {
return !isInline();
@ -136,7 +136,7 @@ struct MMFilesHashIndexElement {
return reinterpret_cast<MMFilesIndexElementValue const*>(p);
}
arangodb::velocypack::Slice slice(IndexLookupContext* context, size_t position) const;
arangodb::velocypack::Slice slice(MMFilesIndexLookupContext* context, size_t position) const;
static uint64_t hash(arangodb::velocypack::Slice const& values);
static uint64_t hash(std::vector<arangodb::velocypack::Slice> const& values);
@ -191,7 +191,7 @@ struct MMFilesSkiplistIndexElement {
return reinterpret_cast<MMFilesIndexElementValue const*>(p);
}
arangodb::velocypack::Slice slice(IndexLookupContext* context, size_t position) const;
arangodb::velocypack::Slice slice(MMFilesIndexLookupContext* context, size_t position) const;
/// @brief allocate a new index element from a vector of slices
static MMFilesSkiplistIndexElement* initialize(MMFilesSkiplistIndexElement* element,
@ -235,7 +235,7 @@ struct MMFilesSimpleIndexElement {
inline uint32_t offset() const noexcept { return static_cast<uint32_t>((_hashAndOffset & 0xFFFFFFFF00000000ULL) >> 32); }
arangodb::velocypack::Slice slice(IndexLookupContext*) const;
arangodb::velocypack::Slice slice(MMFilesIndexLookupContext*) const;
inline operator bool() const noexcept { return _localDocumentId.isSet(); }

View File

@ -21,27 +21,30 @@
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#include "IndexLookupContext.h"
#include "Transaction/Methods.h"
#include "MMFilesIndexLookupContext.h"
#include "MMFiles/MMFilesCollection.h"
#include "VocBase/LogicalCollection.h"
#include "VocBase/ManagedDocumentResult.h"
using namespace arangodb;
IndexLookupContext::IndexLookupContext(transaction::Methods* trx,
MMFilesIndexLookupContext::MMFilesIndexLookupContext(transaction::Methods* trx,
LogicalCollection* collection,
ManagedDocumentResult* result,
size_t numFields)
: _trx(trx), _collection(collection), _result(result), _numFields(numFields) {
: _trx(trx),
_collection(collection),
_result(result),
_numFields(numFields) {
TRI_ASSERT(_trx != nullptr);
TRI_ASSERT(_collection != nullptr);
// note: _result can be a nullptr
}
uint8_t const* IndexLookupContext::lookup(LocalDocumentId token) {
uint8_t const* MMFilesIndexLookupContext::lookup(LocalDocumentId token) const {
TRI_ASSERT(_result != nullptr);
try {
if (_collection->readDocument(_trx, token, *_result)) {
if (static_cast<MMFilesCollection*>(_collection->getPhysical())->readDocument(_trx, token, *_result)) {
return _result->vpack();
}
} catch (...) {

View File

@ -21,8 +21,8 @@
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#ifndef ARANGOD_INDEXES_INDEX_LOOKUP_CONTEXT_H
#define ARANGOD_INDEXES_INDEX_LOOKUP_CONTEXT_H 1
#ifndef ARANGOD_MMFILES_MMFILES_INDEX_LOOKUP_CONTEXT_H
#define ARANGOD_MMFILES_MMFILES_INDEX_LOOKUP_CONTEXT_H 1
#include "Basics/Common.h"
#include "VocBase/LocalDocumentId.h"
@ -36,22 +36,26 @@ namespace transaction {
class Methods;
}
class IndexLookupContext {
class MMFilesIndexLookupContext {
public:
IndexLookupContext() = delete;
IndexLookupContext(transaction::Methods* trx, LogicalCollection* collection, ManagedDocumentResult* result, size_t numFields);
~IndexLookupContext() {}
MMFilesIndexLookupContext() = delete;
MMFilesIndexLookupContext(transaction::Methods* trx,
LogicalCollection* collection,
ManagedDocumentResult* result,
size_t numFields);
uint8_t const* lookup(LocalDocumentId token);
~MMFilesIndexLookupContext() {}
ManagedDocumentResult* result() { return _result; }
uint8_t const* lookup(LocalDocumentId token) const;
ManagedDocumentResult* result() const { return _result; }
inline size_t numFields() const { return _numFields; }
private:
transaction::Methods* _trx;
LogicalCollection* _collection;
ManagedDocumentResult* _result;
mutable ManagedDocumentResult* _result;
size_t const _numFields;
};

View File

@ -28,7 +28,7 @@
#include "Basics/FixedSizeAllocator.h"
#include "Basics/StaticStrings.h"
#include "Basics/VelocyPackHelper.h"
#include "Indexes/IndexLookupContext.h"
#include "MMFiles/MMFilesIndexLookupContext.h"
#include "Indexes/IndexResult.h"
#include "Indexes/PersistentIndexAttributeMatcher.h"
#include "MMFiles/MMFilesCollection.h"
@ -342,7 +342,7 @@ Result MMFilesPersistentIndex::insert(transaction::Methods* trx,
}
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, numPaths());
MMFilesIndexLookupContext context(trx, &_collection, &result, numPaths());
VPackSlice const key = transaction::helpers::extractKeyFromDocument(doc);
auto prefix = buildPrefix(trx->vocbase().id(), _collection.id(), _iid);
VPackBuilder builder;
@ -523,7 +523,7 @@ Result MMFilesPersistentIndex::remove(transaction::Methods* trx,
}
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, numPaths());
MMFilesIndexLookupContext context(trx, &_collection, &result, numPaths());
VPackSlice const key = transaction::helpers::extractKeyFromDocument(doc);
VPackBuilder builder;
std::vector<std::string> values;

View File

@ -27,7 +27,7 @@
#include "Basics/StaticStrings.h"
#include "Basics/hashes.h"
#include "Basics/tri-strings.h"
#include "Indexes/IndexLookupContext.h"
#include "MMFiles/MMFilesIndexLookupContext.h"
#include "Indexes/IndexResult.h"
#include "Indexes/SimpleAttributeEqualityMatcher.h"
#include "MMFiles/MMFilesCollection.h"
@ -335,7 +335,7 @@ MMFilesSimpleIndexElement MMFilesPrimaryIndex::lookupKey(
MMFilesSimpleIndexElement MMFilesPrimaryIndex::lookupKey(
transaction::Methods* trx, VPackSlice const& key,
ManagedDocumentResult& mmdr) const {
IndexLookupContext context(trx, &_collection, &mmdr, 1);
MMFilesIndexLookupContext context(trx, &_collection, &mmdr, 1);
TRI_ASSERT(key.isString());
return _primaryIndex->findByKey(&context, key.begin());
@ -345,7 +345,7 @@ MMFilesSimpleIndexElement MMFilesPrimaryIndex::lookupKey(
MMFilesSimpleIndexElement* MMFilesPrimaryIndex::lookupKeyRef(
transaction::Methods* trx, VPackSlice const& key) const {
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, 1);
MMFilesIndexLookupContext context(trx, &_collection, &result, 1);
TRI_ASSERT(key.isString());
MMFilesSimpleIndexElement* element =
_primaryIndex->findByKeyRef(&context, key.begin());
@ -362,7 +362,7 @@ MMFilesSimpleIndexElement* MMFilesPrimaryIndex::lookupKeyRef(
MMFilesSimpleIndexElement* MMFilesPrimaryIndex::lookupKeyRef(
transaction::Methods* trx, VPackSlice const& key,
ManagedDocumentResult& mmdr) const {
IndexLookupContext context(trx, &_collection, &mmdr, 1);
MMFilesIndexLookupContext context(trx, &_collection, &mmdr, 1);
TRI_ASSERT(key.isString());
MMFilesSimpleIndexElement* element =
_primaryIndex->findByKeyRef(&context, key.begin());
@ -384,7 +384,7 @@ MMFilesSimpleIndexElement MMFilesPrimaryIndex::lookupSequential(
transaction::Methods* trx, arangodb::basics::BucketPosition& position,
uint64_t& total) {
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, 1);
MMFilesIndexLookupContext context(trx, &_collection, &result, 1);
return _primaryIndex->findSequential(&context, position, total);
}
@ -414,7 +414,7 @@ IndexIterator* MMFilesPrimaryIndex::anyIterator(transaction::Methods* trx) const
MMFilesSimpleIndexElement MMFilesPrimaryIndex::lookupSequentialReverse(
transaction::Methods* trx, arangodb::basics::BucketPosition& position) {
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, 1);
MMFilesIndexLookupContext context(trx, &_collection, &result, 1);
return _primaryIndex->findSequentialReverse(&context, position);
}
@ -433,10 +433,10 @@ Result MMFilesPrimaryIndex::insertKey(transaction::Methods* trx,
VPackSlice const& doc,
ManagedDocumentResult& mmdr,
OperationMode mode) {
IndexLookupContext context(trx, &_collection, &mmdr, 1);
MMFilesIndexLookupContext context(trx, &_collection, &mmdr, 1);
MMFilesSimpleIndexElement element(buildKeyElement(documentId, doc));
// TODO: we can pass in a special IndexLookupContext which has some more on the information
// TODO: we can pass in a special MMFilesIndexLookupContext which has some more on the information
// about the to-be-inserted document. this way we can spare one lookup in
// IsEqualElementElementByKey
int res = _primaryIndex->insert(&context, element);
@ -467,7 +467,7 @@ Result MMFilesPrimaryIndex::removeKey(transaction::Methods* trx,
VPackSlice const& doc,
ManagedDocumentResult& mmdr,
OperationMode mode) {
IndexLookupContext context(trx, &_collection, &mmdr, 1);
MMFilesIndexLookupContext context(trx, &_collection, &mmdr, 1);
VPackSlice keySlice(transaction::helpers::extractKeyFromDocument(doc));
MMFilesSimpleIndexElement found =
_primaryIndex->removeByKey(&context, keySlice.begin());
@ -482,7 +482,7 @@ Result MMFilesPrimaryIndex::removeKey(transaction::Methods* trx,
/// @brief resizes the index
int MMFilesPrimaryIndex::resize(transaction::Methods* trx, size_t targetSize) {
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, 1);
MMFilesIndexLookupContext context(trx, &_collection, &result, 1);
return _primaryIndex->resize(&context, targetSize);
}

View File

@ -27,7 +27,7 @@
#include "Basics/AssocUnique.h"
#include "Basics/Common.h"
#include "Indexes/IndexIterator.h"
#include "Indexes/IndexLookupContext.h"
#include "MMFiles/MMFilesIndexLookupContext.h"
#include "MMFiles/MMFilesIndex.h"
#include "MMFiles/MMFilesIndexElement.h"
#include "VocBase/voc-types.h"
@ -57,7 +57,7 @@ struct MMFilesPrimaryIndexHelper {
/// @brief determines if a key corresponds to an element
inline bool IsEqualKeyElement(void* userData, uint8_t const* key,
MMFilesSimpleIndexElement const& right) const {
IndexLookupContext* context = static_cast<IndexLookupContext*>(userData);
MMFilesIndexLookupContext* context = static_cast<MMFilesIndexLookupContext*>(userData);
TRI_ASSERT(context != nullptr);
try {
@ -83,7 +83,7 @@ struct MMFilesPrimaryIndexHelper {
// TODO: check if we have many collisions here
return false;
}
IndexLookupContext* context = static_cast<IndexLookupContext*>(userData);
MMFilesIndexLookupContext* context = static_cast<MMFilesIndexLookupContext*>(userData);
TRI_ASSERT(context != nullptr);
VPackSlice l = left.slice(context);

View File

@ -29,7 +29,7 @@
#include "Basics/FixedSizeAllocator.h"
#include "Basics/StaticStrings.h"
#include "Basics/VelocyPackHelper.h"
#include "Indexes/IndexLookupContext.h"
#include "MMFiles/MMFilesIndexLookupContext.h"
#include "Indexes/IndexResult.h"
#include "Indexes/SkiplistIndexAttributeMatcher.h"
#include "MMFiles/MMFilesCollection.h"
@ -67,7 +67,7 @@ using namespace arangodb;
static int CompareKeyElement(void* userData, VPackSlice const* left,
MMFilesSkiplistIndexElement const* right,
size_t rightPosition) {
IndexLookupContext* context = static_cast<IndexLookupContext*>(userData);
MMFilesIndexLookupContext* context = static_cast<MMFilesIndexLookupContext*>(userData);
TRI_ASSERT(nullptr != left);
TRI_ASSERT(nullptr != right);
return arangodb::basics::VelocyPackHelper::compare(
@ -80,7 +80,7 @@ static int CompareElementElement(void* userData,
size_t leftPosition,
MMFilesSkiplistIndexElement const* right,
size_t rightPosition) {
IndexLookupContext* context = static_cast<IndexLookupContext*>(userData);
MMFilesIndexLookupContext* context = static_cast<MMFilesIndexLookupContext*>(userData);
TRI_ASSERT(nullptr != left);
TRI_ASSERT(nullptr != right);
@ -778,7 +778,7 @@ Result MMFilesSkiplistIndex::insert(transaction::Methods* trx,
}
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, numPaths());
MMFilesIndexLookupContext context(trx, &_collection, &result, numPaths());
// insert into the index. the memory for the element will be owned or freed
// by the index
@ -881,7 +881,7 @@ Result MMFilesSkiplistIndex::remove(transaction::Methods* trx,
}
ManagedDocumentResult result;
IndexLookupContext context(trx, &_collection, &result, numPaths());
MMFilesIndexLookupContext context(trx, &_collection, &result, numPaths());
// attempt the removal for skiplist indexes
// ownership for the index element is transferred to the index

View File

@ -27,7 +27,7 @@
#include "Aql/AstNode.h"
#include "Basics/Common.h"
#include "Indexes/IndexIterator.h"
#include "Indexes/IndexLookupContext.h"
#include "MMFiles/MMFilesIndexLookupContext.h"
#include "MMFiles/MMFilesIndexElement.h"
#include "MMFiles/MMFilesPathBasedIndex.h"
#include "MMFiles/MMFilesSkiplist.h"
@ -174,7 +174,7 @@ class MMFilesSkiplistIterator final : public IndexIterator {
private:
TRI_Skiplist const* _skiplistIndex;
IndexLookupContext _context;
MMFilesIndexLookupContext _context;
size_t _numPaths;
bool _reverse;
Node* _cursor;

View File

@ -147,7 +147,7 @@ VPackBuilder* transaction::Context::leaseBuilder() {
void transaction::Context::returnBuilder(VPackBuilder* builder) {
try {
// put builder back into our vector of builders
_builders.emplace_back(builder);
_builders.push_back(builder);
} catch (...) {
// no harm done. just wipe the builder
delete builder;

View File

@ -45,11 +45,11 @@ using namespace arangodb;
#ifdef ARANGODB_ENABLE_FAILURE_TESTS
namespace {
/// @brief a global set containing the currently registered failure points
std::unordered_set<std::string> failurePoints;
/// @brief a read-write lock for thread-safe access to the failure points set
arangodb::basics::ReadWriteLock failurePointsLock;
/// @brief a global set containing the currently registered failure points
std::set<std::string> failurePoints;
}
/// @brief cause a segmentation violation