Skip to content
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

Check the index have existed although the name not the same #1695

Merged
merged 2 commits into from
Jul 17, 2020
Merged

Check the index have existed although the name not the same #1695

merged 2 commits into from
Jul 17, 2020

Conversation

darionyaphet
Copy link
Contributor

No description provided.

}

for (size_t i = 0; i < fieldNames.size(); i++) {
if (fieldNames[i] != item.get_fields()[i].get_name()) {
Copy link
Contributor

@dangleptr dangleptr Feb 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you ensure the item have the same number fields as the filedNames?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, when the index's field is disaccord, they are not the same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe access invalid index on "item.get_fields()[i]"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a checker, if the size of current index is longer than the previous one , it will skip.

@jude-zhu jude-zhu requested a review from dangleptr February 4, 2020 06:57
Comment on lines 55 to 79
while (checkIter->valid()) {
auto val = checkIter->val();
auto item = MetaServiceUtils::parseIndex(val);
if (item.get_schema_id().getType() != nebula::cpp2::SchemaID::Type::tag_id) {
continue;
}

for (size_t i = 0; i < fieldNames.size(); i++) {
if (fieldNames[i] != item.get_fields()[i].get_name()) {
break;
}

if (i == fieldNames.size() - 1) {
LOG(ERROR) << "Tag Index " << indexName << " have existed";
resp_.set_code(cpp2::ErrorCode::E_EXISTED);
onFinished();
return;
}
}
checkIter->next();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example , exist index1 (col1, col2), then we want create index2(col1, col2, col4), is it work well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

In the test case single_index create on name and multi_index indexed on name and email. It's work.

@@ -43,6 +43,38 @@ void CreateTagIndexProcessor::process(const cpp2::CreateTagIndexReq& req) {
return;
}

auto prefix = MetaServiceUtils::indexPrefix(space);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we unify the code.

@Shylock-Hg Shylock-Hg linked an issue Mar 18, 2020 that may be closed by this pull request
@codecov-io
Copy link

Codecov Report

Merging #1695 into master will increase coverage by 0.25%.
The diff coverage is 95.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1695      +/-   ##
==========================================
+ Coverage   86.90%   87.15%   +0.25%     
==========================================
  Files         636      641       +5     
  Lines       59819    61163    +1344     
==========================================
+ Hits        51984    53307    +1323     
- Misses       7835     7856      +21     
Impacted Files Coverage Δ
src/graph/DescribeSpaceExecutor.h 0.00% <ø> (ø)
src/graph/FetchEdgesExecutor.h 0.00% <ø> (ø)
src/graph/FetchExecutor.cpp 87.77% <ø> (-0.53%) ⬇️
src/graph/FetchVerticesExecutor.h 0.00% <ø> (ø)
src/graph/GoExecutor.h 56.25% <ø> (ø)
src/graph/GraphService.h 100.00% <ø> (ø)
src/graph/PrivilegeExecutor.h 69.56% <ø> (+13.04%) ⬆️
src/graph/SequentialExecutor.h 0.00% <ø> (ø)
src/graph/UseExecutor.h 0.00% <ø> (ø)
src/graph/test/SchemaTest.cpp 96.27% <ø> (-1.07%) ⬇️
... and 96 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0871c69...b1984f7. Read the comment docs.

@@ -454,5 +454,21 @@ BaseProcessor<RESP>::indexCheck(const std::vector<nebula::cpp2::IndexItem>& item
return cpp2::ErrorCode::SUCCEEDED;
}

template<typename RESP>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better put this function to processor/indexMan/ folder, because it's not the concept of BaseProcessor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check item.get_fields().szie() >= fields.size().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before we check the index have checked the fields size.

@dangleptr dangleptr added the priority/low-pri Priority: low label Jul 14, 2020
@dangleptr
Copy link
Contributor

It is a bug. We should address it in next version. @darionyaphet Could you rebase it?

Copy link
Contributor

@dangleptr dangleptr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@dangleptr dangleptr merged commit eedd52b into vesoft-inc:master Jul 17, 2020
xuguruogu pushed a commit to xuguruogu/nebula that referenced this pull request Aug 5, 2020
tong-hao pushed a commit to tong-hao/nebula that referenced this pull request Jun 1, 2021
yixinglu pushed a commit to yixinglu/nebula that referenced this pull request Jan 31, 2023
Co-authored-by: Sophie <[email protected]>

Co-authored-by: hs.zhang <[email protected]>
Co-authored-by: Sophie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/low-pri Priority: low ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reject create duplicate index.
5 participants