Repository navigation
feat(file-index): support attaching indexes to existing data files #582
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
Open
lxy-9602
wants to merge
6
commits into
apache:main
Choose a base branch
from
lxy-9602:file-index-task
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
49bfb42
feat(file-index): support attaching indexes to existing data files
lxy-9602 6a782e1
refactor
lxy-9602 64c431d
publish indexes via temporary files and reuse existing targets
lxy-9602 92060f6
add tests
lxy-9602 7653f6e
change api
lxy-9602 db860f6
add comments
lxy-9602 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <map> | ||
| #include <memory> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "paimon/commit_message.h" | ||
| #include "paimon/result.h" | ||
| #include "paimon/visibility.h" | ||
|
|
||
| namespace paimon { | ||
| class FileSystem; | ||
| class InputStream; | ||
| class MemoryPool; | ||
|
|
||
| /// Serialized index payload using the data file's original field name. | ||
| /// @note IMPORTANT: Callers must ensure fields and payloads match the file's original schema. | ||
| /// This is not validated. | ||
| struct PAIMON_EXPORT FileIndexInput { | ||
| std::string field_name; | ||
| std::string index_type; | ||
| /// Raw payload read from [0, Length()); nullptr denotes an empty index. | ||
| /// Non-null inputs must be nonempty. Borrowed synchronously, never closed or retained. | ||
| std::shared_ptr<InputStream> input; | ||
| }; | ||
|
|
||
| /// Index updates for one data file added by the supplied commit messages. | ||
| struct PAIMON_EXPORT DataFileIndexInput { | ||
| std::string data_file_name; | ||
| std::vector<FileIndexInput> indexes; | ||
| }; | ||
|
|
||
| /// Attaches file indexes to pending commits for fixed-bucket append tables. | ||
| class PAIMON_EXPORT FileIndexWrite { | ||
| public: | ||
| FileIndexWrite() = delete; | ||
| ~FileIndexWrite() = delete; | ||
|
|
||
| /// Writes one external container per file, preserving indexes except supplied field/type pairs. | ||
| /// Ignores the embedding threshold; preserves other extra files and historical index files. | ||
| /// Reuses existing targets without reading or writing index payloads; still prepares messages. | ||
| /// Otherwise publishes UUID temporary files via Rename. If the target appears meanwhile, | ||
| /// reuses it and cleans up the temporary file best-effort. Existing contents are not validated. | ||
| /// Concurrent publication requires atomic rename without overwrite from the file system. | ||
| /// Payloads must use physical row positions, including DV-deleted rows. Do not use input | ||
| /// streams concurrently. Null file system or pool uses the corresponding default. | ||
| /// | ||
| /// @param branch Target branch; empty selects main. | ||
| /// @param options Table option overrides; bucket count cannot change. | ||
| /// @param messages Pending messages from the same table and branch; no snapshot is required. | ||
| /// @param files Unique names of NewFiles or CompactAfter files and field/type pairs. | ||
| /// Empty index lists leave the corresponding files unchanged. | ||
| /// @return Messages in input order with updated file metadata; inputs are not modified. | ||
| /// Commit the returned messages instead of the originals. Other increments are preserved. | ||
| /// New index files are cleaned up best-effort on failure; callers handle commit recovery. | ||
| static Result<std::vector<std::shared_ptr<CommitMessage>>> PrepareCommit( | ||
| const std::string& table_path, const std::string& branch, | ||
| const std::map<std::string, std::string>& options, | ||
| const std::vector<std::shared_ptr<CommitMessage>>& messages, | ||
| const std::vector<DataFileIndexInput>& files, | ||
| const std::shared_ptr<FileSystem>& file_system, const std::shared_ptr<MemoryPool>& pool); | ||
| }; | ||
|
|
||
| } // namespace paimon | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
AttachIndexesfor this api?