1
0
Fork 0

class renaming

This commit is contained in:
jsteemann 2017-03-08 17:54:00 +01:00
parent 3e0969da37
commit 6b882ca8a2
20 changed files with 165 additions and 173 deletions

View File

@ -71,9 +71,9 @@ using Helper = arangodb::basics::VelocyPackHelper;
namespace { namespace {
/// @brief helper class for filling indexes /// @brief helper class for filling indexes
class IndexFillerTask : public basics::LocalTask { class MMFilesIndexFillerTask : public basics::LocalTask {
public: public:
IndexFillerTask( MMFilesIndexFillerTask(
basics::LocalTaskQueue* queue, transaction::Methods* trx, basics::LocalTaskQueue* queue, transaction::Methods* trx,
Index* idx, Index* idx,
std::vector<std::pair<TRI_voc_rid_t, VPackSlice>> const& documents) std::vector<std::pair<TRI_voc_rid_t, VPackSlice>> const& documents)
@ -1426,8 +1426,8 @@ void MMFilesCollection::fillIndex(
try { try {
// move task into thread pool // move task into thread pool
std::shared_ptr<::IndexFillerTask> worker; std::shared_ptr<::MMFilesIndexFillerTask> worker;
worker.reset(new ::IndexFillerTask(queue, trx, idx, documents)); worker.reset(new ::MMFilesIndexFillerTask(queue, trx, idx, documents));
queue->enqueue(worker); queue->enqueue(worker);
} catch (...) { } catch (...) {
// set error code // set error code

View File

@ -398,7 +398,7 @@ int MMFilesCollectorThread::collectLogfiles(bool& worked) {
// reset collector status // reset collector status
broadcastCollectorResult(res); broadcastCollectorResult(res);
PersistentIndexFeature::syncWal(); MMFilesPersistentIndexFeature::syncWal();
_logfileManager->setCollectionDone(logfile); _logfileManager->setCollectionDone(logfile);
} else { } else {

View File

@ -130,19 +130,16 @@ std::string const MMFilesEngine::FeatureName("MMFilesEngine");
MMFilesEngine::MMFilesEngine(application_features::ApplicationServer* server) MMFilesEngine::MMFilesEngine(application_features::ApplicationServer* server)
: StorageEngine(server, EngineName, FeatureName, new MMFilesIndexFactory()) : StorageEngine(server, EngineName, FeatureName, new MMFilesIndexFactory())
, _isUpgrade(false) , _isUpgrade(false)
, _maxTick(0) , _maxTick(0) {
{ startsAfter("MMFilesPersistentIndex");
startsAfter("PersistentIndex");
}
MMFilesEngine::~MMFilesEngine() {
} }
MMFilesEngine::~MMFilesEngine() {}
// perform a physical deletion of the database // perform a physical deletion of the database
void MMFilesEngine::dropDatabase(Database* database, int& status) { void MMFilesEngine::dropDatabase(Database* database, int& status) {
// delete persistent indexes for this database // delete persistent indexes for this database
PersistentIndexFeature::dropDatabase(database->id()); MMFilesPersistentIndexFeature::dropDatabase(database->id());
// To shutdown the database (which destroys all LogicalCollection // To shutdown the database (which destroys all LogicalCollection
// objects of all collections) we need to make sure that the // objects of all collections) we need to make sure that the
@ -382,7 +379,7 @@ void MMFilesEngine::getDatabases(arangodb::velocypack::Builder& result) {
// delete persistent indexes for this database // delete persistent indexes for this database
TRI_voc_tick_t id = static_cast<TRI_voc_tick_t>( TRI_voc_tick_t id = static_cast<TRI_voc_tick_t>(
basics::StringUtils::uint64(idSlice.copyString())); basics::StringUtils::uint64(idSlice.copyString()));
PersistentIndexFeature::dropDatabase(id); MMFilesPersistentIndexFeature::dropDatabase(id);
dropDatabaseDirectory(directory); dropDatabaseDirectory(directory);
continue; continue;
@ -737,7 +734,7 @@ void MMFilesEngine::dropCollection(TRI_vocbase_t* vocbase, arangodb::LogicalColl
unregisterCollectionPath(vocbase->id(), collection->cid()); unregisterCollectionPath(vocbase->id(), collection->cid());
// delete persistent indexes // delete persistent indexes
PersistentIndexFeature::dropCollection(vocbase->id(), collection->cid()); MMFilesPersistentIndexFeature::dropCollection(vocbase->id(), collection->cid());
// rename collection directory // rename collection directory
if (physical->path().empty()) { if (physical->path().empty()) {

View File

@ -43,7 +43,7 @@
using namespace arangodb; using namespace arangodb;
LookupBuilder::LookupBuilder( MMFilesHashIndexLookupBuilder::MMFilesHashIndexLookupBuilder(
transaction::Methods* trx, arangodb::aql::AstNode const* node, transaction::Methods* trx, arangodb::aql::AstNode const* node,
arangodb::aql::Variable const* reference, arangodb::aql::Variable const* reference,
std::vector<std::vector<arangodb::basics::AttributeName>> const& fields) std::vector<std::vector<arangodb::basics::AttributeName>> const& fields)
@ -138,9 +138,9 @@ LookupBuilder::LookupBuilder(
buildNextSearchValue(); buildNextSearchValue();
} }
VPackSlice LookupBuilder::lookup() { return _builder->slice(); } VPackSlice MMFilesHashIndexLookupBuilder::lookup() { return _builder->slice(); }
bool LookupBuilder::hasAndGetNext() { bool MMFilesHashIndexLookupBuilder::hasAndGetNext() {
_builder->clear(); _builder->clear();
if (!_usesIn || _isEmpty) { if (!_usesIn || _isEmpty) {
return false; return false;
@ -152,7 +152,7 @@ bool LookupBuilder::hasAndGetNext() {
return true; return true;
} }
void LookupBuilder::reset() { void MMFilesHashIndexLookupBuilder::reset() {
if (_isEmpty) { if (_isEmpty) {
return; return;
} }
@ -164,7 +164,7 @@ void LookupBuilder::reset() {
buildNextSearchValue(); buildNextSearchValue();
} }
bool LookupBuilder::incrementInPosition() { bool MMFilesHashIndexLookupBuilder::incrementInPosition() {
size_t i = _coveredFields - 1; size_t i = _coveredFields - 1;
while (true) { while (true) {
auto it = _inPosition.find(i); auto it = _inPosition.find(i);
@ -185,7 +185,7 @@ bool LookupBuilder::incrementInPosition() {
} }
} }
void LookupBuilder::buildNextSearchValue() { void MMFilesHashIndexLookupBuilder::buildNextSearchValue() {
if (_isEmpty) { if (_isEmpty) {
return; return;
} }

View File

@ -50,7 +50,7 @@ class LocalTaskQueue;
class MMFilesHashIndex; class MMFilesHashIndex;
/// @brief Class to build Slice lookups out of AST Conditions /// @brief Class to build Slice lookups out of AST Conditions
class LookupBuilder { class MMFilesHashIndexLookupBuilder {
private: private:
transaction::BuilderLeaser _builder; transaction::BuilderLeaser _builder;
bool _usesIn; bool _usesIn;
@ -64,7 +64,7 @@ class LookupBuilder {
transaction::BuilderLeaser _inStorage; transaction::BuilderLeaser _inStorage;
public: public:
LookupBuilder( MMFilesHashIndexLookupBuilder(
transaction::Methods*, arangodb::aql::AstNode const*, transaction::Methods*, arangodb::aql::AstNode const*,
arangodb::aql::Variable const*, arangodb::aql::Variable const*,
std::vector<std::vector<arangodb::basics::AttributeName>> const&); std::vector<std::vector<arangodb::basics::AttributeName>> const&);
@ -100,7 +100,7 @@ class MMFilesHashIndexIterator final : public IndexIterator {
private: private:
MMFilesHashIndex const* _index; MMFilesHashIndex const* _index;
LookupBuilder _lookups; MMFilesHashIndexLookupBuilder _lookups;
std::vector<MMFilesHashIndexElement*> _buffer; std::vector<MMFilesHashIndexElement*> _buffer;
size_t _posInBuffer; size_t _posInBuffer;
}; };

View File

@ -421,7 +421,7 @@ std::shared_ptr<Index> MMFilesIndexFactory::prepareIndexFromSlice(
break; break;
} }
case arangodb::Index::TRI_IDX_TYPE_ROCKSDB_INDEX: { case arangodb::Index::TRI_IDX_TYPE_ROCKSDB_INDEX: {
newIdx.reset(new arangodb::PersistentIndex(iid, col, info)); newIdx.reset(new arangodb::MMFilesPersistentIndex(iid, col, info));
break; break;
} }
case arangodb::Index::TRI_IDX_TYPE_FULLTEXT_INDEX: { case arangodb::Index::TRI_IDX_TYPE_FULLTEXT_INDEX: {

View File

@ -86,10 +86,10 @@ static size_t sortWeight(arangodb::aql::AstNode const* node) {
// lists: lexicographically and within each slot according to these rules. // lists: lexicographically and within each slot according to these rules.
// ........................................................................... // ...........................................................................
PersistentIndexIterator::PersistentIndexIterator(LogicalCollection* collection, MMFilesPersistentIndexIterator::MMFilesPersistentIndexIterator(LogicalCollection* collection,
transaction::Methods* trx, transaction::Methods* trx,
ManagedDocumentResult* mmdr, ManagedDocumentResult* mmdr,
arangodb::PersistentIndex const* index, arangodb::MMFilesPersistentIndex const* index,
arangodb::MMFilesPrimaryIndex* primaryIndex, arangodb::MMFilesPrimaryIndex* primaryIndex,
rocksdb::OptimisticTransactionDB* db, rocksdb::OptimisticTransactionDB* db,
bool reverse, bool reverse,
@ -102,17 +102,17 @@ PersistentIndexIterator::PersistentIndexIterator(LogicalCollection* collection,
_probe(false) { _probe(false) {
TRI_idx_iid_t const id = index->id(); TRI_idx_iid_t const id = index->id();
std::string const prefix = PersistentIndex::buildPrefix( std::string const prefix = MMFilesPersistentIndex::buildPrefix(
trx->vocbase()->id(), _primaryIndex->collection()->cid(), id); trx->vocbase()->id(), _primaryIndex->collection()->cid(), id);
TRI_ASSERT(prefix.size() == PersistentIndex::keyPrefixSize()); TRI_ASSERT(prefix.size() == MMFilesPersistentIndex::keyPrefixSize());
_leftEndpoint.reset(new arangodb::velocypack::Buffer<char>()); _leftEndpoint.reset(new arangodb::velocypack::Buffer<char>());
_leftEndpoint->reserve(PersistentIndex::keyPrefixSize() + left.byteSize()); _leftEndpoint->reserve(MMFilesPersistentIndex::keyPrefixSize() + left.byteSize());
_leftEndpoint->append(prefix.c_str(), prefix.size()); _leftEndpoint->append(prefix.c_str(), prefix.size());
_leftEndpoint->append(left.startAs<char const>(), left.byteSize()); _leftEndpoint->append(left.startAs<char const>(), left.byteSize());
_rightEndpoint.reset(new arangodb::velocypack::Buffer<char>()); _rightEndpoint.reset(new arangodb::velocypack::Buffer<char>());
_rightEndpoint->reserve(PersistentIndex::keyPrefixSize() + right.byteSize()); _rightEndpoint->reserve(MMFilesPersistentIndex::keyPrefixSize() + right.byteSize());
_rightEndpoint->append(prefix.c_str(), prefix.size()); _rightEndpoint->append(prefix.c_str(), prefix.size());
_rightEndpoint->append(right.startAs<char const>(), right.byteSize()); _rightEndpoint->append(right.startAs<char const>(), right.byteSize());
@ -129,7 +129,7 @@ PersistentIndexIterator::PersistentIndexIterator(LogicalCollection* collection,
} }
/// @brief Reset the cursor /// @brief Reset the cursor
void PersistentIndexIterator::reset() { void MMFilesPersistentIndexIterator::reset() {
if (_reverse) { if (_reverse) {
_probe = true; _probe = true;
_cursor->Seek(rocksdb::Slice(_rightEndpoint->data(), _rightEndpoint->size())); _cursor->Seek(rocksdb::Slice(_rightEndpoint->data(), _rightEndpoint->size()));
@ -141,8 +141,8 @@ void PersistentIndexIterator::reset() {
} }
} }
bool PersistentIndexIterator::next(TokenCallback const& cb, size_t limit) { bool MMFilesPersistentIndexIterator::next(TokenCallback const& cb, size_t limit) {
auto comparator = PersistentIndexFeature::instance()->comparator(); auto comparator = MMFilesPersistentIndexFeature::instance()->comparator();
while (limit > 0) { while (limit > 0) {
if (!_cursor->Valid()) { if (!_cursor->Valid()) {
// We are exhausted already, sorry // We are exhausted already, sorry
@ -150,10 +150,10 @@ bool PersistentIndexIterator::next(TokenCallback const& cb, size_t limit) {
} }
rocksdb::Slice key = _cursor->key(); rocksdb::Slice key = _cursor->key();
// LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "cursor key: " << VPackSlice(key.data() + PersistentIndex::keyPrefixSize()).toJson(); // LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "cursor key: " << VPackSlice(key.data() + MMFilesPersistentIndex::keyPrefixSize()).toJson();
int res = comparator->Compare(key, rocksdb::Slice(_leftEndpoint->data(), _leftEndpoint->size())); int res = comparator->Compare(key, rocksdb::Slice(_leftEndpoint->data(), _leftEndpoint->size()));
// LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "comparing: " << VPackSlice(key.data() + PersistentIndex::keyPrefixSize()).toJson() << " with " << VPackSlice((char const*) _leftEndpoint->data() + PersistentIndex::keyPrefixSize()).toJson() << " - res: " << res; // LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "comparing: " << VPackSlice(key.data() + MMFilesPersistentIndex::keyPrefixSize()).toJson() << " with " << VPackSlice((char const*) _leftEndpoint->data() + MMFilesPersistentIndex::keyPrefixSize()).toJson() << " - res: " << res;
if (res < 0) { if (res < 0) {
if (_reverse) { if (_reverse) {
@ -166,7 +166,7 @@ bool PersistentIndexIterator::next(TokenCallback const& cb, size_t limit) {
} }
res = comparator->Compare(key, rocksdb::Slice(_rightEndpoint->data(), _rightEndpoint->size())); res = comparator->Compare(key, rocksdb::Slice(_rightEndpoint->data(), _rightEndpoint->size()));
// LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "comparing: " << VPackSlice(key.data() + PersistentIndex::keyPrefixSize()).toJson() << " with " << VPackSlice((char const*) _rightEndpoint->data() + PersistentIndex::keyPrefixSize()).toJson() << " - res: " << res; // LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "comparing: " << VPackSlice(key.data() + MMFilesPersistentIndex::keyPrefixSize()).toJson() << " with " << VPackSlice((char const*) _rightEndpoint->data() + MMFilesPersistentIndex::keyPrefixSize()).toJson() << " - res: " << res;
if (res <= 0) { if (res <= 0) {
@ -207,21 +207,21 @@ bool PersistentIndexIterator::next(TokenCallback const& cb, size_t limit) {
} }
/// @brief create the index /// @brief create the index
PersistentIndex::PersistentIndex(TRI_idx_iid_t iid, MMFilesPersistentIndex::MMFilesPersistentIndex(TRI_idx_iid_t iid,
arangodb::LogicalCollection* collection, arangodb::LogicalCollection* collection,
arangodb::velocypack::Slice const& info) arangodb::velocypack::Slice const& info)
: MMFilesPathBasedIndex(iid, collection, info, 0, true), : MMFilesPathBasedIndex(iid, collection, info, 0, true),
_db(PersistentIndexFeature::instance()->db()) {} _db(MMFilesPersistentIndexFeature::instance()->db()) {}
/// @brief destroy the index /// @brief destroy the index
PersistentIndex::~PersistentIndex() {} MMFilesPersistentIndex::~MMFilesPersistentIndex() {}
size_t PersistentIndex::memory() const { size_t MMFilesPersistentIndex::memory() const {
return 0; // TODO return 0; // TODO
} }
/// @brief return a VelocyPack representation of the index /// @brief return a VelocyPack representation of the index
void PersistentIndex::toVelocyPack(VPackBuilder& builder, void MMFilesPersistentIndex::toVelocyPack(VPackBuilder& builder,
bool withFigures) const { bool withFigures) const {
Index::toVelocyPack(builder, withFigures); Index::toVelocyPack(builder, withFigures);
builder.add("unique", VPackValue(_unique)); builder.add("unique", VPackValue(_unique));
@ -229,15 +229,15 @@ void PersistentIndex::toVelocyPack(VPackBuilder& builder,
} }
/// @brief return a VelocyPack representation of the index figures /// @brief return a VelocyPack representation of the index figures
void PersistentIndex::toVelocyPackFigures(VPackBuilder& builder) const { void MMFilesPersistentIndex::toVelocyPackFigures(VPackBuilder& builder) const {
TRI_ASSERT(builder.isOpenObject()); TRI_ASSERT(builder.isOpenObject());
builder.add("memory", VPackValue(memory())); builder.add("memory", VPackValue(memory()));
} }
/// @brief inserts a document into the index /// @brief inserts a document into the index
int PersistentIndex::insert(transaction::Methods* trx, TRI_voc_rid_t revisionId, int MMFilesPersistentIndex::insert(transaction::Methods* trx, TRI_voc_rid_t revisionId,
VPackSlice const& doc, bool isRollback) { VPackSlice const& doc, bool isRollback) {
auto comparator = PersistentIndexFeature::instance()->comparator(); auto comparator = MMFilesPersistentIndexFeature::instance()->comparator();
std::vector<MMFilesSkiplistIndexElement*> elements; std::vector<MMFilesSkiplistIndexElement*> elements;
int res; int res;
@ -394,7 +394,7 @@ int PersistentIndex::insert(transaction::Methods* trx, TRI_voc_rid_t revisionId,
} }
/// @brief removes a document from the index /// @brief removes a document from the index
int PersistentIndex::remove(transaction::Methods* trx, TRI_voc_rid_t revisionId, int MMFilesPersistentIndex::remove(transaction::Methods* trx, TRI_voc_rid_t revisionId,
VPackSlice const& doc, bool isRollback) { VPackSlice const& doc, bool isRollback) {
std::vector<MMFilesSkiplistIndexElement*> elements; std::vector<MMFilesSkiplistIndexElement*> elements;
@ -460,21 +460,21 @@ int PersistentIndex::remove(transaction::Methods* trx, TRI_voc_rid_t revisionId,
return res; return res;
} }
int PersistentIndex::unload() { int MMFilesPersistentIndex::unload() {
// nothing to do // nothing to do
return TRI_ERROR_NO_ERROR; return TRI_ERROR_NO_ERROR;
} }
/// @brief called when the index is dropped /// @brief called when the index is dropped
int PersistentIndex::drop() { int MMFilesPersistentIndex::drop() {
return PersistentIndexFeature::instance()->dropIndex(_collection->vocbase()->id(), return MMFilesPersistentIndexFeature::instance()->dropIndex(_collection->vocbase()->id(),
_collection->cid(), _iid); _collection->cid(), _iid);
} }
/// @brief attempts to locate an entry in the index /// @brief attempts to locate an entry in the index
/// Warning: who ever calls this function is responsible for destroying /// Warning: who ever calls this function is responsible for destroying
/// the PersistentIndexIterator* results /// the MMFilesPersistentIndexIterator* results
PersistentIndexIterator* PersistentIndex::lookup(transaction::Methods* trx, MMFilesPersistentIndexIterator* MMFilesPersistentIndex::lookup(transaction::Methods* trx,
ManagedDocumentResult* mmdr, ManagedDocumentResult* mmdr,
VPackSlice const searchValues, VPackSlice const searchValues,
bool reverse) const { bool reverse) const {
@ -573,17 +573,17 @@ PersistentIndexIterator* PersistentIndex::lookup(transaction::Methods* trx,
// Same for the iterator // Same for the iterator
auto physical = static_cast<MMFilesCollection*>(_collection->getPhysical()); auto physical = static_cast<MMFilesCollection*>(_collection->getPhysical());
auto idx = physical->primaryIndex(); auto idx = physical->primaryIndex();
return new PersistentIndexIterator(_collection, trx, mmdr, this, idx, _db, reverse, leftBorder, rightBorder); return new MMFilesPersistentIndexIterator(_collection, trx, mmdr, this, idx, _db, reverse, leftBorder, rightBorder);
} }
bool PersistentIndex::accessFitsIndex( bool MMFilesPersistentIndex::accessFitsIndex(
arangodb::aql::AstNode const* access, arangodb::aql::AstNode const* other, arangodb::aql::AstNode const* access, arangodb::aql::AstNode const* other,
arangodb::aql::AstNode const* op, arangodb::aql::Variable const* reference, arangodb::aql::AstNode const* op, arangodb::aql::Variable const* reference,
std::unordered_map<size_t, std::vector<arangodb::aql::AstNode const*>>& std::unordered_map<size_t, std::vector<arangodb::aql::AstNode const*>>&
found, found,
std::unordered_set<std::string>& nonNullAttributes, std::unordered_set<std::string>& nonNullAttributes,
bool isExecution) const { bool isExecution) const {
if (!this->canUseConditionPart(access, other, op, reference, nonNullAttributes, isExecution)) { if (!canUseConditionPart(access, other, op, reference, nonNullAttributes, isExecution)) {
return false; return false;
} }
@ -674,7 +674,7 @@ bool PersistentIndex::accessFitsIndex(
return false; return false;
} }
void PersistentIndex::matchAttributes( void MMFilesPersistentIndex::matchAttributes(
arangodb::aql::AstNode const* node, arangodb::aql::AstNode const* node,
arangodb::aql::Variable const* reference, arangodb::aql::Variable const* reference,
std::unordered_map<size_t, std::vector<arangodb::aql::AstNode const*>>& std::unordered_map<size_t, std::vector<arangodb::aql::AstNode const*>>&
@ -716,7 +716,7 @@ void PersistentIndex::matchAttributes(
} }
} }
bool PersistentIndex::supportsFilterCondition( bool MMFilesPersistentIndex::supportsFilterCondition(
arangodb::aql::AstNode const* node, arangodb::aql::AstNode const* node,
arangodb::aql::Variable const* reference, size_t itemsInIndex, arangodb::aql::Variable const* reference, size_t itemsInIndex,
size_t& estimatedItems, double& estimatedCost) const { size_t& estimatedItems, double& estimatedCost) const {
@ -816,7 +816,7 @@ bool PersistentIndex::supportsFilterCondition(
return false; return false;
} }
bool PersistentIndex::supportsSortCondition( bool MMFilesPersistentIndex::supportsSortCondition(
arangodb::aql::SortCondition const* sortCondition, arangodb::aql::SortCondition const* sortCondition,
arangodb::aql::Variable const* reference, size_t itemsInIndex, arangodb::aql::Variable const* reference, size_t itemsInIndex,
double& estimatedCost, size_t& coveredAttributes) const { double& estimatedCost, size_t& coveredAttributes) const {
@ -862,7 +862,7 @@ bool PersistentIndex::supportsSortCondition(
return false; return false;
} }
IndexIterator* PersistentIndex::iteratorForCondition( IndexIterator* MMFilesPersistentIndex::iteratorForCondition(
transaction::Methods* trx, transaction::Methods* trx,
ManagedDocumentResult* mmdr, ManagedDocumentResult* mmdr,
arangodb::aql::AstNode const* node, arangodb::aql::AstNode const* node,
@ -1054,7 +1054,7 @@ IndexIterator* PersistentIndex::iteratorForCondition(
} }
/// @brief specializes the condition for use with the index /// @brief specializes the condition for use with the index
arangodb::aql::AstNode* PersistentIndex::specializeCondition( arangodb::aql::AstNode* MMFilesPersistentIndex::specializeCondition(
arangodb::aql::AstNode* node, arangodb::aql::AstNode* node,
arangodb::aql::Variable const* reference) const { arangodb::aql::Variable const* reference) const {
std::unordered_map<size_t, std::vector<arangodb::aql::AstNode const*>> found; std::unordered_map<size_t, std::vector<arangodb::aql::AstNode const*>> found;
@ -1116,7 +1116,7 @@ arangodb::aql::AstNode* PersistentIndex::specializeCondition(
return node; return node;
} }
bool PersistentIndex::isDuplicateOperator( bool MMFilesPersistentIndex::isDuplicateOperator(
arangodb::aql::AstNode const* node, arangodb::aql::AstNode const* node,
std::unordered_set<int> const& operatorsFound) const { std::unordered_set<int> const& operatorsFound) const {
auto type = node->type; auto type = node->type;

View File

@ -50,28 +50,27 @@ struct Variable;
class LogicalCollection; class LogicalCollection;
class MMFilesPrimaryIndex; class MMFilesPrimaryIndex;
class PersistentIndex; class MMFilesPersistentIndex;
namespace transaction { namespace transaction {
class Methods; class Methods;
} }
;
/// @brief Iterator structure for RocksDB. We require a start and stop node /// @brief Iterator structure for RocksDB. We require a start and stop node
class PersistentIndexIterator final : public IndexIterator { class MMFilesPersistentIndexIterator final : public IndexIterator {
private: private:
friend class PersistentIndex; friend class MMFilesPersistentIndex;
public: public:
PersistentIndexIterator(LogicalCollection* collection, transaction::Methods* trx, MMFilesPersistentIndexIterator(LogicalCollection* collection, transaction::Methods* trx,
ManagedDocumentResult* mmdr, ManagedDocumentResult* mmdr,
arangodb::PersistentIndex const* index, arangodb::MMFilesPersistentIndex const* index,
arangodb::MMFilesPrimaryIndex* primaryIndex, arangodb::MMFilesPrimaryIndex* primaryIndex,
rocksdb::OptimisticTransactionDB* db, rocksdb::OptimisticTransactionDB* db,
bool reverse, bool reverse,
arangodb::velocypack::Slice const& left, arangodb::velocypack::Slice const& left,
arangodb::velocypack::Slice const& right); arangodb::velocypack::Slice const& right);
~PersistentIndexIterator() = default; ~MMFilesPersistentIndexIterator() = default;
public: public:
@ -93,16 +92,16 @@ class PersistentIndexIterator final : public IndexIterator {
bool _probe; bool _probe;
}; };
class PersistentIndex final : public MMFilesPathBasedIndex { class MMFilesPersistentIndex final : public MMFilesPathBasedIndex {
friend class PersistentIndexIterator; friend class MMFilesPersistentIndexIterator;
public: public:
PersistentIndex() = delete; MMFilesPersistentIndex() = delete;
PersistentIndex(TRI_idx_iid_t, LogicalCollection*, MMFilesPersistentIndex(TRI_idx_iid_t, LogicalCollection*,
arangodb::velocypack::Slice const&); arangodb::velocypack::Slice const&);
~PersistentIndex(); ~MMFilesPersistentIndex();
public: public:
IndexType type() const override { IndexType type() const override {
@ -164,8 +163,8 @@ class PersistentIndex final : public MMFilesPathBasedIndex {
/// @brief attempts to locate an entry in the index /// @brief attempts to locate an entry in the index
/// ///
/// Warning: who ever calls this function is responsible for destroying /// Warning: who ever calls this function is responsible for destroying
/// the velocypack::Slice and the PersistentIndexIterator* results /// the velocypack::Slice and the MMFilesPersistentIndexIterator* results
PersistentIndexIterator* lookup(transaction::Methods*, MMFilesPersistentIndexIterator* lookup(transaction::Methods*,
ManagedDocumentResult* mmdr, ManagedDocumentResult* mmdr,
arangodb::velocypack::Slice const, arangodb::velocypack::Slice const,
bool reverse) const; bool reverse) const;

View File

@ -50,11 +50,11 @@ using namespace arangodb;
using namespace arangodb::application_features; using namespace arangodb::application_features;
using namespace arangodb::options; using namespace arangodb::options;
static PersistentIndexFeature* Instance = nullptr; static MMFilesPersistentIndexFeature* Instance = nullptr;
PersistentIndexFeature::PersistentIndexFeature( MMFilesPersistentIndexFeature::MMFilesPersistentIndexFeature(
application_features::ApplicationServer* server) application_features::ApplicationServer* server)
: application_features::ApplicationFeature(server, "PersistentIndex"), : application_features::ApplicationFeature(server, "MMFilesPersistentIndex"),
_db(nullptr), _comparator(nullptr), _path(), _active(true), _db(nullptr), _comparator(nullptr), _path(), _active(true),
_writeBufferSize(0), _maxWriteBufferNumber(2), _writeBufferSize(0), _maxWriteBufferNumber(2),
_delayedWriteRate(2 * 1024 * 1024), _minWriteBufferNumberToMerge(1), _delayedWriteRate(2 * 1024 * 1024), _minWriteBufferNumberToMerge(1),
@ -69,7 +69,7 @@ PersistentIndexFeature::PersistentIndexFeature(
startsAfter("DatabasePath"); startsAfter("DatabasePath");
} }
PersistentIndexFeature::~PersistentIndexFeature() { MMFilesPersistentIndexFeature::~MMFilesPersistentIndexFeature() {
try { try {
delete _db; delete _db;
} catch (...) { } catch (...) {
@ -80,7 +80,7 @@ PersistentIndexFeature::~PersistentIndexFeature() {
} }
} }
void PersistentIndexFeature::collectOptions(std::shared_ptr<ProgramOptions> options) { void MMFilesPersistentIndexFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
options->addSection("rocksdb", "Configure the RocksDB engine"); options->addSection("rocksdb", "Configure the RocksDB engine");
options->addOption( options->addOption(
@ -175,7 +175,7 @@ void PersistentIndexFeature::collectOptions(std::shared_ptr<ProgramOptions> opti
new UInt64Parameter(&_compactionReadaheadSize)); new UInt64Parameter(&_compactionReadaheadSize));
} }
void PersistentIndexFeature::validateOptions(std::shared_ptr<ProgramOptions> options) { void MMFilesPersistentIndexFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
if (!_active) { if (!_active) {
forceDisable(); forceDisable();
} else { } else {
@ -201,7 +201,7 @@ void PersistentIndexFeature::validateOptions(std::shared_ptr<ProgramOptions> opt
} }
} }
void PersistentIndexFeature::start() { void MMFilesPersistentIndexFeature::start() {
Instance = this; Instance = this;
if (!isEnabled()) { if (!isEnabled()) {
@ -214,7 +214,7 @@ void PersistentIndexFeature::start() {
LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "initializing rocksdb, path: " << _path; LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "initializing rocksdb, path: " << _path;
_comparator = new RocksDBKeyComparator(); _comparator = new MMFilesPersistentIndexKeyComparator();
rocksdb::BlockBasedTableOptions tableOptions; rocksdb::BlockBasedTableOptions tableOptions;
tableOptions.cache_index_and_filter_blocks = true; tableOptions.cache_index_and_filter_blocks = true;
@ -222,7 +222,7 @@ void PersistentIndexFeature::start() {
// TODO: using the prefix extractor will lead to the comparator being // TODO: using the prefix extractor will lead to the comparator being
// called with just the key prefix (which the comparator currently cannot handle) // called with just the key prefix (which the comparator currently cannot handle)
// _options.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform(PersistentIndex::minimalPrefixSize())); // _options.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform(MMFilesPersistentIndex::minimalPrefixSize()));
// _options.table_factory.reset(rocksdb::NewBlockBasedTableFactory(tableOptions)); // _options.table_factory.reset(rocksdb::NewBlockBasedTableFactory(tableOptions));
_options.create_if_missing = true; _options.create_if_missing = true;
@ -264,7 +264,7 @@ void PersistentIndexFeature::start() {
} }
} }
void PersistentIndexFeature::unprepare() { void MMFilesPersistentIndexFeature::unprepare() {
if (!isEnabled()) { if (!isEnabled()) {
return; return;
} }
@ -283,11 +283,11 @@ void PersistentIndexFeature::unprepare() {
syncWal(); syncWal();
} }
PersistentIndexFeature* PersistentIndexFeature::instance() { MMFilesPersistentIndexFeature* MMFilesPersistentIndexFeature::instance() {
return Instance; return Instance;
} }
int PersistentIndexFeature::syncWal() { int MMFilesPersistentIndexFeature::syncWal() {
#ifndef _WIN32 #ifndef _WIN32
// SyncWAL() always reports a "not implemented" error on Windows // SyncWAL() always reports a "not implemented" error on Windows
if (Instance == nullptr || !Instance->isEnabled()) { if (Instance == nullptr || !Instance->isEnabled()) {
@ -306,31 +306,31 @@ int PersistentIndexFeature::syncWal() {
return TRI_ERROR_NO_ERROR; return TRI_ERROR_NO_ERROR;
} }
int PersistentIndexFeature::dropDatabase(TRI_voc_tick_t databaseId) { int MMFilesPersistentIndexFeature::dropDatabase(TRI_voc_tick_t databaseId) {
if (Instance == nullptr) { if (Instance == nullptr) {
return TRI_ERROR_INTERNAL; return TRI_ERROR_INTERNAL;
} }
// LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "dropping RocksDB database: " << databaseId; // LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "dropping RocksDB database: " << databaseId;
return Instance->dropPrefix(PersistentIndex::buildPrefix(databaseId)); return Instance->dropPrefix(MMFilesPersistentIndex::buildPrefix(databaseId));
} }
int PersistentIndexFeature::dropCollection(TRI_voc_tick_t databaseId, TRI_voc_cid_t collectionId) { int MMFilesPersistentIndexFeature::dropCollection(TRI_voc_tick_t databaseId, TRI_voc_cid_t collectionId) {
if (Instance == nullptr) { if (Instance == nullptr) {
return TRI_ERROR_INTERNAL; return TRI_ERROR_INTERNAL;
} }
// LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "dropping RocksDB database: " << databaseId << ", collection: " << collectionId; // LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "dropping RocksDB database: " << databaseId << ", collection: " << collectionId;
return Instance->dropPrefix(PersistentIndex::buildPrefix(databaseId, collectionId)); return Instance->dropPrefix(MMFilesPersistentIndex::buildPrefix(databaseId, collectionId));
} }
int PersistentIndexFeature::dropIndex(TRI_voc_tick_t databaseId, TRI_voc_cid_t collectionId, TRI_idx_iid_t indexId) { int MMFilesPersistentIndexFeature::dropIndex(TRI_voc_tick_t databaseId, TRI_voc_cid_t collectionId, TRI_idx_iid_t indexId) {
if (Instance == nullptr) { if (Instance == nullptr) {
return TRI_ERROR_INTERNAL; return TRI_ERROR_INTERNAL;
} }
// LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "dropping RocksDB database: " << databaseId << ", collection: " << collectionId << ", index: " << indexId; // LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "dropping RocksDB database: " << databaseId << ", collection: " << collectionId << ", index: " << indexId;
return Instance->dropPrefix(PersistentIndex::buildPrefix(databaseId, collectionId, indexId)); return Instance->dropPrefix(MMFilesPersistentIndex::buildPrefix(databaseId, collectionId, indexId));
} }
int PersistentIndexFeature::dropPrefix(std::string const& prefix) { int MMFilesPersistentIndexFeature::dropPrefix(std::string const& prefix) {
if (!isEnabled()) { if (!isEnabled()) {
return TRI_ERROR_NO_ERROR; return TRI_ERROR_NO_ERROR;
} }
@ -349,7 +349,7 @@ int PersistentIndexFeature::dropPrefix(std::string const& prefix) {
l.reserve(prefix.size() + builder.slice().byteSize()); l.reserve(prefix.size() + builder.slice().byteSize());
l.append(prefix); l.append(prefix);
// extend the prefix to at least 24 bytes // extend the prefix to at least 24 bytes
while (l.size() < PersistentIndex::keyPrefixSize()) { while (l.size() < MMFilesPersistentIndex::keyPrefixSize()) {
uint64_t value = 0; uint64_t value = 0;
l.append(reinterpret_cast<char const*>(&value), sizeof(uint64_t)); l.append(reinterpret_cast<char const*>(&value), sizeof(uint64_t));
} }
@ -364,7 +364,7 @@ int PersistentIndexFeature::dropPrefix(std::string const& prefix) {
u.reserve(prefix.size() + builder.slice().byteSize()); u.reserve(prefix.size() + builder.slice().byteSize());
u.append(prefix); u.append(prefix);
// extend the prefix to at least 24 bytes // extend the prefix to at least 24 bytes
while (u.size() < PersistentIndex::keyPrefixSize()) { while (u.size() < MMFilesPersistentIndex::keyPrefixSize()) {
uint64_t value = UINT64_MAX; uint64_t value = UINT64_MAX;
u.append(reinterpret_cast<char const*>(&value), sizeof(uint64_t)); u.append(reinterpret_cast<char const*>(&value), sizeof(uint64_t));
} }
@ -381,7 +381,7 @@ int PersistentIndexFeature::dropPrefix(std::string const& prefix) {
} }
} }
LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "dropping RocksDB range: " << VPackSlice(l.c_str() + PersistentIndex::keyPrefixSize()).toJson() << " - " << VPackSlice(u.c_str() + PersistentIndex::keyPrefixSize()).toJson(); LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "dropping RocksDB range: " << VPackSlice(l.c_str() + MMFilesPersistentIndex::keyPrefixSize()).toJson() << " - " << VPackSlice(u.c_str() + MMFilesPersistentIndex::keyPrefixSize()).toJson();
#endif #endif
// delete files in range lower..upper // delete files in range lower..upper
@ -401,7 +401,7 @@ int PersistentIndexFeature::dropPrefix(std::string const& prefix) {
// go on and delete the remaining keys (delete files in range does not necessarily // go on and delete the remaining keys (delete files in range does not necessarily
// find them all, just complete files) // find them all, just complete files)
auto comparator = PersistentIndexFeature::instance()->comparator(); auto comparator = MMFilesPersistentIndexFeature::instance()->comparator();
rocksdb::DB* db = _db->GetBaseDB(); rocksdb::DB* db = _db->GetBaseDB();
rocksdb::WriteBatch batch; rocksdb::WriteBatch batch;

View File

@ -21,8 +21,8 @@
/// @author Jan Steemann /// @author Jan Steemann
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef ARANGOD_INDEXES_ROCKS_DB_FEATURE_H #ifndef ARANGOD_MMFILES_MMFILES_PERSISTENT_INDEX_FEATURE_H
#define ARANGOD_INDEXES_ROCKS_DB_FEATURE_H 1 #define ARANGOD_MMFILES_MMFILES_PERSISTENT_INDEX_FEATURE_H 1
#include "ApplicationFeatures/ApplicationFeature.h" #include "ApplicationFeatures/ApplicationFeature.h"
#include "Basics/Common.h" #include "Basics/Common.h"
@ -35,12 +35,12 @@ class OptimisticTransactionDB;
} }
namespace arangodb { namespace arangodb {
class RocksDBKeyComparator; class MMFilesPersistentIndexKeyComparator;
class PersistentIndexFeature final : public application_features::ApplicationFeature { class MMFilesPersistentIndexFeature final : public application_features::ApplicationFeature {
public: public:
explicit PersistentIndexFeature(application_features::ApplicationServer* server); explicit MMFilesPersistentIndexFeature(application_features::ApplicationServer* server);
~PersistentIndexFeature(); ~MMFilesPersistentIndexFeature();
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final; void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;
void validateOptions(std::shared_ptr<options::ProgramOptions>) override final; void validateOptions(std::shared_ptr<options::ProgramOptions>) override final;
@ -48,14 +48,14 @@ class PersistentIndexFeature final : public application_features::ApplicationFea
void unprepare() override final; void unprepare() override final;
inline rocksdb::OptimisticTransactionDB* db() const { return _db; } inline rocksdb::OptimisticTransactionDB* db() const { return _db; }
inline RocksDBKeyComparator* comparator() const { return _comparator; } inline MMFilesPersistentIndexKeyComparator* comparator() const { return _comparator; }
static int syncWal(); static int syncWal();
static int dropDatabase(TRI_voc_tick_t); static int dropDatabase(TRI_voc_tick_t);
static int dropCollection(TRI_voc_tick_t, TRI_voc_cid_t); static int dropCollection(TRI_voc_tick_t, TRI_voc_cid_t);
static int dropIndex(TRI_voc_tick_t, TRI_voc_cid_t, TRI_idx_iid_t); static int dropIndex(TRI_voc_tick_t, TRI_voc_cid_t, TRI_idx_iid_t);
static PersistentIndexFeature* instance(); static MMFilesPersistentIndexFeature* instance();
private: private:
@ -65,7 +65,7 @@ class PersistentIndexFeature final : public application_features::ApplicationFea
rocksdb::OptimisticTransactionDB* _db; rocksdb::OptimisticTransactionDB* _db;
rocksdb::Options _options; rocksdb::Options _options;
RocksDBKeyComparator* _comparator; MMFilesPersistentIndexKeyComparator* _comparator;
std::string _path; std::string _path;
bool _active; bool _active;
uint64_t _writeBufferSize; uint64_t _writeBufferSize;

View File

@ -32,12 +32,12 @@
using namespace arangodb; using namespace arangodb;
int RocksDBKeyComparator::Compare(rocksdb::Slice const& lhs, rocksdb::Slice const& rhs) const { int MMFilesPersistentIndexKeyComparator::Compare(rocksdb::Slice const& lhs, rocksdb::Slice const& rhs) const {
TRI_ASSERT(lhs.size() > 8); TRI_ASSERT(lhs.size() > 8);
TRI_ASSERT(rhs.size() > 8); TRI_ASSERT(rhs.size() > 8);
// compare by index id first // compare by index id first
int res = memcmp(lhs.data(), rhs.data(), PersistentIndex::keyPrefixSize()); int res = memcmp(lhs.data(), rhs.data(), MMFilesPersistentIndex::keyPrefixSize());
if (res != 0) { if (res != 0) {
return res; return res;

View File

@ -21,8 +21,8 @@
/// @author Jan Steemann /// @author Jan Steemann
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef ARANGOD_INDEXES_ROCKS_DB_KEY_COMPARATOR_H #ifndef ARANGOD_MMFILES_MMFILES_PERSISTENT_INDEX_KEY_COMPARATOR_H
#define ARANGOD_INDEXES_ROCKS_DB_KEY_COMPARATOR_H 1 #define ARANGOD_MMFILES_MMFILES_PERSISTENT_INDEX_KEY_COMPARATOR_H 1
#include "Basics/Common.h" #include "Basics/Common.h"
#include "MMFiles/MMFilesPersistentIndex.h" #include "MMFiles/MMFilesPersistentIndex.h"
@ -34,13 +34,13 @@
namespace arangodb { namespace arangodb {
class RocksDBKeyComparator : public rocksdb::Comparator { class MMFilesPersistentIndexKeyComparator final : public rocksdb::Comparator {
public: public:
RocksDBKeyComparator() = default; MMFilesPersistentIndexKeyComparator() = default;
~RocksDBKeyComparator() = default; ~MMFilesPersistentIndexKeyComparator() = default;
static inline arangodb::velocypack::Slice extractKeySlice(rocksdb::Slice const& slice) { static inline arangodb::velocypack::Slice extractKeySlice(rocksdb::Slice const& slice) {
return arangodb::velocypack::Slice(slice.data() + PersistentIndex::keyPrefixSize()); return arangodb::velocypack::Slice(slice.data() + MMFilesPersistentIndex::keyPrefixSize());
} }
int Compare(rocksdb::Slice const& lhs, rocksdb::Slice const& rhs) const; int Compare(rocksdb::Slice const& lhs, rocksdb::Slice const& rhs) const;

View File

@ -128,7 +128,7 @@ bool MMFilesPrimaryIndexIterator::next(TokenCallback const& cb, size_t limit) {
void MMFilesPrimaryIndexIterator::reset() { _iterator.reset(); } void MMFilesPrimaryIndexIterator::reset() { _iterator.reset(); }
AllIndexIterator::AllIndexIterator(LogicalCollection* collection, MMFilesAllIndexIterator::MMFilesAllIndexIterator(LogicalCollection* collection,
transaction::Methods* trx, transaction::Methods* trx,
ManagedDocumentResult* mmdr, ManagedDocumentResult* mmdr,
MMFilesPrimaryIndex const* index, MMFilesPrimaryIndex const* index,
@ -136,7 +136,7 @@ AllIndexIterator::AllIndexIterator(LogicalCollection* collection,
bool reverse) bool reverse)
: IndexIterator(collection, trx, mmdr, index), _index(indexImpl), _reverse(reverse), _total(0) {} : IndexIterator(collection, trx, mmdr, index), _index(indexImpl), _reverse(reverse), _total(0) {}
bool AllIndexIterator::next(TokenCallback const& cb, size_t limit) { bool MMFilesAllIndexIterator::next(TokenCallback const& cb, size_t limit) {
while (limit > 0) { while (limit > 0) {
MMFilesSimpleIndexElement element; MMFilesSimpleIndexElement element;
if (_reverse) { if (_reverse) {
@ -154,15 +154,15 @@ bool AllIndexIterator::next(TokenCallback const& cb, size_t limit) {
return true; return true;
} }
void AllIndexIterator::reset() { _position.reset(); } void MMFilesAllIndexIterator::reset() { _position.reset(); }
AnyIndexIterator::AnyIndexIterator(LogicalCollection* collection, transaction::Methods* trx, MMFilesAnyIndexIterator::MMFilesAnyIndexIterator(LogicalCollection* collection, transaction::Methods* trx,
ManagedDocumentResult* mmdr, ManagedDocumentResult* mmdr,
MMFilesPrimaryIndex const* index, MMFilesPrimaryIndex const* index,
MMFilesPrimaryIndexImpl const* indexImpl) MMFilesPrimaryIndexImpl const* indexImpl)
: IndexIterator(collection, trx, mmdr, index), _index(indexImpl), _step(0), _total(0) {} : IndexIterator(collection, trx, mmdr, index), _index(indexImpl), _step(0), _total(0) {}
bool AnyIndexIterator::next(TokenCallback const& cb, size_t limit) { bool MMFilesAnyIndexIterator::next(TokenCallback const& cb, size_t limit) {
while (limit > 0) { while (limit > 0) {
MMFilesSimpleIndexElement element = MMFilesSimpleIndexElement element =
_index->findRandom(&_context, _initial, _position, _step, _total); _index->findRandom(&_context, _initial, _position, _step, _total);
@ -176,7 +176,7 @@ bool AnyIndexIterator::next(TokenCallback const& cb, size_t limit) {
return true; return true;
} }
void AnyIndexIterator::reset() { void MMFilesAnyIndexIterator::reset() {
_step = 0; _step = 0;
_total = 0; _total = 0;
_position = _initial; _position = _initial;
@ -313,7 +313,7 @@ MMFilesSimpleIndexElement MMFilesPrimaryIndex::lookupSequential(
IndexIterator* MMFilesPrimaryIndex::allIterator(transaction::Methods* trx, IndexIterator* MMFilesPrimaryIndex::allIterator(transaction::Methods* trx,
ManagedDocumentResult* mmdr, ManagedDocumentResult* mmdr,
bool reverse) const { bool reverse) const {
return new AllIndexIterator(_collection, trx, mmdr, this, _primaryIndex, reverse); return new MMFilesAllIndexIterator(_collection, trx, mmdr, this, _primaryIndex, reverse);
} }
/// @brief request an iterator over all elements in the index in /// @brief request an iterator over all elements in the index in
@ -321,7 +321,7 @@ IndexIterator* MMFilesPrimaryIndex::allIterator(transaction::Methods* trx,
/// exactly once unless the collection is modified. /// exactly once unless the collection is modified.
IndexIterator* MMFilesPrimaryIndex::anyIterator(transaction::Methods* trx, IndexIterator* MMFilesPrimaryIndex::anyIterator(transaction::Methods* trx,
ManagedDocumentResult* mmdr) const { ManagedDocumentResult* mmdr) const {
return new AnyIndexIterator(_collection, trx, mmdr, this, _primaryIndex); return new MMFilesAnyIndexIterator(_collection, trx, mmdr, this, _primaryIndex);
} }
/// @brief a method to iterate over all elements in the index in /// @brief a method to iterate over all elements in the index in

View File

@ -68,16 +68,16 @@ class MMFilesPrimaryIndexIterator final : public IndexIterator {
arangodb::velocypack::ArrayIterator _iterator; arangodb::velocypack::ArrayIterator _iterator;
}; };
class AllIndexIterator final : public IndexIterator { class MMFilesAllIndexIterator final : public IndexIterator {
public: public:
AllIndexIterator(LogicalCollection* collection, MMFilesAllIndexIterator(LogicalCollection* collection,
transaction::Methods* trx, transaction::Methods* trx,
ManagedDocumentResult* mmdr, ManagedDocumentResult* mmdr,
MMFilesPrimaryIndex const* index, MMFilesPrimaryIndex const* index,
MMFilesPrimaryIndexImpl const* indexImpl, MMFilesPrimaryIndexImpl const* indexImpl,
bool reverse); bool reverse);
~AllIndexIterator() {} ~MMFilesAllIndexIterator() {}
char const* typeName() const override { return "all-index-iterator"; } char const* typeName() const override { return "all-index-iterator"; }
@ -92,14 +92,14 @@ class AllIndexIterator final : public IndexIterator {
uint64_t _total; uint64_t _total;
}; };
class AnyIndexIterator final : public IndexIterator { class MMFilesAnyIndexIterator final : public IndexIterator {
public: public:
AnyIndexIterator(LogicalCollection* collection, transaction::Methods* trx, MMFilesAnyIndexIterator(LogicalCollection* collection, transaction::Methods* trx,
ManagedDocumentResult* mmdr, ManagedDocumentResult* mmdr,
MMFilesPrimaryIndex const* index, MMFilesPrimaryIndex const* index,
MMFilesPrimaryIndexImpl const* indexImpl); MMFilesPrimaryIndexImpl const* indexImpl);
~AnyIndexIterator() {} ~MMFilesAnyIndexIterator() {}
char const* typeName() const override { return "any-index-iterator"; } char const* typeName() const override { return "any-index-iterator"; }

View File

@ -104,25 +104,25 @@ static int CompareElementElement(void* userData,
return arangodb::basics::VelocyPackHelper::compare(l, r, true); return arangodb::basics::VelocyPackHelper::compare(l, r, true);
} }
bool BaseSkiplistLookupBuilder::isEquality() const { return _isEquality; } bool MMFilesBaseSkiplistLookupBuilder::isEquality() const { return _isEquality; }
VPackSlice const* BaseSkiplistLookupBuilder::getLowerLookup() const { VPackSlice const* MMFilesBaseSkiplistLookupBuilder::getLowerLookup() const {
return &_lowerSlice; return &_lowerSlice;
} }
bool BaseSkiplistLookupBuilder::includeLower() const { return _includeLower; } bool MMFilesBaseSkiplistLookupBuilder::includeLower() const { return _includeLower; }
VPackSlice const* BaseSkiplistLookupBuilder::getUpperLookup() const { VPackSlice const* MMFilesBaseSkiplistLookupBuilder::getUpperLookup() const {
return &_upperSlice; return &_upperSlice;
} }
bool BaseSkiplistLookupBuilder::includeUpper() const { return _includeUpper; } bool MMFilesBaseSkiplistLookupBuilder::includeUpper() const { return _includeUpper; }
SkiplistLookupBuilder::SkiplistLookupBuilder( MMFilesSkiplistLookupBuilder::MMFilesSkiplistLookupBuilder(
transaction::Methods* trx, transaction::Methods* trx,
std::vector<std::vector<arangodb::aql::AstNode const*>>& ops, std::vector<std::vector<arangodb::aql::AstNode const*>>& ops,
arangodb::aql::Variable const* var, bool reverse) arangodb::aql::Variable const* var, bool reverse)
: BaseSkiplistLookupBuilder(trx) { : MMFilesBaseSkiplistLookupBuilder(trx) {
_lowerBuilder->openArray(); _lowerBuilder->openArray();
if (ops.empty()) { if (ops.empty()) {
// We only use this skiplist to sort. use empty array for lookup // We only use this skiplist to sort. use empty array for lookup
@ -249,17 +249,17 @@ SkiplistLookupBuilder::SkiplistLookupBuilder(
} }
} }
bool SkiplistLookupBuilder::next() { bool MMFilesSkiplistLookupBuilder::next() {
// The first search value is created during creation. // The first search value is created during creation.
// So next is always false. // So next is always false.
return false; return false;
} }
SkiplistInLookupBuilder::SkiplistInLookupBuilder( MMFilesSkiplistInLookupBuilder::MMFilesSkiplistInLookupBuilder(
transaction::Methods* trx, transaction::Methods* trx,
std::vector<std::vector<arangodb::aql::AstNode const*>>& ops, std::vector<std::vector<arangodb::aql::AstNode const*>>& ops,
arangodb::aql::Variable const* var, bool reverse) arangodb::aql::Variable const* var, bool reverse)
: BaseSkiplistLookupBuilder(trx), _dataBuilder(trx), _done(false) { : MMFilesBaseSkiplistLookupBuilder(trx), _dataBuilder(trx), _done(false) {
TRI_ASSERT(!ops.empty()); // We certainly do not need IN here TRI_ASSERT(!ops.empty()); // We certainly do not need IN here
transaction::BuilderLeaser tmp(trx); transaction::BuilderLeaser tmp(trx);
std::set<VPackSlice, arangodb::basics::VelocyPackHelper::VPackSorted<true>> std::set<VPackSlice, arangodb::basics::VelocyPackHelper::VPackSorted<true>>
@ -422,7 +422,7 @@ SkiplistInLookupBuilder::SkiplistInLookupBuilder(
buildSearchValues(); buildSearchValues();
} }
bool SkiplistInLookupBuilder::next() { bool MMFilesSkiplistInLookupBuilder::next() {
if (_done || !forwardInPosition()) { if (_done || !forwardInPosition()) {
return false; return false;
} }
@ -430,7 +430,7 @@ bool SkiplistInLookupBuilder::next() {
return true; return true;
} }
bool SkiplistInLookupBuilder::forwardInPosition() { bool MMFilesSkiplistInLookupBuilder::forwardInPosition() {
std::list<PosStruct>::reverse_iterator it = _inPositions.rbegin(); std::list<PosStruct>::reverse_iterator it = _inPositions.rbegin();
while (it != _inPositions.rend()) { while (it != _inPositions.rend()) {
it->current++; it->current++;
@ -448,7 +448,7 @@ bool SkiplistInLookupBuilder::forwardInPosition() {
return false; return false;
} }
void SkiplistInLookupBuilder::buildSearchValues() { void MMFilesSkiplistInLookupBuilder::buildSearchValues() {
auto inPos = _inPositions.begin(); auto inPos = _inPositions.begin();
_lowerBuilder->clear(); _lowerBuilder->clear();
_lowerBuilder->openArray(); _lowerBuilder->openArray();
@ -507,7 +507,7 @@ MMFilesSkiplistIterator::MMFilesSkiplistIterator(LogicalCollection* collection,
TRI_Skiplist const* skiplist, size_t numPaths, TRI_Skiplist const* skiplist, size_t numPaths,
std::function<int(void*, MMFilesSkiplistIndexElement const*, MMFilesSkiplistIndexElement const*, std::function<int(void*, MMFilesSkiplistIndexElement const*, MMFilesSkiplistIndexElement const*,
MMFilesSkiplistCmpType)> const& CmpElmElm, MMFilesSkiplistCmpType)> const& CmpElmElm,
bool reverse, BaseSkiplistLookupBuilder* builder) bool reverse, MMFilesBaseSkiplistLookupBuilder* builder)
: IndexIterator(collection, trx, mmdr, index), : IndexIterator(collection, trx, mmdr, index),
_skiplistIndex(skiplist), _skiplistIndex(skiplist),
_numPaths(numPaths), _numPaths(numPaths),
@ -1235,14 +1235,14 @@ IndexIterator* MMFilesSkiplistIndex::iteratorForCondition(
} }
if (usesIn) { if (usesIn) {
auto builder = std::make_unique<SkiplistInLookupBuilder>( auto builder = std::make_unique<MMFilesSkiplistInLookupBuilder>(
trx, mapping, reference, reverse); trx, mapping, reference, reverse);
return new MMFilesSkiplistIterator(_collection, trx, mmdr, this, return new MMFilesSkiplistIterator(_collection, trx, mmdr, this,
_skiplistIndex, numPaths(), CmpElmElm, _skiplistIndex, numPaths(), CmpElmElm,
reverse, builder.release()); reverse, builder.release());
} }
auto builder = auto builder =
std::make_unique<SkiplistLookupBuilder>(trx, mapping, reference, reverse); std::make_unique<MMFilesSkiplistLookupBuilder>(trx, mapping, reference, reverse);
return new MMFilesSkiplistIterator(_collection, trx, mmdr, this, return new MMFilesSkiplistIterator(_collection, trx, mmdr, this,
_skiplistIndex, numPaths(), CmpElmElm, _skiplistIndex, numPaths(), CmpElmElm,
reverse, builder.release()); reverse, builder.release());

View File

@ -47,12 +47,9 @@ class MMFilesSkiplistIndex;
namespace transaction { namespace transaction {
class Methods; class Methods;
} }
;
/// @brief Abstract Builder for lookup values in skiplist index /// @brief Abstract Builder for lookup values in skiplist index
class MMFilesBaseSkiplistLookupBuilder {
class BaseSkiplistLookupBuilder {
protected: protected:
bool _isEquality; bool _isEquality;
bool _includeLower; bool _includeLower;
@ -65,9 +62,8 @@ class BaseSkiplistLookupBuilder {
arangodb::velocypack::Slice _upperSlice; arangodb::velocypack::Slice _upperSlice;
public: public:
explicit BaseSkiplistLookupBuilder(transaction::Methods* trx) : explicit MMFilesBaseSkiplistLookupBuilder(transaction::Methods* trx) :
_lowerBuilder(trx), _upperBuilder(trx) _lowerBuilder(trx), _upperBuilder(trx) {
{
_isEquality = true; _isEquality = true;
_includeUpper = true; _includeUpper = true;
_includeLower = true; _includeLower = true;
@ -76,7 +72,7 @@ class BaseSkiplistLookupBuilder {
_upperBuilder->clear(); _upperBuilder->clear();
} }
virtual ~BaseSkiplistLookupBuilder() {}; virtual ~MMFilesBaseSkiplistLookupBuilder() {}
/// @brief Compute the next lookup values /// @brief Compute the next lookup values
/// If returns false there is no further lookup /// If returns false there is no further lookup
@ -109,15 +105,15 @@ class BaseSkiplistLookupBuilder {
/// returned in the correct ordering. And no /// returned in the correct ordering. And no
/// lookup is returned twice. /// lookup is returned twice.
class SkiplistLookupBuilder : public BaseSkiplistLookupBuilder { class MMFilesSkiplistLookupBuilder final : public MMFilesBaseSkiplistLookupBuilder {
public: public:
SkiplistLookupBuilder( MMFilesSkiplistLookupBuilder(
transaction::Methods* trx, transaction::Methods* trx,
std::vector<std::vector<arangodb::aql::AstNode const*>>&, std::vector<std::vector<arangodb::aql::AstNode const*>>&,
arangodb::aql::Variable const*, bool); arangodb::aql::Variable const*, bool);
~SkiplistLookupBuilder() {} ~MMFilesSkiplistLookupBuilder() {}
/// @brief Compute the next lookup values /// @brief Compute the next lookup values
/// If returns false there is no further lookup /// If returns false there is no further lookup
@ -125,7 +121,7 @@ class SkiplistLookupBuilder : public BaseSkiplistLookupBuilder {
}; };
class SkiplistInLookupBuilder : public BaseSkiplistLookupBuilder { class MMFilesSkiplistInLookupBuilder final : public MMFilesBaseSkiplistLookupBuilder {
private: private:
@ -145,12 +141,12 @@ class SkiplistInLookupBuilder : public BaseSkiplistLookupBuilder {
bool _done; bool _done;
public: public:
SkiplistInLookupBuilder( MMFilesSkiplistInLookupBuilder(
transaction::Methods* trx, transaction::Methods* trx,
std::vector<std::vector<arangodb::aql::AstNode const*>>&, std::vector<std::vector<arangodb::aql::AstNode const*>>&,
arangodb::aql::Variable const*, bool); arangodb::aql::Variable const*, bool);
~SkiplistInLookupBuilder() {} ~MMFilesSkiplistInLookupBuilder() {}
/// @brief Compute the next lookup values /// @brief Compute the next lookup values
/// If returns false there is no further lookup /// If returns false there is no further lookup
@ -190,7 +186,7 @@ class MMFilesSkiplistIterator final : public IndexIterator {
std::vector<std::pair<Node*, Node*>> _intervals; std::vector<std::pair<Node*, Node*>> _intervals;
size_t _currentInterval; size_t _currentInterval;
BaseSkiplistLookupBuilder* _builder; MMFilesBaseSkiplistLookupBuilder* _builder;
std::function<int(void*, MMFilesSkiplistIndexElement const*, MMFilesSkiplistIndexElement const*, std::function<int(void*, MMFilesSkiplistIndexElement const*, MMFilesSkiplistIndexElement const*,
MMFilesSkiplistCmpType)> _CmpElmElm; MMFilesSkiplistCmpType)> _CmpElmElm;
@ -202,7 +198,7 @@ class MMFilesSkiplistIterator final : public IndexIterator {
TRI_Skiplist const* skiplist, size_t numPaths, TRI_Skiplist const* skiplist, size_t numPaths,
std::function<int(void*, MMFilesSkiplistIndexElement const*, MMFilesSkiplistIndexElement const*, std::function<int(void*, MMFilesSkiplistIndexElement const*, MMFilesSkiplistIndexElement const*,
MMFilesSkiplistCmpType)> const& CmpElmElm, MMFilesSkiplistCmpType)> const& CmpElmElm,
bool reverse, BaseSkiplistLookupBuilder* builder); bool reverse, MMFilesBaseSkiplistLookupBuilder* builder);
~MMFilesSkiplistIterator() { ~MMFilesSkiplistIterator() {
delete _builder; delete _builder;

View File

@ -64,7 +64,7 @@ MMFilesTransactionState::~MMFilesTransactionState() {
/// @brief get (or create) a rocksdb WriteTransaction /// @brief get (or create) a rocksdb WriteTransaction
rocksdb::Transaction* MMFilesTransactionState::rocksTransaction() { rocksdb::Transaction* MMFilesTransactionState::rocksTransaction() {
if (_rocksTransaction == nullptr) { if (_rocksTransaction == nullptr) {
_rocksTransaction = PersistentIndexFeature::instance()->db()->BeginTransaction( _rocksTransaction = MMFilesPersistentIndexFeature::instance()->db()->BeginTransaction(
rocksdb::WriteOptions(), rocksdb::OptimisticTransactionOptions()); rocksdb::WriteOptions(), rocksdb::OptimisticTransactionOptions());
} }
return _rocksTransaction; return _rocksTransaction;
@ -278,7 +278,7 @@ int MMFilesTransactionState::addOperation(TRI_voc_rid_t revisionId,
} }
if (localWaitForSync) { if (localWaitForSync) {
// also sync RocksDB WAL // also sync RocksDB WAL
PersistentIndexFeature::syncWal(); MMFilesPersistentIndexFeature::syncWal();
} }
operation.setTick(slotInfo.tick); operation.setTick(slotInfo.tick);
fid = slotInfo.logfileId; fid = slotInfo.logfileId;
@ -473,7 +473,7 @@ int MMFilesTransactionState::writeCommitMarker() {
if (_waitForSync) { if (_waitForSync) {
// also sync RocksDB WAL // also sync RocksDB WAL
PersistentIndexFeature::syncWal(); MMFilesPersistentIndexFeature::syncWal();
} }
TRI_IF_FAILURE("TransactionWriteCommitMarkerThrow") { TRI_IF_FAILURE("TransactionWriteCommitMarkerThrow") {

View File

@ -790,7 +790,7 @@ bool MMFilesWalRecoverState::ReplayMarker(TRI_df_marker_t const* marker,
auto physical = static_cast<MMFilesCollection*>(col->getPhysical()); auto physical = static_cast<MMFilesCollection*>(col->getPhysical());
TRI_ASSERT(physical != nullptr); TRI_ASSERT(physical != nullptr);
PersistentIndexFeature::dropIndex(databaseId, collectionId, indexId); MMFilesPersistentIndexFeature::dropIndex(databaseId, collectionId, indexId);
std::string const indexName("index-" + std::to_string(indexId) + std::string const indexName("index-" + std::to_string(indexId) +
".json"); ".json");
@ -868,7 +868,7 @@ bool MMFilesWalRecoverState::ReplayMarker(TRI_df_marker_t const* marker,
vocbase->dropCollection(collection, true, false); vocbase->dropCollection(collection, true, false);
} }
PersistentIndexFeature::dropCollection(databaseId, collectionId); MMFilesPersistentIndexFeature::dropCollection(databaseId, collectionId);
// check if there is another collection with the same name as the one // check if there is another collection with the same name as the one
// that // that
@ -987,7 +987,7 @@ bool MMFilesWalRecoverState::ReplayMarker(TRI_df_marker_t const* marker,
state->databaseFeature->dropDatabase(nameString, true, false); state->databaseFeature->dropDatabase(nameString, true, false);
} }
PersistentIndexFeature::dropDatabase(databaseId); MMFilesPersistentIndexFeature::dropDatabase(databaseId);
vocbase = nullptr; vocbase = nullptr;
/* TODO: check what TRI_ERROR_ARANGO_DATABASE_NOT_FOUND means here /* TODO: check what TRI_ERROR_ARANGO_DATABASE_NOT_FOUND means here
@ -1052,7 +1052,7 @@ bool MMFilesWalRecoverState::ReplayMarker(TRI_df_marker_t const* marker,
TRI_ASSERT(physical != nullptr); TRI_ASSERT(physical != nullptr);
col->dropIndex(indexId); col->dropIndex(indexId);
PersistentIndexFeature::dropIndex(databaseId, collectionId, indexId); MMFilesPersistentIndexFeature::dropIndex(databaseId, collectionId, indexId);
// additionally remove the index file // additionally remove the index file
std::string const indexName("index-" + std::to_string(indexId) + std::string const indexName("index-" + std::to_string(indexId) +
@ -1094,7 +1094,7 @@ bool MMFilesWalRecoverState::ReplayMarker(TRI_df_marker_t const* marker,
if (collection != nullptr) { if (collection != nullptr) {
vocbase->dropCollection(collection, true, false); vocbase->dropCollection(collection, true, false);
} }
PersistentIndexFeature::dropCollection(databaseId, collectionId); MMFilesPersistentIndexFeature::dropCollection(databaseId, collectionId);
break; break;
} }
@ -1114,7 +1114,7 @@ bool MMFilesWalRecoverState::ReplayMarker(TRI_df_marker_t const* marker,
state->databaseFeature->dropDatabase(databaseId, true, false); state->databaseFeature->dropDatabase(databaseId, true, false);
} }
PersistentIndexFeature::dropDatabase(databaseId); MMFilesPersistentIndexFeature::dropDatabase(databaseId);
break; break;
} }

View File

@ -41,7 +41,7 @@ MMFilesWalRecoveryFeature::MMFilesWalRecoveryFeature(ApplicationServer* server)
requiresElevatedPrivileges(false); requiresElevatedPrivileges(false);
startsAfter("Database"); startsAfter("Database");
startsAfter("MMFilesLogfileManager"); startsAfter("MMFilesLogfileManager");
startsAfter("PersistentIndex"); startsAfter("MMFilesPersistentIndex");
} }
/// @brief run the recovery procedure /// @brief run the recovery procedure

View File

@ -152,16 +152,15 @@ static int runServer(int argc, char** argv) {
server.addFeature(new InitDatabaseFeature(&server, nonServerFeatures)); server.addFeature(new InitDatabaseFeature(&server, nonServerFeatures));
server.addFeature(new LanguageFeature(&server)); server.addFeature(new LanguageFeature(&server));
server.addFeature(new LockfileFeature(&server)); server.addFeature(new LockfileFeature(&server));
server.addFeature(new MMFilesLogfileManager(&server));
server.addFeature(new LoggerBufferFeature(&server)); server.addFeature(new LoggerBufferFeature(&server));
server.addFeature(new LoggerFeature(&server, true)); server.addFeature(new LoggerFeature(&server, true));
server.addFeature(new MMFilesLogfileManager(&server));
server.addFeature(new MMFilesPersistentIndexFeature(&server));
server.addFeature(new NonceFeature(&server)); server.addFeature(new NonceFeature(&server));
server.addFeature(new PageSizeFeature(&server)); server.addFeature(new PageSizeFeature(&server));
server.addFeature(new PrivilegeFeature(&server)); server.addFeature(new PrivilegeFeature(&server));
server.addFeature(new QueryRegistryFeature(&server));
server.addFeature(new TraverserEngineRegistryFeature(&server));
server.addFeature(new RandomFeature(&server)); server.addFeature(new RandomFeature(&server));
server.addFeature(new PersistentIndexFeature(&server)); server.addFeature(new QueryRegistryFeature(&server));
server.addFeature(new SchedulerFeature(&server)); server.addFeature(new SchedulerFeature(&server));
server.addFeature(new ScriptFeature(&server, &ret)); server.addFeature(new ScriptFeature(&server, &ret));
server.addFeature(new ServerFeature(&server, &ret)); server.addFeature(new ServerFeature(&server, &ret));
@ -171,6 +170,7 @@ static int runServer(int argc, char** argv) {
server.addFeature(new StatisticsFeature(&server)); server.addFeature(new StatisticsFeature(&server));
server.addFeature(new TempFeature(&server, name)); server.addFeature(new TempFeature(&server, name));
server.addFeature(new TransactionManagerFeature(&server)); server.addFeature(new TransactionManagerFeature(&server));
server.addFeature(new TraverserEngineRegistryFeature(&server));
server.addFeature(new UnitTestsFeature(&server, &ret)); server.addFeature(new UnitTestsFeature(&server, &ret));
server.addFeature(new UpgradeFeature(&server, &ret, nonServerFeatures)); server.addFeature(new UpgradeFeature(&server, &ret, nonServerFeatures));
server.addFeature(new V8DealerFeature(&server)); server.addFeature(new V8DealerFeature(&server));