8000 Merge pull request #4812 from arangodb/bug-fix/internal-issue-#375 · mnemosdev/arangodb@07f7769 · GitHub
[go: up one dir, main page]

Skip to content

Commit 07f7769

Browse files
author
Andrey Abramov
authored
Merge pull request arangodb#4812 from arangodb/bug-fix/internal-issue-#375
remove ArangoSearch dependencies from StorageEngineMock
2 parents c2cda95 + 926a869 commit 07f7769

File tree

5 files changed

+50
-17
lines changed

5 files changed

+50
-17
lines changed

arangod/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ if (USE_IRESEARCH)
4848
add_library(${LIB_ARANGO_IRESEARCH}
4949
STATIC
5050
IResearch/ApplicationServerHelper.h IResearch/ApplicationServerHelper.cpp
51-
IResearch/AttributeScorer.cpp IResearch/AttributeScorer.h
5251
IResearch/Containers.cpp IResearch/Containers.h
5352
IResearch/IResearchAnalyzerFeature.cpp IResearch/IResearchAnalyzerFeature.h
5453
IResearch/IResearchAttributes.cpp IResearch/IResearchAttributes.h

arangod/IResearch/AqlHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ bool attributeAccessEqual(
296296
}
297297

298298
return lhsValue.type != NodeValue::Type::INVALID
299-
&& lhsValue.type != NodeValue::Type::INVALID
299+
&& rhsValue.type != NodeValue::Type::INVALID
300300
&& rhsValue == lhsValue;
301301
}
302302

arangod/IResearch/IResearchOrderFactory.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424
#include "IResearchOrderFactory.h"
2525

2626
#include "AqlHelper.h"
27-
#include "AttributeScorer.h"
2827
#include "IResearchAttributes.h"
2928
#include "VelocyPackHelper.h"
3029

3130
#include "Aql/AstNode.h"
3231
#include "Aql/Function.h"
3332
#include "Aql/SortCondition.h"
3433

34+
#include "search/scorers.hpp"
35+
3536
// ----------------------------------------------------------------------------
3637
// --SECTION-- OrderFactory dependencies
3738
// ----------------------------------------------------------------------------

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ if (USE_IRESEARCH)
4444
IResearch/IResearchQueryAggregate-test.cpp
4545
IResearch/IResearchQueryTraversal-test.cpp
4646
IResearch/ExpressionFilter-test.cpp
47-
IResearch/StorageEngineMock.cpp
4847
IResearch/ExecutionBlockMock.cpp
4948
IResearch/ExpressionContextMock.cpp
5049
IResearch/VelocyPackHelper-test.cpp
@@ -115,6 +114,7 @@ add_executable(
115114
RocksDBEngine/TypeConversionTest.cpp
116115
SimpleHttpClient/CommunicatorTest.cpp
117116
VocBase/LogicalDataSource-test.cpp
117+
IResearch/StorageEngineMock.cpp
118118
${IRESEARCH_TESTS_SOURCES}
119119
main.cpp
120120
)

tests/IResearch/StorageEngineMock.cpp

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
#include "Basics/LocalTaskQueue.h"
2727
#include "Basics/Result.h"
2828
#include "Basics/StaticStrings.h"
29+
#include "Basics/VelocyPackHelper.h"
2930
#include "Indexes/IndexIterator.h"
3031
#include "Indexes/SimpleAttributeEqualityMatcher.h"
32+
#ifdef USE_IRESEARCH
3133
#include "IResearch/IResearchFeature.h"
3234
#include "IResearch/IResearchMMFilesLink.h"
33-
#include "IResearch/VelocyPackHelper.h"
35+
#endif
3436
#include "Transaction/Methods.h"
3537
#include "Utils/OperationOptions.h"
3638
#include "velocypack/Iterator.h"
@@ -41,7 +43,7 @@
4143
#include "Transaction/Helpers.h"
4244
#include "Aql/AstNode.h"
4345

