zjw1111 commented on code in PR #368:
URL: https://github.com/apache/paimon-cpp/pull/368#discussion_r4045480027
##########
src/paimon/core/operation/data_evolution_split_read.cpp:
##########
@@ -215,11 +215,32 @@ Result<std::unique_ptr<BatchReader>>
DataEvolutionSplitRead::CreateReader(
if (auto indexed_split =
std::dynamic_pointer_cast<IndexedSplitImpl>(split)) {
PAIMON_RETURN_NOT_OK(indexed_split->Validate());
const auto& data_split = indexed_split->GetDataSplit();
- PAIMON_ASSIGN_OR_RAISE(std::unique_ptr<BatchReader> batch_reader,
- InnerCreateReader(data_split,
indexed_split->RowRanges()));
- if (HasIndexScoreField(raw_read_schema_)) {
+ auto read_schema = raw_read_schema_;
+ bool complete_scores = HasIndexScoreField(read_schema) &&
!indexed_split->Scores().empty();
+ bool remove_row_id = false;
+ std::unordered_map<int64_t, float> scores_by_row_id;
+ if (complete_scores) {
+ scores_by_row_id.reserve(indexed_split->Scores().size());
+ size_t score_idx = 0;
+ for (const auto& range : indexed_split->RowRanges()) {
+ for (int64_t row_id = range.from; row_id <= range.to;
++row_id) {
+ scores_by_row_id.emplace(row_id,
indexed_split->Scores()[score_idx++]);
+ }
+ }
+ remove_row_id =
read_schema->GetFieldIndex(SpecialFields::RowId().Name()) < 0;
+ if (remove_row_id) {
+ PAIMON_ASSIGN_OR_RAISE_FROM_ARROW(
+ read_schema,
read_schema->AddField(read_schema->num_fields(),
+
DataField::ConvertDataFieldToArrowField(
+
SpecialFields::RowId())));
+ }
+ }
Review Comment:
Let's defer this refactoring until the global PK index actually needs to
reuse this logic. I'll keep the current structure in this PR and revisit the
shared abstraction when that use case is implemented.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]