Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.9k
[vec](load) fix core of segment_writer while it is not thread-safe#9569
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
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -104,23 +104,28 @@ Status BetaRowsetWriter::add_block(const vectorized::Block* block) { | ||
| if (UNLIKELY(_segment_writer == nullptr)) { | ||
| RETURN_NOT_OK(_create_segment_writer(&_segment_writer)); | ||
| } | ||
| return _add_block(block, &_segment_writer); | ||
| } | ||
| Status BetaRowsetWriter::_add_block(const vectorized::Block* block, | ||
| std::unique_ptr<segment_v2::SegmentWriter>* segment_writer) { | ||
yixiutt marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| size_t block_size_in_bytes = block->bytes(); | ||
| size_t block_row_num = block->rows(); | ||
| size_t row_avg_size_in_bytes = std::max((size_t)1, block_size_in_bytes / block_row_num); | ||
| size_t row_offset = 0; | ||
| do { | ||
| auto max_row_add = _segment_writer->max_row_to_add(row_avg_size_in_bytes); | ||
| auto max_row_add = (*segment_writer)->max_row_to_add(row_avg_size_in_bytes); | ||
| if (UNLIKELY(max_row_add < 1)) { | ||
| // no space for another signle row, need flush now | ||
| RETURN_NOT_OK(_flush_segment_writer(&_segment_writer)); | ||
| RETURN_NOT_OK(_create_segment_writer(&_segment_writer)); | ||
| max_row_add = _segment_writer->max_row_to_add(row_avg_size_in_bytes); | ||
| RETURN_NOT_OK(_flush_segment_writer(segment_writer)); | ||
| RETURN_NOT_OK(_create_segment_writer(segment_writer)); | ||
| max_row_add = (*segment_writer)->max_row_to_add(row_avg_size_in_bytes); | ||
| DCHECK(max_row_add > 0); | ||
| } | ||
| size_t input_row_num = std::min(block_row_num - row_offset, size_t(max_row_add)); | ||
| auto s = _segment_writer->append_block(block, row_offset, input_row_num); | ||
| auto s = (*segment_writer)->append_block(block, row_offset, input_row_num); | ||
| if (UNLIKELY(!s.ok())) { | ||
| LOG(WARNING) << "failed to append block: " << s.to_string(); | ||
| return Status::OLAPInternalError(OLAP_ERR_WRITER_DATA_WRITE_ERROR); | ||
| @@ -250,6 +255,17 @@ Status BetaRowsetWriter::flush_single_memtable(MemTable* memtable, int64_t* flus | ||
| return Status::OK(); | ||
| } | ||
| Status BetaRowsetWriter::flush_single_memtable(const vectorized::Block* block) { | ||
| if (block->rows() == 0) { | ||
| return Status::OK(); | ||
| } | ||
| std::unique_ptr<segment_v2::SegmentWriter> writer; | ||
| RETURN_NOT_OK(_create_segment_writer(&writer)); | ||
| RETURN_NOT_OK(_add_block(block, &writer)); | ||
| RETURN_NOT_OK(_flush_segment_writer(&writer)); | ||
| return Status::OK(); | ||
| } | ||
| RowsetSharedPtr BetaRowsetWriter::build() { | ||
| // TODO(lingbin): move to more better place, or in a CreateBlockBatch? | ||
| for (auto& wblock : _wblocks) { | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.