mirror of https://gitee.com/bigwinds/arangodb
Refactoring index interface (#7971)
This commit is contained in:
parent
8e7b0067c7
commit
ba102323cc
|
@ -173,6 +173,12 @@ AstNode* createSubqueryWithLimit(ExecutionPlan* plan, ExecutionNode* node,
|
|||
// return reference to outVariable
|
||||
return ast->createNodeReference(subqueryOutVariable);
|
||||
}
|
||||
|
||||
bool isGeoIndex(arangodb::Index::IndexType type) {
|
||||
return type == arangodb::Index::TRI_IDX_TYPE_GEO1_INDEX ||
|
||||
type == arangodb::Index::TRI_IDX_TYPE_GEO2_INDEX ||
|
||||
type == arangodb::Index::TRI_IDX_TYPE_GEO_INDEX;
|
||||
}
|
||||
|
||||
std::pair<AstNode*, AstNode*> getAttributeAccessFromIndex(Ast* ast, AstNode* docRef,
|
||||
NearOrWithinParams& params) {
|
||||
|
@ -186,7 +192,7 @@ std::pair<AstNode*, AstNode*> getAttributeAccessFromIndex(Ast* ast, AstNode* doc
|
|||
std::vector<basics::AttributeName> field;
|
||||
auto indexes = trx->indexesForCollection(params.collection);
|
||||
for (auto& idx : indexes) {
|
||||
if (Index::isGeoIndex(idx->type())) {
|
||||
if (::isGeoIndex(idx->type())) {
|
||||
// we take the first index that is found
|
||||
bool isGeo1 = idx->type() == Index::IndexType::TRI_IDX_TYPE_GEO1_INDEX;
|
||||
bool isGeo2 = idx->type() == Index::IndexType::TRI_IDX_TYPE_GEO2_INDEX;
|
||||
|
@ -392,7 +398,7 @@ AstNode* replaceWithinRectangle(AstNode* funAstNode, ExecutionNode* calcNode,
|
|||
std::shared_ptr<arangodb::Index> index;
|
||||
// we should not access the LogicalCollection directly
|
||||
for (auto& idx : ast->query()->trx()->indexesForCollection(cname)) {
|
||||
if (Index::isGeoIndex(idx->type())) {
|
||||
if (::isGeoIndex(idx->type())) {
|
||||
index = idx;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -74,16 +74,6 @@ class ClusterIndex : public Index {
|
|||
void unload() override {}
|
||||
size_t memory() const override { return 0; }
|
||||
|
||||
Result insert(transaction::Methods& trx, LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override {
|
||||
return Result(TRI_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
Result remove(transaction::Methods& trx, LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc, Index::OperationMode mode) override {
|
||||
return Result(TRI_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
Result drop() override { return Result(TRI_ERROR_NOT_IMPLEMENTED); }
|
||||
|
||||
bool hasCoveringIterator() const override;
|
||||
|
@ -133,4 +123,4 @@ class ClusterIndex : public Index {
|
|||
};
|
||||
} // namespace arangodb
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -70,12 +70,6 @@ class IResearchLinkCoordinator final : public arangodb::ClusterIndex, public IRe
|
|||
return IResearchLink::hasSelectivityEstimate();
|
||||
}
|
||||
|
||||
virtual arangodb::Result insert(transaction::Methods& trx, LocalDocumentId const& documentId,
|
||||
VPackSlice const& doc, OperationMode mode) override {
|
||||
TRI_ASSERT(false); // should not be called
|
||||
return arangodb::Result(TRI_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
bool isHidden() const override {
|
||||
return true; // always hide links
|
||||
}
|
||||
|
@ -99,12 +93,6 @@ class IResearchLinkCoordinator final : public arangodb::ClusterIndex, public IRe
|
|||
|
||||
virtual size_t memory() const override { return IResearchLink::memory(); }
|
||||
|
||||
arangodb::Result remove(transaction::Methods& trx, LocalDocumentId const& documentId,
|
||||
VPackSlice const& doc, OperationMode mode) override {
|
||||
TRI_ASSERT(false); // should not be called
|
||||
return arangodb::Result(TRI_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief fill and return a JSON description of a IResearchLink object
|
||||
/// @param withFigures output 'figures' section with e.g. memory size
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace aql {
|
|||
class Ast;
|
||||
struct AstNode;
|
||||
class CalculationNode;
|
||||
struct Expression;
|
||||
class Expression;
|
||||
struct Variable;
|
||||
|
||||
} // namespace aql
|
||||
|
|
|
@ -42,13 +42,6 @@ class IResearchRocksDBLink final : public arangodb::RocksDBIndex, public IResear
|
|||
IResearchLink::afterTruncate();
|
||||
}
|
||||
|
||||
virtual void batchInsert(
|
||||
transaction::Methods& trx,
|
||||
std::vector<std::pair<arangodb::LocalDocumentId, arangodb::velocypack::Slice>> const& documents,
|
||||
std::shared_ptr<arangodb::basics::LocalTaskQueue> queue) override {
|
||||
IResearchLink::batchInsert(trx, documents, queue);
|
||||
}
|
||||
|
||||
virtual bool canBeDropped() const override {
|
||||
return IResearchLink::canBeDropped();
|
||||
}
|
||||
|
@ -68,11 +61,11 @@ class IResearchRocksDBLink final : public arangodb::RocksDBIndex, public IResear
|
|||
return IResearchLink::hasSelectivityEstimate();
|
||||
}
|
||||
|
||||
virtual arangodb::Result insertInternal(arangodb::transaction::Methods& trx,
|
||||
arangodb::RocksDBMethods* methods,
|
||||
arangodb::LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc,
|
||||
arangodb::Index::OperationMode mode) override {
|
||||
virtual arangodb::Result insert(arangodb::transaction::Methods& trx,
|
||||
arangodb::RocksDBMethods* methods,
|
||||
arangodb::LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc,
|
||||
arangodb::Index::OperationMode mode) override {
|
||||
return IResearchLink::insert(trx, documentId, doc, mode);
|
||||
}
|
||||
|
||||
|
@ -96,11 +89,11 @@ class IResearchRocksDBLink final : public arangodb::RocksDBIndex, public IResear
|
|||
|
||||
virtual size_t memory() const override { return IResearchLink::memory(); }
|
||||
|
||||
virtual arangodb::Result removeInternal(arangodb::transaction::Methods& trx,
|
||||
arangodb::RocksDBMethods*,
|
||||
arangodb::LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc,
|
||||
arangodb::Index::OperationMode mode) override {
|
||||
virtual arangodb::Result remove(arangodb::transaction::Methods& trx,
|
||||
arangodb::RocksDBMethods*,
|
||||
arangodb::LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc,
|
||||
arangodb::Index::OperationMode mode) override {
|
||||
return IResearchLink::remove(trx, documentId, doc, mode);
|
||||
}
|
||||
|
||||
|
@ -135,4 +128,4 @@ class IResearchRocksDBLink final : public arangodb::RocksDBIndex, public IResear
|
|||
} // namespace iresearch
|
||||
} // namespace arangodb
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "IResearchCommon.h"
|
||||
#include "IResearchLink.h"
|
||||
#include "IResearchLinkHelper.h"
|
||||
#include "IResearchRocksDBLink.h"
|
||||
#include "IResearchView.h"
|
||||
#include "Indexes/Index.h"
|
||||
#include "RestServer/DatabaseFeature.h"
|
||||
|
@ -223,7 +224,7 @@ void IResearchRocksDBRecoveryHelper::PutCF(uint32_t column_family_id,
|
|||
|
||||
trx.begin();
|
||||
|
||||
for (auto link : links) {
|
||||
for (std::shared_ptr<arangodb::Index> const& link : links) {
|
||||
IndexId indexId(coll->vocbase().id(), coll->id(), link->id());
|
||||
|
||||
// optimization: avoid insertion of recovered documents twice,
|
||||
|
@ -231,8 +232,9 @@ void IResearchRocksDBRecoveryHelper::PutCF(uint32_t column_family_id,
|
|||
if (!link || _recoveredIndexes.find(indexId) != _recoveredIndexes.end()) {
|
||||
continue; // index was already populated when it was created
|
||||
}
|
||||
|
||||
link->insert(trx, docId, doc, arangodb::Index::OperationMode::internal);
|
||||
|
||||
IResearchLink* l = static_cast<IResearchRocksDBLink*>(link.get());
|
||||
l->insert(trx, docId, doc, arangodb::Index::OperationMode::internal);
|
||||
}
|
||||
|
||||
trx.commit();
|
||||
|
@ -265,9 +267,10 @@ void IResearchRocksDBRecoveryHelper::handleDeleteCF(uint32_t column_family_id,
|
|||
|
||||
trx.begin();
|
||||
|
||||
for (auto link : links) {
|
||||
link->remove(trx, docId, arangodb::velocypack::Slice::emptyObjectSlice(),
|
||||
arangodb::Index::OperationMode::internal);
|
||||
for (std::shared_ptr<arangodb::Index> const& link : links) {
|
||||
IResearchLink* l = static_cast<IResearchRocksDBLink*>(link.get());
|
||||
l->remove(trx, docId, arangodb::velocypack::Slice::emptyObjectSlice(),
|
||||
arangodb::Index::OperationMode::internal);
|
||||
}
|
||||
|
||||
trx.commit();
|
||||
|
@ -320,4 +323,4 @@ void IResearchRocksDBRecoveryHelper::LogData(const rocksdb::Slice& blob) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "Aql/Variable.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/HashSet.h"
|
||||
#include "Basics/LocalTaskQueue.h"
|
||||
#include "Basics/StaticStrings.h"
|
||||
#include "Basics/StringRef.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
|
@ -553,18 +552,6 @@ bool Index::implicitlyUnique() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
void Index::batchInsert(transaction::Methods& trx,
|
||||
std::vector<std::pair<LocalDocumentId, arangodb::velocypack::Slice>> const& documents,
|
||||
std::shared_ptr<arangodb::basics::LocalTaskQueue> queue) {
|
||||
for (auto const& it : documents) {
|
||||
Result status = insert(trx, it.first, it.second, OperationMode::normal);
|
||||
if (status.errorNumber() != TRI_ERROR_NO_ERROR) {
|
||||
queue->setStatus(status.errorNumber());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief default implementation for drop
|
||||
Result Index::drop() {
|
||||
return Result(); // do nothing
|
||||
|
|
|
@ -193,11 +193,6 @@ class Index {
|
|||
|
||||
static IndexType type(std::string const& type);
|
||||
|
||||
static bool isGeoIndex(IndexType type) {
|
||||
return type == TRI_IDX_TYPE_GEO1_INDEX || type == TRI_IDX_TYPE_GEO2_INDEX ||
|
||||
type == TRI_IDX_TYPE_GEO_INDEX;
|
||||
}
|
||||
|
||||
virtual char const* typeName() const = 0;
|
||||
|
||||
static bool allowExpansion(IndexType type) {
|
||||
|
@ -301,16 +296,6 @@ class Index {
|
|||
virtual void toVelocyPackFigures(arangodb::velocypack::Builder&) const;
|
||||
std::shared_ptr<arangodb::velocypack::Builder> toVelocyPackFigures() const;
|
||||
|
||||
virtual void batchInsert(transaction::Methods& trx,
|
||||
std::vector<std::pair<LocalDocumentId, arangodb::velocypack::Slice>> const& docs,
|
||||
std::shared_ptr<arangodb::basics::LocalTaskQueue> queue);
|
||||
|
||||
virtual Result insert(transaction::Methods& trx, LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc, OperationMode mode) = 0;
|
||||
|
||||
virtual Result remove(transaction::Methods& trx, LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc, OperationMode mode) = 0;
|
||||
|
||||
virtual void load() = 0;
|
||||
virtual void unload() = 0;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ set(MMFILES_SOURCES
|
|||
MMFiles/MMFilesEdgeIndex.cpp
|
||||
MMFiles/MMFilesEngine.cpp
|
||||
MMFiles/MMFilesExportCursor.cpp
|
||||
MMFiles/MMFilesIndex.cpp
|
||||
MMFiles/MMFilesIndexElement.cpp
|
||||
MMFiles/MMFilesIndexFactory.cpp
|
||||
MMFiles/MMFilesIndexLookupContext.cpp
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace {
|
|||
class MMFilesIndexFillerTask : public basics::LocalTask {
|
||||
public:
|
||||
MMFilesIndexFillerTask(std::shared_ptr<basics::LocalTaskQueue> const& queue,
|
||||
transaction::Methods& trx, Index* idx,
|
||||
transaction::Methods& trx, MMFilesIndex* idx,
|
||||
std::shared_ptr<std::vector<std::pair<LocalDocumentId, VPackSlice>>> const& documents)
|
||||
: LocalTask(queue), _trx(trx), _idx(idx), _documents(documents) {}
|
||||
|
||||
|
@ -135,7 +135,7 @@ class MMFilesIndexFillerTask : public basics::LocalTask {
|
|||
|
||||
private:
|
||||
transaction::Methods& _trx;
|
||||
Index* _idx;
|
||||
MMFilesIndex* _idx;
|
||||
std::shared_ptr<std::vector<std::pair<LocalDocumentId, VPackSlice>>> _documents;
|
||||
};
|
||||
|
||||
|
@ -1621,7 +1621,7 @@ void MMFilesCollection::fillIndex(
|
|||
try {
|
||||
// move task into thread pool
|
||||
std::shared_ptr<::MMFilesIndexFillerTask> worker;
|
||||
worker.reset(new ::MMFilesIndexFillerTask(queue, trx, idx, documents));
|
||||
worker.reset(new ::MMFilesIndexFillerTask(queue, trx, midx, documents));
|
||||
queue->enqueue(worker);
|
||||
} catch (...) {
|
||||
// set error code
|
||||
|
@ -3185,7 +3185,7 @@ Result MMFilesCollection::insertSecondaryIndexes(arangodb::transaction::Methods&
|
|||
continue;
|
||||
}
|
||||
|
||||
Result res = idx->insert(trx, documentId, doc, mode);
|
||||
Result res = midx->insert(trx, documentId, doc, mode);
|
||||
|
||||
// in case of no-memory, return immediately
|
||||
if (res.errorNumber() == TRI_ERROR_OUT_OF_MEMORY) {
|
||||
|
@ -3233,7 +3233,7 @@ Result MMFilesCollection::deleteSecondaryIndexes(transaction::Methods& trx,
|
|||
continue;
|
||||
}
|
||||
|
||||
Result res = idx->remove(trx, documentId, doc, mode);
|
||||
Result res = midx->remove(trx, documentId, doc, mode);
|
||||
|
||||
if (res.fail()) {
|
||||
// an error occurred
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2019 ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Simon Grätzer
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "MMFilesIndex.h"
|
||||
|
||||
#include "Basics/LocalTaskQueue.h"
|
||||
|
||||
using namespace arangodb;
|
||||
|
||||
void MMFilesIndex::batchInsert(transaction::Methods& trx,
|
||||
std::vector<std::pair<LocalDocumentId, arangodb::velocypack::Slice>> const& documents,
|
||||
std::shared_ptr<arangodb::basics::LocalTaskQueue> queue) {
|
||||
for (auto const& it : documents) {
|
||||
Result status = insert(trx, it.first, it.second, OperationMode::normal);
|
||||
if (status.errorNumber() != TRI_ERROR_NO_ERROR) {
|
||||
queue->setStatus(status.errorNumber());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -49,13 +49,24 @@ class MMFilesIndex : public Index {
|
|||
virtual bool isHidden() const override {
|
||||
return false; // do not generally hide MMFiles indexes
|
||||
}
|
||||
|
||||
virtual bool isPersistent() const { return false; };
|
||||
|
||||
virtual void batchInsert(transaction::Methods& trx,
|
||||
std::vector<std::pair<LocalDocumentId, arangodb::velocypack::Slice>> const& docs,
|
||||
std::shared_ptr<arangodb::basics::LocalTaskQueue> queue);
|
||||
|
||||
virtual Result insert(transaction::Methods& trx, LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc, OperationMode mode) = 0;
|
||||
|
||||
virtual Result remove(transaction::Methods& trx, LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc, OperationMode mode) = 0;
|
||||
|
||||
void afterTruncate(TRI_voc_tick_t) override {
|
||||
// for mmfiles, truncating the index just unloads it
|
||||
unload();
|
||||
}
|
||||
|
||||
virtual bool isPersistent() const { return false; };
|
||||
};
|
||||
} // namespace arangodb
|
||||
|
||||
|
|
|
@ -68,12 +68,12 @@ void RocksDBBuilderIndex::toVelocyPack(VPackBuilder& builder,
|
|||
}
|
||||
|
||||
/// insert index elements into the specified write batch.
|
||||
Result RocksDBBuilderIndex::insertInternal(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& slice,
|
||||
OperationMode mode) {
|
||||
Result RocksDBBuilderIndex::insert(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& slice,
|
||||
OperationMode mode) {
|
||||
TRI_ASSERT(false); // not enabled
|
||||
Result r = _wrapped->insertInternal(trx, mthd, documentId, slice, mode);
|
||||
Result r = _wrapped->insert(trx, mthd, documentId, slice, mode);
|
||||
if (r.is(TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED)) {
|
||||
// these are expected errors; store in builder and suppress
|
||||
bool expected = false;
|
||||
|
@ -87,10 +87,10 @@ Result RocksDBBuilderIndex::insertInternal(transaction::Methods& trx, RocksDBMet
|
|||
}
|
||||
|
||||
/// remove index elements and put it in the specified write batch.
|
||||
Result RocksDBBuilderIndex::removeInternal(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& slice,
|
||||
OperationMode mode) {
|
||||
Result RocksDBBuilderIndex::remove(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& slice,
|
||||
OperationMode mode) {
|
||||
TRI_ASSERT(false); // not enabled
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(_removedDocsMutex);
|
||||
|
@ -103,7 +103,7 @@ Result RocksDBBuilderIndex::removeInternal(transaction::Methods& trx, RocksDBMet
|
|||
}
|
||||
}
|
||||
|
||||
Result r = _wrapped->removeInternal(trx, mthd, documentId, slice, mode);
|
||||
Result r = _wrapped->remove(trx, mthd, documentId, slice, mode);
|
||||
if (r.is(TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED)) {
|
||||
// these are expected errors; store in builder and suppress
|
||||
bool expected = false;
|
||||
|
@ -134,6 +134,11 @@ struct BuilderTrx : public arangodb::transaction::Methods {
|
|||
private:
|
||||
TRI_voc_cid_t _cid;
|
||||
};
|
||||
|
||||
//struct BuilderCookie {
|
||||
// VPackBuffer<uint8_t>
|
||||
// VPackBuilder _removals;
|
||||
//};
|
||||
} // namespace
|
||||
|
||||
// Background index filler task
|
||||
|
@ -232,8 +237,8 @@ arangodb::Result RocksDBBuilderIndex::fillIndexBackground(std::function<void()>
|
|||
_lockedDocs.insert(docId.id());
|
||||
}
|
||||
|
||||
res = internal->insertInternal(trx, &batched, docId, VPackSlice(it->value().data()),
|
||||
Index::OperationMode::normal);
|
||||
res = internal->insert(trx, &batched, docId, VPackSlice(it->value().data()),
|
||||
Index::OperationMode::normal);
|
||||
if (res.fail()) {
|
||||
break;
|
||||
}
|
||||
|
@ -343,8 +348,8 @@ static arangodb::Result fillIndexFast(RocksDBIndex& ridx, LogicalCollection& col
|
|||
while (it->Valid()) {
|
||||
TRI_ASSERT(it->key().compare(upper) < 0);
|
||||
|
||||
res = ridx.insertInternal(trx, &batched, RocksDBKey::documentId(it->key()),
|
||||
VPackSlice(it->value().data()), Index::OperationMode::normal);
|
||||
res = ridx.insert(trx, &batched, RocksDBKey::documentId(it->key()),
|
||||
VPackSlice(it->value().data()), Index::OperationMode::normal);
|
||||
if (res.fail()) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -71,14 +71,14 @@ class RocksDBBuilderIndex final : public arangodb::RocksDBIndex {
|
|||
bool hasSelectivityEstimate() const override { return false; }
|
||||
|
||||
/// insert index elements into the specified write batch.
|
||||
Result insertInternal(transaction::Methods& trx, RocksDBMethods*,
|
||||
LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const&, OperationMode mode) override;
|
||||
Result insert(transaction::Methods& trx, RocksDBMethods*,
|
||||
LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const&, OperationMode mode) override;
|
||||
|
||||
/// remove index elements and put it in the specified write batch.
|
||||
Result removeInternal(transaction::Methods& trx, RocksDBMethods*,
|
||||
LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const&, OperationMode mode) override;
|
||||
Result remove(transaction::Methods& trx, RocksDBMethods*,
|
||||
LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const&, OperationMode mode) override;
|
||||
|
||||
RocksDBBuilderIndex(std::shared_ptr<arangodb::RocksDBIndex> const&);
|
||||
|
||||
|
|
|
@ -1245,18 +1245,10 @@ Result RocksDBCollection::insertDocument(arangodb::transaction::Methods* trx,
|
|||
READ_LOCKER(guard, _indexesLock);
|
||||
for (std::shared_ptr<Index> const& idx : _indexes) {
|
||||
RocksDBIndex* rIdx = static_cast<RocksDBIndex*>(idx.get());
|
||||
auto tmpres = rIdx->insertInternal(*trx, mthds, documentId, doc, options.indexOperationMode);
|
||||
res = rIdx->insert(*trx, mthds, documentId, doc, options.indexOperationMode);
|
||||
|
||||
if (tmpres.fail()) {
|
||||
if (tmpres.is(TRI_ERROR_OUT_OF_MEMORY)) {
|
||||
// in case of OOM return immediately
|
||||
return tmpres;
|
||||
}
|
||||
|
||||
if (tmpres.is(TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED) || res.ok()) {
|
||||
// "prefer" unique constraint violated over other errors
|
||||
res.reset(tmpres);
|
||||
}
|
||||
if (res.fail()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1296,16 +1288,11 @@ Result RocksDBCollection::removeDocument(arangodb::transaction::Methods* trx,
|
|||
Result resInner;
|
||||
READ_LOCKER(guard, _indexesLock);
|
||||
for (std::shared_ptr<Index> const& idx : _indexes) {
|
||||
auto tmpres = idx->remove(*trx, documentId, doc, options.indexOperationMode);
|
||||
RocksDBIndex* ridx = static_cast<RocksDBIndex*>(idx.get());
|
||||
res = ridx->remove(*trx, mthd, documentId, doc, options.indexOperationMode);
|
||||
|
||||
if (tmpres.fail()) {
|
||||
if (tmpres.is(TRI_ERROR_OUT_OF_MEMORY)) {
|
||||
// in case of OOM return immediately
|
||||
return tmpres;
|
||||
}
|
||||
|
||||
// for other errors, set result
|
||||
res.reset(tmpres);
|
||||
if (res.fail()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1354,16 +1341,11 @@ Result RocksDBCollection::updateDocument(transaction::Methods* trx,
|
|||
READ_LOCKER(guard, _indexesLock);
|
||||
for (std::shared_ptr<Index> const& idx : _indexes) {
|
||||
RocksDBIndex* rIdx = static_cast<RocksDBIndex*>(idx.get());
|
||||
auto tmpres = rIdx->updateInternal(*trx, mthd, oldDocumentId, oldDoc, newDocumentId,
|
||||
newDoc, options.indexOperationMode);
|
||||
res = rIdx->update(*trx, mthd, oldDocumentId, oldDoc, newDocumentId,
|
||||
newDoc, options.indexOperationMode);
|
||||
|
||||
if (tmpres.fail()) {
|
||||
if (tmpres.is(TRI_ERROR_OUT_OF_MEMORY)) {
|
||||
// in case of OOM return immediately
|
||||
return tmpres;
|
||||
}
|
||||
|
||||
res.reset(tmpres);
|
||||
if (res.fail()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -583,10 +583,10 @@ void RocksDBEdgeIndex::toVelocyPack(VPackBuilder& builder,
|
|||
builder.close();
|
||||
}
|
||||
|
||||
Result RocksDBEdgeIndex::insertInternal(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) {
|
||||
Result RocksDBEdgeIndex::insert(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) {
|
||||
Result res;
|
||||
VPackSlice fromTo = doc.get(_directionAttr);
|
||||
TRI_ASSERT(fromTo.isString());
|
||||
|
@ -619,10 +619,10 @@ Result RocksDBEdgeIndex::insertInternal(transaction::Methods& trx, RocksDBMethod
|
|||
return res;
|
||||
}
|
||||
|
||||
Result RocksDBEdgeIndex::removeInternal(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) {
|
||||
Result RocksDBEdgeIndex::remove(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) {
|
||||
Result res;
|
||||
|
||||
// VPackSlice primaryKey = doc.get(StaticStrings::KeyString);
|
||||
|
@ -653,27 +653,6 @@ Result RocksDBEdgeIndex::removeInternal(transaction::Methods& trx, RocksDBMethod
|
|||
return res;
|
||||
}
|
||||
|
||||
void RocksDBEdgeIndex::batchInsert(transaction::Methods& trx,
|
||||
std::vector<std::pair<LocalDocumentId, VPackSlice>> const& documents,
|
||||
std::shared_ptr<arangodb::basics::LocalTaskQueue> queue) {
|
||||
auto* mthds = RocksDBTransactionState::toMethods(&trx);
|
||||
|
||||
for (auto const& doc : documents) {
|
||||
VPackSlice fromTo = doc.second.get(_directionAttr);
|
||||
TRI_ASSERT(fromTo.isString());
|
||||
auto fromToRef = StringRef(fromTo);
|
||||
RocksDBKeyLeaser key(&trx);
|
||||
key->constructEdgeIndexValue(_objectId, fromToRef, doc.first);
|
||||
|
||||
blackListKey(fromToRef);
|
||||
rocksdb::Status s = mthds->Put(_cf, key.ref(), rocksdb::Slice());
|
||||
if (!s.ok()) {
|
||||
queue->setStatus(rocksutils::convertStatus(s).errorNumber());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief checks whether the index supports the condition
|
||||
bool RocksDBEdgeIndex::supportsFilterCondition(
|
||||
std::vector<std::shared_ptr<arangodb::Index>> const& allIndexes,
|
||||
|
|
|
@ -139,10 +139,6 @@ class RocksDBEdgeIndex final : public RocksDBIndex {
|
|||
|
||||
void toVelocyPack(VPackBuilder&, std::underlying_type<Index::Serialize>::type) const override;
|
||||
|
||||
void batchInsert(transaction::Methods& trx,
|
||||
std::vector<std::pair<LocalDocumentId, velocypack::Slice>> const& docs,
|
||||
std::shared_ptr<basics::LocalTaskQueue> queue) override;
|
||||
|
||||
bool hasBatchInsert() const override { return false; }
|
||||
|
||||
bool supportsFilterCondition(std::vector<std::shared_ptr<arangodb::Index>> const& allIndexes,
|
||||
|
@ -164,13 +160,13 @@ class RocksDBEdgeIndex final : public RocksDBIndex {
|
|||
|
||||
void afterTruncate(TRI_voc_tick_t tick) override;
|
||||
|
||||
Result insertInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
Result insert(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
|
||||
Result removeInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
Result remove(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
|
||||
private:
|
||||
/// @brief create the iterator
|
||||
|
|
|
@ -172,10 +172,10 @@ bool RocksDBFulltextIndex::matchesDefinition(VPackSlice const& info) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
Result RocksDBFulltextIndex::insertInternal(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) {
|
||||
Result RocksDBFulltextIndex::insert(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) {
|
||||
Result res;
|
||||
std::set<std::string> words = wordlist(doc);
|
||||
|
||||
|
@ -205,10 +205,10 @@ Result RocksDBFulltextIndex::insertInternal(transaction::Methods& trx, RocksDBMe
|
|||
return res;
|
||||
}
|
||||
|
||||
Result RocksDBFulltextIndex::removeInternal(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) {
|
||||
Result RocksDBFulltextIndex::remove(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) {
|
||||
Result res;
|
||||
std::set<std::string> words = wordlist(doc);
|
||||
|
||||
|
|
|
@ -104,14 +104,14 @@ class RocksDBFulltextIndex final : public RocksDBIndex {
|
|||
|
||||
protected:
|
||||
/// insert index elements into the specified write batch.
|
||||
Result insertInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
Result insert(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
|
||||
/// remove index elements and put it in the specified write batch.
|
||||
Result removeInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
Result remove(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
|
||||
private:
|
||||
std::set<std::string> wordlist(arangodb::velocypack::Slice const&);
|
||||
|
|
|
@ -374,10 +374,10 @@ IndexIterator* RocksDBGeoIndex::iteratorForCondition(
|
|||
}
|
||||
|
||||
/// internal insert function, set batch or trx before calling
|
||||
Result RocksDBGeoIndex::insertInternal(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
arangodb::Index::OperationMode mode) {
|
||||
Result RocksDBGeoIndex::insert(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
arangodb::Index::OperationMode mode) {
|
||||
Result res;
|
||||
|
||||
// covering and centroid of coordinate / polygon / ...
|
||||
|
@ -419,10 +419,10 @@ Result RocksDBGeoIndex::insertInternal(transaction::Methods& trx, RocksDBMethods
|
|||
}
|
||||
|
||||
/// internal remove function, set batch or trx before calling
|
||||
Result RocksDBGeoIndex::removeInternal(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
arangodb::Index::OperationMode mode) {
|
||||
Result RocksDBGeoIndex::remove(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
arangodb::Index::OperationMode mode) {
|
||||
Result res;
|
||||
|
||||
// covering and centroid of coordinate / polygon / ...
|
||||
|
|
|
@ -75,18 +75,18 @@ class RocksDBGeoIndex final : public RocksDBIndex, public geo_index::Index {
|
|||
bool matchesDefinition(velocypack::Slice const& info) const override;
|
||||
|
||||
/// insert index elements into the specified write batch.
|
||||
Result insertInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId, velocypack::Slice const& doc,
|
||||
arangodb::Index::OperationMode mode) override;
|
||||
Result insert(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId, velocypack::Slice const& doc,
|
||||
arangodb::Index::OperationMode mode) override;
|
||||
|
||||
/// remove index elements and put it in the specified write batch.
|
||||
Result removeInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId, velocypack::Slice const& docs,
|
||||
arangodb::Index::OperationMode mode) override;
|
||||
Result remove(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId, velocypack::Slice const& docs,
|
||||
arangodb::Index::OperationMode mode) override;
|
||||
|
||||
private:
|
||||
std::string const _typeName;
|
||||
};
|
||||
} // namespace arangodb
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -239,21 +239,21 @@ void RocksDBIndex::afterTruncate(TRI_voc_tick_t) {
|
|||
}
|
||||
}
|
||||
|
||||
Result RocksDBIndex::updateInternal(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& oldDocumentId,
|
||||
velocypack::Slice const& oldDoc,
|
||||
LocalDocumentId const& newDocumentId,
|
||||
velocypack::Slice const& newDoc,
|
||||
Index::OperationMode mode) {
|
||||
Result RocksDBIndex::update(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& oldDocumentId,
|
||||
velocypack::Slice const& oldDoc,
|
||||
LocalDocumentId const& newDocumentId,
|
||||
velocypack::Slice const& newDoc,
|
||||
Index::OperationMode mode) {
|
||||
// It is illegal to call this method on the primary index
|
||||
// RocksDBPrimaryIndex must override this method accordingly
|
||||
TRI_ASSERT(type() != TRI_IDX_TYPE_PRIMARY_INDEX);
|
||||
|
||||
Result res = removeInternal(trx, mthd, oldDocumentId, oldDoc, mode);
|
||||
Result res = remove(trx, mthd, oldDocumentId, oldDoc, mode);
|
||||
if (!res.ok()) {
|
||||
return res;
|
||||
}
|
||||
return insertInternal(trx, mthd, newDocumentId, newDoc, mode);
|
||||
return insert(trx, mthd, newDocumentId, newDoc, mode);
|
||||
}
|
||||
|
||||
/// @brief return the memory usage of the index
|
||||
|
|
|
@ -72,18 +72,6 @@ class RocksDBIndex : public Index {
|
|||
|
||||
Result drop() override;
|
||||
|
||||
Result insert(transaction::Methods& trx, LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override {
|
||||
auto mthds = RocksDBTransactionState::toMethods(&trx);
|
||||
return insertInternal(trx, mthds, documentId, doc, mode);
|
||||
}
|
||||
|
||||
Result remove(transaction::Methods& trx, LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc, Index::OperationMode mode) override {
|
||||
auto mthds = RocksDBTransactionState::toMethods(&trx);
|
||||
return removeInternal(trx, mthds, documentId, doc, mode);
|
||||
}
|
||||
|
||||
virtual void afterTruncate(TRI_voc_tick_t tick) override;
|
||||
|
||||
void load() override;
|
||||
|
@ -106,22 +94,22 @@ class RocksDBIndex : public Index {
|
|||
void destroyCache();
|
||||
|
||||
/// insert index elements into the specified write batch.
|
||||
virtual Result insertInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) = 0;
|
||||
virtual Result insert(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) = 0;
|
||||
|
||||
/// remove index elements and put it in the specified write batch.
|
||||
virtual Result removeInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) = 0;
|
||||
virtual Result remove(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) = 0;
|
||||
|
||||
virtual Result updateInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& oldDocumentId,
|
||||
arangodb::velocypack::Slice const& oldDoc,
|
||||
LocalDocumentId const& newDocumentId,
|
||||
velocypack::Slice const& newDoc, Index::OperationMode mode);
|
||||
virtual Result update(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& oldDocumentId,
|
||||
arangodb::velocypack::Slice const& oldDoc,
|
||||
LocalDocumentId const& newDocumentId,
|
||||
velocypack::Slice const& newDoc, Index::OperationMode mode);
|
||||
|
||||
rocksdb::ColumnFamilyHandle* columnFamily() const { return _cf; }
|
||||
|
||||
|
@ -164,4 +152,4 @@ class RocksDBIndex : public Index {
|
|||
};
|
||||
} // namespace arangodb
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -432,10 +432,10 @@ bool RocksDBPrimaryIndex::lookupRevision(transaction::Methods* trx, arangodb::St
|
|||
return true;
|
||||
}
|
||||
|
||||
Result RocksDBPrimaryIndex::insertInternal(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& slice,
|
||||
Index::OperationMode mode) {
|
||||
Result RocksDBPrimaryIndex::insert(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& slice,
|
||||
Index::OperationMode mode) {
|
||||
Result res;
|
||||
VPackSlice keySlice = transaction::helpers::extractKeyFromDocument(slice);
|
||||
TRI_ASSERT(keySlice.isString());
|
||||
|
@ -472,12 +472,12 @@ Result RocksDBPrimaryIndex::insertInternal(transaction::Methods& trx, RocksDBMet
|
|||
return res;
|
||||
}
|
||||
|
||||
Result RocksDBPrimaryIndex::updateInternal(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& oldDocumentId,
|
||||
velocypack::Slice const& oldDoc,
|
||||
LocalDocumentId const& newDocumentId,
|
||||
velocypack::Slice const& newDoc,
|
||||
Index::OperationMode mode) {
|
||||
Result RocksDBPrimaryIndex::update(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& oldDocumentId,
|
||||
velocypack::Slice const& oldDoc,
|
||||
LocalDocumentId const& newDocumentId,
|
||||
velocypack::Slice const& newDoc,
|
||||
Index::OperationMode mode) {
|
||||
Result res;
|
||||
VPackSlice keySlice = transaction::helpers::extractKeyFromDocument(oldDoc);
|
||||
TRI_ASSERT(keySlice == oldDoc.get(StaticStrings::KeyString));
|
||||
|
@ -498,10 +498,10 @@ Result RocksDBPrimaryIndex::updateInternal(transaction::Methods& trx, RocksDBMet
|
|||
return res;
|
||||
}
|
||||
|
||||
Result RocksDBPrimaryIndex::removeInternal(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& slice,
|
||||
Index::OperationMode mode) {
|
||||
Result RocksDBPrimaryIndex::remove(transaction::Methods& trx, RocksDBMethods* mthd,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& slice,
|
||||
Index::OperationMode mode) {
|
||||
Result res;
|
||||
|
||||
// TODO: deal with matching revisions?
|
||||
|
|
|
@ -210,19 +210,19 @@ class RocksDBPrimaryIndex final : public RocksDBIndex {
|
|||
std::function<bool(LocalDocumentId const&)> callback) const;
|
||||
|
||||
/// insert index elements into the specified write batch.
|
||||
Result insertInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
Result insert(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
|
||||
/// remove index elements and put it in the specified write batch.
|
||||
Result removeInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
Result remove(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
|
||||
Result updateInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& oldDocumentId,
|
||||
velocypack::Slice const& oldDoc, LocalDocumentId const& newDocumentId,
|
||||
velocypack::Slice const& newDoc, Index::OperationMode mode) override;
|
||||
Result update(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& oldDocumentId,
|
||||
velocypack::Slice const& oldDoc, LocalDocumentId const& newDocumentId,
|
||||
velocypack::Slice const& newDoc, Index::OperationMode mode) override;
|
||||
|
||||
private:
|
||||
/// @brief create the iterator, for a single attribute, IN operator
|
||||
|
|
|
@ -586,10 +586,10 @@ void RocksDBVPackIndex::fillPaths(std::vector<std::vector<std::string>>& paths,
|
|||
}
|
||||
|
||||
/// @brief inserts a document into the index
|
||||
Result RocksDBVPackIndex::insertInternal(transaction::Methods& trx, RocksDBMethods* mthds,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) {
|
||||
Result RocksDBVPackIndex::insert(transaction::Methods& trx, RocksDBMethods* mthds,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) {
|
||||
Result res;
|
||||
rocksdb::Status s;
|
||||
SmallVector<RocksDBKey>::allocator_type::arena_type elementsArena;
|
||||
|
@ -663,17 +663,17 @@ Result RocksDBVPackIndex::insertInternal(transaction::Methods& trx, RocksDBMetho
|
|||
return res;
|
||||
}
|
||||
|
||||
Result RocksDBVPackIndex::updateInternal(transaction::Methods& trx, RocksDBMethods* mthds,
|
||||
LocalDocumentId const& oldDocumentId,
|
||||
velocypack::Slice const& oldDoc,
|
||||
LocalDocumentId const& newDocumentId,
|
||||
velocypack::Slice const& newDoc,
|
||||
Index::OperationMode mode) {
|
||||
Result RocksDBVPackIndex::update(transaction::Methods& trx, RocksDBMethods* mthds,
|
||||
LocalDocumentId const& oldDocumentId,
|
||||
velocypack::Slice const& oldDoc,
|
||||
LocalDocumentId const& newDocumentId,
|
||||
velocypack::Slice const& newDoc,
|
||||
Index::OperationMode mode) {
|
||||
if (!_unique || _useExpansion) {
|
||||
// only unique index supports in-place updates
|
||||
// lets also not handle the complex case of expanded arrays
|
||||
return RocksDBIndex::updateInternal(trx, mthds, oldDocumentId, oldDoc,
|
||||
newDocumentId, newDoc, mode);
|
||||
return RocksDBIndex::update(trx, mthds, oldDocumentId, oldDoc,
|
||||
newDocumentId, newDoc, mode);
|
||||
} else {
|
||||
Result res;
|
||||
rocksdb::Status s;
|
||||
|
@ -699,8 +699,8 @@ Result RocksDBVPackIndex::updateInternal(transaction::Methods& trx, RocksDBMetho
|
|||
}
|
||||
if (!equal) {
|
||||
// we can only use in-place updates if no indexed attributes changed
|
||||
return RocksDBIndex::updateInternal(trx, mthds, oldDocumentId, oldDoc,
|
||||
newDocumentId, newDoc, mode);
|
||||
return RocksDBIndex::update(trx, mthds, oldDocumentId, oldDoc,
|
||||
newDocumentId, newDoc, mode);
|
||||
}
|
||||
|
||||
// more expensive method to
|
||||
|
@ -734,10 +734,10 @@ Result RocksDBVPackIndex::updateInternal(transaction::Methods& trx, RocksDBMetho
|
|||
}
|
||||
|
||||
/// @brief removes a document from the index
|
||||
Result RocksDBVPackIndex::removeInternal(transaction::Methods& trx, RocksDBMethods* mthds,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) {
|
||||
Result RocksDBVPackIndex::remove(transaction::Methods& trx, RocksDBMethods* mthds,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc,
|
||||
Index::OperationMode mode) {
|
||||
Result res;
|
||||
rocksdb::Status s;
|
||||
SmallVector<RocksDBKey>::allocator_type::arena_type elementsArena;
|
||||
|
|
|
@ -200,18 +200,18 @@ class RocksDBVPackIndex : public RocksDBIndex {
|
|||
void afterTruncate(TRI_voc_tick_t tick) override;
|
||||
|
||||
protected:
|
||||
Result insertInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
Result insert(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
|
||||
Result removeInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
Result remove(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& documentId,
|
||||
velocypack::Slice const& doc, Index::OperationMode mode) override;
|
||||
|
||||
Result updateInternal(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& oldDocumentId,
|
||||
velocypack::Slice const& oldDoc, LocalDocumentId const& newDocumentId,
|
||||
velocypack::Slice const& newDoc, Index::OperationMode mode) override;
|
||||
Result update(transaction::Methods& trx, RocksDBMethods* methods,
|
||||
LocalDocumentId const& oldDocumentId,
|
||||
velocypack::Slice const& oldDoc, LocalDocumentId const& newDocumentId,
|
||||
velocypack::Slice const& newDoc, Index::OperationMode mode) override;
|
||||
|
||||
private:
|
||||
/// @brief return the number of paths
|
||||
|
@ -262,4 +262,4 @@ class RocksDBVPackIndex : public RocksDBIndex {
|
|||
};
|
||||
} // namespace arangodb
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "IResearch/IResearchAnalyzerFeature.h"
|
||||
#include "IResearch/IResearchCommon.h"
|
||||
#include "IResearch/IResearchFeature.h"
|
||||
#include "IResearch/IResearchLink.h"
|
||||
#include "IResearch/IResearchMMFilesLink.h"
|
||||
#include "IResearch/IResearchView.h"
|
||||
#include "Logger/Logger.h"
|
||||
|
@ -656,7 +657,9 @@ SECTION("test_write") {
|
|||
arangodb::transaction::Options()
|
||||
);
|
||||
CHECK((trx.begin().ok()));
|
||||
CHECK((link->insert(trx, arangodb::LocalDocumentId(1), doc0->slice(), arangodb::Index::OperationMode::normal).ok()));
|
||||
auto* l = dynamic_cast<arangodb::iresearch::IResearchLink*>(link.get());
|
||||
REQUIRE(l != nullptr);
|
||||
CHECK((l->insert(trx, arangodb::LocalDocumentId(1), doc0->slice(), arangodb::Index::OperationMode::normal).ok()));
|
||||
CHECK((trx.commit().ok()));
|
||||
}
|
||||
|
||||
|
@ -673,7 +676,9 @@ SECTION("test_write") {
|
|||
arangodb::transaction::Options()
|
||||
);
|
||||
CHECK((trx.begin().ok()));
|
||||
CHECK((link->insert(trx, arangodb::LocalDocumentId(2), doc1->slice(), arangodb::Index::OperationMode::normal).ok()));
|
||||
auto* l = dynamic_cast<arangodb::iresearch::IResearchLink*>(link.get());
|
||||
REQUIRE(l != nullptr);
|
||||
CHECK((l->insert(trx, arangodb::LocalDocumentId(2), doc1->slice(), arangodb::Index::OperationMode::normal).ok()));
|
||||
CHECK((trx.commit().ok()));
|
||||
}
|
||||
|
||||
|
@ -690,7 +695,9 @@ SECTION("test_write") {
|
|||
arangodb::transaction::Options()
|
||||
);
|
||||
CHECK((trx.begin().ok()));
|
||||
CHECK((link->remove(trx, arangodb::LocalDocumentId(2), doc1->slice(), arangodb::Index::OperationMode::normal).ok()));
|
||||
auto* l = dynamic_cast<arangodb::iresearch::IResearchLink*>(link.get());
|
||||
REQUIRE(l != nullptr);
|
||||
CHECK((l->remove(trx, arangodb::LocalDocumentId(2), doc1->slice(), arangodb::Index::OperationMode::normal).ok()));
|
||||
CHECK((trx.commit().ok()));
|
||||
}
|
||||
|
||||
|
@ -710,4 +717,4 @@ SECTION("test_write") {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -215,7 +215,7 @@ class EdgeIndexMock final : public arangodb::Index {
|
|||
arangodb::LocalDocumentId const& documentId,
|
||||
arangodb::velocypack::Slice const& doc,
|
||||
OperationMode
|
||||
) override {
|
||||
) {
|
||||
if (!doc.isObject()) {
|
||||
return { TRI_ERROR_INTERNAL };
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ class EdgeIndexMock final : public arangodb::Index {
|
|||
arangodb::LocalDocumentId const&,
|
||||
arangodb::velocypack::Slice const& doc,
|
||||
OperationMode
|
||||
) override {
|
||||
) {
|
||||
if (!doc.isObject()) {
|
||||
return { TRI_ERROR_INTERNAL };
|
||||
}
|
||||
|
@ -598,7 +598,19 @@ std::shared_ptr<arangodb::Index> PhysicalCollectionMock::createIndex(arangodb::v
|
|||
auto res = trx.begin();
|
||||
TRI_ASSERT(res.ok());
|
||||
|
||||
index->batchInsert(trx, docs, taskQueuePtr);
|
||||
if (index->type() == arangodb::Index::TRI_IDX_TYPE_EDGE_INDEX) {
|
||||
auto* l = dynamic_cast<EdgeIndexMock*>(index.get());
|
||||
TRI_ASSERT(l != nullptr);
|
||||
for (auto const& pair : docs) {
|
||||
l->insert(trx, pair.first, pair.second, arangodb::Index::OperationMode::internal);
|
||||
}
|
||||
} else if (index->type() == arangodb::Index::TRI_IDX_TYPE_IRESEARCH_LINK) {
|
||||
auto* l = dynamic_cast<arangodb::iresearch::IResearchLink*>(index.get());
|
||||
TRI_ASSERT(l != nullptr);;
|
||||
l->batchInsert(trx, docs, taskQueuePtr);
|
||||
} else {
|
||||
TRI_ASSERT(false);
|
||||
}
|
||||
|
||||
if (TRI_ERROR_NO_ERROR != taskQueue.status()) {
|
||||
return nullptr;
|
||||
|
@ -689,9 +701,31 @@ arangodb::Result PhysicalCollectionMock::insert(
|
|||
result.setUnmanaged(documents.back().first.data(), docId);
|
||||
|
||||
for (auto& index : _indexes) {
|
||||
if (!index->insert(*trx, docId, arangodb::velocypack::Slice(result.vpack()), arangodb::Index::OperationMode::normal).ok()) {
|
||||
return arangodb::Result(TRI_ERROR_BAD_PARAMETER);
|
||||
if (index->type() == arangodb::Index::TRI_IDX_TYPE_EDGE_INDEX) {
|
||||
auto* l = static_cast<EdgeIndexMock*>(index.get());
|
||||
if (!l->insert(*trx, docId, arangodb::velocypack::Slice(result.vpack()),
|
||||
arangodb::Index::OperationMode::normal).ok()) {
|
||||
return arangodb::Result(TRI_ERROR_BAD_PARAMETER);
|
||||
}
|
||||
continue;
|
||||
} else if (index->type() == arangodb::Index::TRI_IDX_TYPE_IRESEARCH_LINK) {
|
||||
|
||||
if (arangodb::ServerState::instance()->isCoordinator()) {
|
||||
auto* l = static_cast<arangodb::iresearch::IResearchLinkCoordinator*>(index.get());
|
||||
if (!l->insert(*trx, docId, arangodb::velocypack::Slice(result.vpack()),
|
||||
arangodb::Index::OperationMode::normal).ok()) {
|
||||
return arangodb::Result(TRI_ERROR_BAD_PARAMETER);
|
||||
}
|
||||
} else {
|
||||
auto* l = static_cast<arangodb::iresearch::IResearchMMFilesLink*>(index.get());
|
||||
if (!l->insert(*trx, docId, arangodb::velocypack::Slice(result.vpack()),
|
||||
arangodb::Index::OperationMode::normal).ok()) {
|
||||
return arangodb::Result(TRI_ERROR_BAD_PARAMETER);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
TRI_ASSERT(false);
|
||||
}
|
||||
|
||||
return arangodb::Result();
|
||||
|
|
Loading…
Reference in New Issue