Skip to content

refactor: improve type safety and const-correctness#192

Open
lxy-9602 wants to merge 8 commits intoalibaba:mainfrom
lxy-9602:refactor-code
Open

refactor: improve type safety and const-correctness#192
lxy-9602 wants to merge 8 commits intoalibaba:mainfrom
lxy-9602:refactor-code

Conversation

@lxy-9602
Copy link
Collaborator

@lxy-9602 lxy-9602 commented Mar 20, 2026

Purpose

Linked issue: #93

  1. Fix LookupLevels to support key fields at any position in schema.
  2. Replace 'auto' with explicit types in PAIMON_ASSIGN_OR_RAISE to improve clarity.
  3. Mark getter methods that access member variables as 'const'.

For 1. KeyValueDataFileRecordReader previously used key_arity (an integer) to extract key fields by positional index, assuming they always appear right after the two special fields (_SEQUENCE_NUMBER, _VALUE_KIND).

For the normal read path this was not an issue, because MergeFileSplitRead reorders the schema to place key fields before value fields. However, LookupLevels does not perform this reordering, so during compaction the lookup process would fail to correctly extract key fields when they appear after value fields.

This fix replaces int32_t key_arity with std::shared_ptr<arrow::Schema> key_schema and uses GetFieldByName to locate key columns by name regardless of their physical position.

Tests

LookupLevelsTest, TestLevelsWithValueFieldAppearBeforeKey
KeyValueDataFileRecordReaderTest, TestKeyFieldAfterValueField

Generative AI tooling

Partially Generated-by: Claude-4.6-Opus

@fafacao86
Copy link
Contributor

I think it would be good to have some coding style guideline for paimon-cpp contribution docs. 😸

@lxy-9602
Copy link
Collaborator Author

lxy-9602 commented Mar 20, 2026

I think it would be good to have some coding style guideline for paimon-cpp contribution docs. 😸

Great idea! We'll add that in later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants