8000 Feature/arangosearch link version by gnusi · Pull Request #14717 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Feature/arangosearch link version #14717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
  • Loading branch information
gnusi committed Sep 2, 2021
commit 34c9f2c41b44116a5bcf31c4df0e98edfd9a674f
34 changes: 19 additions & 15 deletions tests/IResearch/IResearchQueryNoMaterialization-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,19 @@ static const char* collectionName1 = "collection_1";
static const char* collectionName2 = "collection_2";

static const char* viewName = "view";
// -----------------------------------------------------------------------------
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------

class IResearchQueryNoMaterializationTest : public IResearchQueryTest {
protected:
std::deque<arangodb::ManagedDocumentResult> insertedDocs;

void addLinkToCollection(std::shared_ptr<arangodb::iresearch::IResearchView>& view) {
auto versionStr = std::to_string(static_cast<uint32_t>(linkVersion()));

auto updateJson = VPackParser::fromJson(
std::string("{") +
"\"links\": {"
"\"" + collectionName1 + "\": {\"includeAllFields\": true, \"storeValues\": \"id\"},"
"\"" + collectionName2 + "\": {\"includeAllFields\": true, \"storeValues\": \"id\"}"
"\"" + collectionName1 + "\": {\"includeAllFields\": true, \"storeValues\": \"id\", \"version\": " + versionStr + "},"
"\"" + collectionName2 + "\": {\"includeAllFields\": true, \"storeValues\": \"id\", \"version\": " + versionStr + "}"
"}}");
EXPECT_TRUE(view->properties(updateJson->slice(), true, true).ok());

Expand Down Expand Up @@ -276,7 +275,7 @@ class IResearchQueryNoMaterializationTest : public IResearchQueryTest {
// --SECTION-- test suite
// -----------------------------------------------------------------------------

TEST_F(IResearchQueryNoMaterializationTest, sortColumnPriority) {
TEST_P(IResearchQueryNoMaterializationTest, sortColumnPriority) {
auto const queryString = std::string("FOR d IN ") + viewName +
" SEARCH d.value IN [1, 2, 11, 12] SORT d.value RETURN d.value";

Expand All @@ -290,7 +289,7 @@ TEST_F(IResearchQueryNoMaterializationTest, sortColumnPriority) {
executeAndCheck(queryString, expectedValues, 1, {{arangodb::iresearch::IResearchViewNode::SortColumnNumber, 0}});
}

TEST_F(IResearchQueryNoMaterializationTest, sortColumnPriorityViewsSubquery) {
TEST_P(IResearchQueryNoMaterializationTest, sortColumnPriorityViewsSubquery) {
// this checks proper stored variables buffer resizing uring optimization
auto const queryString = std::string("FOR c IN ") + viewName + "2 SEARCH c.value IN [1, 2, 11, 12] SORT c.value FOR d IN " + viewName +
" SEARCH d.value == c.value SORT d.value RETURN d.value";
Expand Down Expand Up @@ -330,7 +329,7 @@ TEST_F(IResearchQueryNoMaterializationTest, sortColumnPriorityViewsSubquery) {
EXPECT_EQ(expectedValue, expectedValues.end());
}

TEST_F(IResearchQueryNoMaterializationTest, maxMatchColumnPriority) {
TEST_P(IResearchQueryNoMaterializationTest, maxMatchColumnPriority) {
auto const queryString = std::string("FOR d IN ") + viewName +
" FILTER d.str == 'cat' SORT d.value RETURN d.value";

Expand All @@ -348,7 +347,7 @@ TEST_F(IResearchQueryNoMaterializationTest, maxMatchColumnPriority) {
executeAndCheck(queryString, expectedValues, 1, {{3, 0}, {3, 1}});
}

TEST_F(IResearchQueryNoMaterializationTest, sortAndStoredValues) {
TEST_P(IResearchQueryNoMaterializationTest, sortAndStoredValues) {
auto const queryString = std::string("FOR d IN ") + viewName +
" SORT d._id RETURN d.foo";

Expand All @@ -366,7 +365,7 @@ TEST_F(IResearchQueryNoMaterializationTest, sortAndStoredValues) {
executeAndCheck(queryString, expectedValues, 2, {{arangodb::iresearch::IResearchViewNode::SortColumnNumber, 1}, {2, 0}});
}

TEST_F(IResearchQueryNoMaterializationTest, fieldExistence) {
TEST_P(IResearchQueryNoMaterializationTest, fieldExistence) {
auto const queryString = std::string("FOR d IN ") + viewName +
" SEARCH EXISTS(d.exist) SORT d.value RETURN d.value";

Expand All @@ -380,7 +379,7 @@ TEST_F(IResearchQueryNoMaterializationTest, fieldExistence) {
executeAndCheck(queryString, expectedValues, 1, {{arangodb::iresearch::IResearchViewNode::SortColumnNumber, 0}});
}

TEST_F(IResearchQueryNoMaterializationTest, storedFieldExistence) {
TEST_P(IResearchQueryNoMaterializationTest, storedFieldExistence) {
auto const queryString = std::string("FOR d IN ") + viewName +
" SEARCH EXISTS(d.exist) SORT d.value RETURN d.exist";

Expand All @@ -394,7 +393,7 @@ TEST_F(IResearchQueryNoMaterializationTest, storedFieldExistence) {
executeAndCheck(queryString, expectedValues, 2, {{arangodb::iresearch::IResearchViewNode::SortColumnNumber, 0}, {4, 0}});
}

TEST_F(IResea 8000 rchQueryNoMaterializationTest, emptyField) {
TEST_P(IResearchQueryNoMaterializationTest, emptyField) {
auto const queryString = std::string("FOR d IN ") + viewName +
" SORT d.exist DESC LIMIT 1 RETURN d.exist";

Expand All @@ -405,7 +404,7 @@ TEST_F(IResearchQueryNoMaterializationTest, emptyField) {
executeAndCheck(queryString, expectedValues, 1, {{4, 0}});
}

TEST_F(IResearchQueryNoMaterializationTest, testStoredValuesRecord) {
TEST_P(IResearchQueryNoMaterializationTest, testStoredValuesRecord) {
static std::vector<std::string> const EMPTY;
auto doc = arangodb::velocypack::Parser::fromJson("{ \"str\": \"abc\", \"value\": 10 }");
std::string collectionName("testCollection");
Expand Down Expand Up @@ -551,7 +550,7 @@ TEST_F(IResearchQueryNoMaterializationTest, testStoredValuesRecord) {
}
}

TEST_F(IResearchQueryNoMaterializationTest, testStoredValuesRecordWithCompression) {
TEST_P(IResearchQueryNoMaterializationTest, testStoredValuesRecordWithCompression) {
static std::vector<std::string> const EMPTY;
auto doc = arangodb::velocypack::Parser::fromJson("{ \"str\": \"abc\", \"value\": 10 }");
std::string collectionName("testCollection");
Expand Down Expand Up @@ -697,7 +696,7 @@ TEST_F(IResearchQueryNoMaterializationTest, testStoredValuesRecordWithCompressio
}
}

TEST_F(IResearchQueryNoMaterializationTest, matchSortButNotEnoughAttributes) {
TEST_P(IResearchQueryNoMaterializationTest, matchSortButNotEnoughAttributes) {
auto const queryString = std::string("FOR d IN ") + viewName +
" SEARCH d.value IN [1, 2, 11, 12] FILTER d.boo == '12312' SORT d.boo ASC "
" RETURN DISTINCT {resource_type: d.foo, version: d.not_in_stored}";
Expand All @@ -722,3 +721,8 @@ TEST_F(IResearchQueryNoMaterializationTest, matchSortButNotEnoughAttributes) {
}
EXPECT_TRUE(found);
}

INSTANTIATE_TEST_CASE_P(
IResearchQueryNoMaterializationTest,
IResearchQueryNoMaterializationTest,
GetLinkVersions());
42 changes: 27 additions & 15 deletions tests/IResearch/IResearchQueryNullTerm-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,17 @@

#include <velocypack/Iterator.h>

#include "utils/string_utils.hpp"

extern const char* ARGV0; // defined in main.cpp

namespace {

// -----------------------------------------------------------------------------
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------

class IResearchQueryNullTermTest : public IResearchQueryTest {};

} // namespace

// -----------------------------------------------------------------------------
// --SECTION-- test suite
// -----------------------------------------------------------------------------

TEST_F(IResearchQueryNullTermTest, test) {
TEST_P(IResearchQueryNullTermTest, test) {
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, testDBInfo(server.server()));
arangodb::LogicalView* view{};
std::vector<arangodb::velocypack::Builder> insertedDocs;
Expand Down Expand Up @@ -139,12 +133,25 @@ TEST_F(IResearchQueryNullTermTest, test) {
auto* impl = dynamic_cast<arangodb::iresearch::IResearchView*>(view);
ASSERT_FALSE(!impl);

auto updateJson = arangodb::velocypack::Parser::fromJson(
"{ \"links\": {"
"\"testCollection0\": { \"includeAllFields\": true, "
"\"trackListPositions\": true },"
"\"testCollection1\": { \"includeAllFields\": true }"
"}}");
auto viewDefinitionTemplate = R"({
"links": {
"testCollection0": {
"includeAllFields": true,
"trackListPositions": true,
"version":%u },
"testCollection1": {
"includeAllFields": true,
"version":%u }
}
})";

auto viewDefinition = irs::string_utils::to_string(
viewDefinitionTemplate,
static_cast<uint32_t>(linkVersion()),
static_cast<uint32_t>(linkVersion()));

auto updateJson = VPackParser::fromJson(viewDefinition);

EXPECT_TRUE(impl->properties(updateJson->slice(), true, true).ok());
std::set<arangodb::DataSourceId> cids;
impl->visitCollections([&cids](arangodb::DataSourceId cid) -> bool {
Expand Down Expand Up @@ -1293,3 +1300,8 @@ TEST_F(IResearchQueryNullTermTest, test) {
EXPECT_FALSE(resultIt.valid());
}
}

INSTANTIATE_TEST_CASE_P(
IResearchQueryNullTermTest,
IResearchQueryNullTermTest,
GetLinkVersions());
40 changes: 26 additions & 14 deletions tests/IResearch/IResearchQueryNumericTerm-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,17 @@

#include <velocypack/Iterator.h>

#include "utils/string_utils.hpp"

extern const char* ARGV0; // defined in main.cpp

namespace {

// -----------------------------------------------------------------------------
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------

class IResearchQueryNumericTermTest : public IResearchQueryTest {};

} // namespace

// -----------------------------------------------------------------------------
// --SECTION-- test suite
// -----------------------------------------------------------------------------

TEST_F(IResearchQueryNumericTermTest, test) {
TEST_P(IResearchQueryNumericTermTest, test) {
// ArangoDB specific string comparer
struct StringComparer {
bool operator()(irs::string_ref const& lhs, irs::string_ref const& rhs) const {
Expand Down Expand Up @@ -93,11 +87,24 @@ TEST_F(IResearchQueryNumericTermTest, test) {

// add link to collection
{
auto updateJson = arangodb::velocypack::Parser::fromJson(
"{ \"links\" : {"
"\"collection_1\" : { \"includeAllFields\" : true },"
"\"collection_2\" : { \"includeAllFields\" : true }"
"}}");
auto viewDefinitionTemplate = R"({
"links": {
"collection_1": {
"includeAllFields": true,
"version":%u },
"collection_2": {
"includeAllFields": true,
"version":%u }
}
})";

auto viewDefinition = irs::string_utils::to_string(
viewDefinitionTemplate,
static_cast<uint32_t>(linkVersion()),
static_cast<uint32_t>(linkVersion()));

auto updateJson = VPackParser::fromJson(viewDefinition);

EXPECT_TRUE(view->properties(updateJson->slice(), true, true).ok());

arangodb::velocypack::Builder builder;
Expand Down Expand Up @@ -3010,3 +3017,8 @@ TEST_F(IResearchQueryNumericTermTest, test) {
EXPECT_EQ(expectedDoc, expectedDocs.rend());
}
}

INSTANTIATE_TEST_CASE_P(
IResearchQueryNumericTermTest,
IResearchQueryNumericTermTest,
GetLinkVersions());
Loading
0