44-
NS_LOCAL
46+
namespace {
4547

4648
/// @brief hard-coded vector of the index attributes
4749
/// note that the attribute names must be hard-coded here to avoid an init-order
@@ -142,9 +144,12 @@ class EdgeIndexMock final : public arangodb::Index {
142144
return nullptr;
143145
}
144146

145-
auto const type = arangodb::iresearch::getStringRef(typeSlice);
147+
auto const type = arangodb::basics::VelocyPackHelper::getStringRef(
148+
typeSlice,
149+
arangodb::velocypack::StringRef()
150+
);
146151

147-
if (type != "edge") {
152+
if (type.compare("edge") != 0) {
148153
return nullptr;
149154
}
150155

@@ -491,7 +496,30 @@ class AllIteratorMock final : public arangodb::IndexIterator {
491496
uint64_t _end;
492497
}; // AllIteratorMock
493498

494-
NS_END
499+
bool mergeSlice(
500+
arangodb::velocypack::Builder& builder,
501+
arangodb::velocypack::Slice const& slice
502+
) {
503+
if (builder.isOpenArray()) {
504+
if (slice.isArray()) {
505+
builder.add(arangodb::velocypack::ArrayIterator(slice));
506+
} else {
507+
builder.add(slice);
508+
}
509+
510+
return true;
511+
}
512+
513+
if (builder.isOpenObject() && slice.isObject()) {
514+
builder.add(arangodb::velocypack::ObjectIterator(slice));
515+
516+
return true;
517+
}
518+
519+
return false;
520+
}
521+
522+
}
495523

496524
void ContextDataMock::pinData(arangodb::LogicalCollection* collection) {
497525
if (collection) {
@@ -540,14 +568,19 @@ std::shared_ptr<arangodb::Index> PhysicalCollectionMock::createIndex(arangodb::t
540568
}
541569
}
542570

543-
auto const type = arangodb::iresearch::getStringRef(info.get("type"));
571+
auto const type = arangodb::basics::VelocyPackHelper::getStringRef(
572+
info.get("type"),
573+
arangodb::velocypack::StringRef()
574+
);
544575

545576
std::shared_ptr<arangodb::Index> index;
546577

547-
if (type == "edge") {
578+
if (0 == type.compare("edge")) {
548579
index = EdgeIndexMock::make(++lastId, _logicalCollection, info);
549-
} else if (arangodb::iresearch::IResearchFeature::type() == type) {
580+
#ifdef USE_IRESEARCH
581+
} else if (0 == type.compare(arangodb::iresearch::IResearchFeature::type())) {
550582
index = arangodb::iresearch::IResearchMMFilesLink::make(++lastId, _logicalCollection, info);
583+
#endif
551584
}
552585

553586
if (!index) {
@@ -603,15 +636,15 @@ std::unique_ptr<arangodb::IndexIterator> PhysicalCollectionMock::getAllIterator(
603636
before();
604637

605638
if (reverse) {
606-
return irs::memory::make_unique<ReverseAllIteratorMock>(documents.size(), this->_logicalCollection, trx);
639+
return std::make_unique<ReverseAllIteratorMock>(documents.size(), this->_logicalCollection, trx);
607640
}
608641

609-
return irs::memory::make_unique<AllIteratorMock>(documents.size(), this->_logicalCollection, trx);
642+
return std::make_unique<AllIteratorMock>(documents.size(), this->_logicalCollection, trx);
610643
}
611644

612645
std::unique_ptr<arangodb::IndexIterator> PhysicalCollectionMock::getAnyIterator(arangodb::transaction::Methods* trx) const {
613646
before();
614-
return irs::memory::make_unique<AllIteratorMock>(documents.size(), this->_logicalCollection, trx);
647+
return std::make_unique<AllIteratorMock>(documents.size(), this->_logicalCollection, trx);
615648
}
616649

617650
void PhysicalCollectionMock::getPropertiesVPack(arangodb::velocypack::Builder&) const {
@@ -879,7 +912,7 @@ arangodb::Result PhysicalCollectionMock::update(arangodb::transaction::Methods*
879912

880913
builder.openObject();
881914

882-
if (!arangodb::iresearch::mergeSlice(builder, newSlice)) {
915+
if (!mergeSlice(builder, newSlice)) {
883916
return arangodb::Result(TRI_ERROR_BAD_PARAMETER);
884917
}
885918

@@ -1161,7 +1194,7 @@ TRI_vocbase_t* StorageEngineMock::openDatabase(arangodb::velocypack::Slice const
11611194
return nullptr;
11621195
}
11631196

1164-
auto vocbase = irs::memory::make_unique<TRI_vocbase_t>(
1197+
auto vocbase = std::make_unique<TRI_vocbase_t>(
11651198
TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL,
11661199
vocbases.size(),
11671200
args.get("name").copyString()

0 commit comments

Comments
 (0)
0