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

Storages: support building vector index for ColumnFileTiny (Part 2) #9546

Merged
merged 4 commits into from
Oct 25, 2024

Conversation

Lloyd-Pottiger
Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger commented Oct 21, 2024

What problem does this PR solve?

Issue Number: ref #9600

Problem Summary:

What is changed and how it works?

This PR is part of https://github.com/tidbcloud/tiflash-cse/pull/293, which introduce the write path.

Unit tests will be included in next PR.


Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 21, 2024
@@ -142,6 +142,18 @@ void VectorIndexHNSWBuilder::save(std::string_view path) const
RUNTIME_CHECK_MSG(result, "Failed to save vector index: {} path={}", result.error.what(), path);
}

void VectorIndexHNSWBuilder::save(WriteBuffer & write_buf) const
Copy link
Contributor

Choose a reason for hiding this comment

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

saveToBuffer may be more clear. I am not sure whether the compiler will implicitly cast string_view as WriteBuffer cause by the future code changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed.

Signed-off-by: Lloyd-Pottiger <[email protected]>
if (tiny_file->hasIndex(index.index_id))
continue;

any_new_index_build = true;
Copy link
Member

Choose a reason for hiding this comment

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

Why it happens before duplicated index check(L64-L68)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For example, there are file_1, file_2, file_3, and index_1, index_2, index_3, and file_1 with index_1, file_2 with index_2, file_3 with index_3.

any_new_index_build means whether the file needs to build the index, so any_new_index_build should be true for all files in this case.

indexes_to_build contains all index information that will be built in the task, so indexes_to_build should contain information of all indexes in this case.


for (const auto & [col_id, index_infos] : col_indexes)
{
// Make sure the column_id is in the schema.
Copy link
Member

Choose a reason for hiding this comment

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

So we are sure that the schema is up-to-date here? I assume there is somewhere that we call syncSchema or something to ensure this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we do not need to guarantee this. If one file's schema is not up-to-date, we will just skip the new created index.

while (true)
{
if (!should_proceed())
throw Exception(ErrorCodes::ABORTED, "Index build is interrupted");
Copy link
Member

@CalvinNeo CalvinNeo Oct 23, 2024

Choose a reason for hiding this comment

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

Why use a exception here rather than a status code? I see it is originally like this in tiflash-cse, I just wonder if it is necessary to use a status code if the ErrorCodes::ABORTED is a regular case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the task is running in a thread pool, it is async.

Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

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

Generally looks good!

Signed-off-by: Lloyd-Pottiger <[email protected]>
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Oct 25, 2024
Copy link
Member

@CalvinNeo CalvinNeo left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

ti-chi-bot bot commented Oct 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: breezewish, CalvinNeo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [CalvinNeo,breezewish]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 25, 2024
Copy link
Contributor

ti-chi-bot bot commented Oct 25, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-10-25 05:55:05.421847304 +0000 UTC m=+589706.118637915: ☑️ agreed by breezewish.
  • 2024-10-25 06:23:16.811732302 +0000 UTC m=+591397.508522907: ☑️ agreed by CalvinNeo.

@ti-chi-bot ti-chi-bot bot merged commit a1a3b9b into pingcap:master Oct 25, 2024
5 checks passed
@Lloyd-Pottiger Lloyd-Pottiger deleted the cf-tiny-vector-index branch October 25, 2024 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants