Skip to content

[refactor](fe) Extract toThrift from descriptor classes into DescriptorToThriftConverter#62312

Merged
924060929 merged 2 commits intoapache:masterfrom
morrySnow:slot-thrift
Apr 10, 2026
Merged

[refactor](fe) Extract toThrift from descriptor classes into DescriptorToThriftConverter#62312
924060929 merged 2 commits intoapache:masterfrom
morrySnow:slot-thrift

Conversation

@morrySnow
Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Problem Summary:
The toThrift() methods on SlotDescriptor, TupleDescriptor, and DescriptorTable mix serialization logic with domain model classes. Following the same pattern as FunctionToThriftConverter, this PR extracts all three toThrift() methods into a new DescriptorToThriftConverter utility class, keeping the domain classes focused on their core responsibilities.

Changes:

  • Created DescriptorToThriftConverter as a final utility class with private constructor and 3 static toThrift overloads
  • Created DescriptorToThriftConverterTest with 17 unit tests covering all code paths
  • Updated all 11 call sites across 7 files to use DescriptorToThriftConverter.toThrift()
  • Removed toThrift() from SlotDescriptor, TupleDescriptor, and DescriptorTable
  • Added necessary getters: getMaterializedColumnName(), getThriftDescTable(), getTupleDescs()
  • Cleaned up unused imports (TSlotDescriptor, TTupleDescriptor, TableIf, Logger/LogManager)

Release note

None

Check List (For Author)

  • Test: Unit Test (DescriptorToThriftConverterTest with 17 test cases)
  • Behavior changed: No
  • Does this need documentation: No

…orToThriftConverter

### What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:
The toThrift() methods on SlotDescriptor, TupleDescriptor, and DescriptorTable
mix serialization logic with domain model classes. Following the same pattern as
FunctionToThriftConverter, this PR extracts all three toThrift() methods into a
new DescriptorToThriftConverter utility class, keeping the domain classes focused
on their core responsibilities.

### Release note

None

### Check List (For Author)

- Test: Unit Test (DescriptorToThriftConverterTest with 17 test cases)
- Behavior changed: No
- Does this need documentation: No

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@morrySnow
Copy link
Copy Markdown
Contributor Author

run buildall

@morrySnow
Copy link
Copy Markdown
Contributor Author

/review

@hello-stephen
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

1 finding:

  • fe/fe-core/src/main/java/org/apache/doris/analysis/DescriptorTable.java: getTupleDescs() is a new public accessor that returns the live tupleDescs.values() view. External callers can mutate it via remove()/clear() without updating slotDescs or the id generators, which can leave DescriptorTable internally inconsistent. Because the new converter lives in the same package, this helper should stay package-private or return an unmodifiable view.

Critical checkpoint conclusions:

  • Goal of task: Partially accomplished. The Thrift conversion logic was extracted and the visible call sites were migrated, but the refactor introduced the encapsulation regression above.
  • Small, clear, focused change: Not fully. The refactor widens DescriptorTable's public API unnecessarily.
  • Concurrency: Not applicable for the touched code; no new thread-safety issues were introduced.
  • Lifecycle/static initialization: No special lifecycle or static initialization issues found.
  • Configuration: No configuration changes.
  • Compatibility/incompatible change: No FE-BE protocol or storage compatibility change found.
  • Functionally parallel code paths: The call sites changed in this PR were updated consistently.
  • Special conditional checks: No new risky conditional logic was introduced.
  • Test coverage: Added unit tests cover the main Thrift conversion paths, but they do not protect against the new mutable API exposure.
  • Observability: Not applicable.
  • Transaction/persistence: Not applicable.
  • Data writes/modifications: Not applicable.
  • FE-BE variable passing: Not applicable.
  • Performance: No material performance regression found in the converter logic.
  • Other issues: No additional concrete correctness issues found beyond the public mutable accessor.

result.addToTableDescriptors(tbl.toThrift());
}
thriftDescTable = result;
return result;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

getTupleDescs() exposes a live tupleDescs.values() view as public API. That collection supports remove()/clear(), so external callers can now mutate DescriptorTable without updating slotDescs or the ID generators, leaving the object internally inconsistent. Since DescriptorToThriftConverter is in the same package, this helper can stay package-private, or it should at least return an unmodifiable view.

@hello-stephen
Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 88.52% (54/61) 🎉
Increment coverage report
Complete coverage report

… path types with Java equivalents

### What problem does this PR solve?

Issue Number: close #xxx

Related PR: apache#62312

Problem Summary:
1. Remove TDescriptorTable cache from DescriptorTable - the thriftDescTable field,
   getThriftDescTable(), and setThriftDescTable() are removed. DescriptorToThriftConverter
   now always regenerates the Thrift representation.

2. Create Java equivalent classes (ColumnAccessPath, ColumnAccessPathType) to replace
   Thrift types (TColumnAccessPath, TAccessPathType, TDataAccessPath, TMetaAccessPath)
   used directly in domain code. The Thrift types are now confined to
   DescriptorToThriftConverter, which handles the conversion.

   DataAccessPath and MetaAccessPath are merged into a single ColumnAccessPath class
   since both are structurally identical (List<String> path). Type discrimination is
   via the ColumnAccessPathType enum (DATA, META).

### Release note

None

### Check List (For Author)

- Test: Unit Test (DescriptorToThriftConverterTest - 22 tests)
- Behavior changed: No
- Does this need documentation: No

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@morrySnow
Copy link
Copy Markdown
Contributor Author

run buildall

@morrySnow
Copy link
Copy Markdown
Contributor Author

/review

@github-actions
Copy link
Copy Markdown
Contributor

No issues found in this review.

Critical checkpoints:

  • Goal and correctness: The PR cleanly extracts descriptor-to-Thrift serialization into DescriptorToThriftConverter, updates the FE call sites consistently, and preserves behavior based on the reviewed call chains.
  • Scope/minimality: The change stays focused on FE descriptor serialization and access-path type cleanup without unrelated logic changes.
  • Concurrency/lifecycle/config/compatibility: No new concurrency, lifecycle, config, persistence, or rolling-upgrade compatibility concerns were introduced.
  • Parallel paths: The relevant FE serialization paths and nested-column/variant access-path plumbing were updated consistently.
  • Conditional checks/observability: No new risky conditional branches or observability gaps stood out.
  • Testing: Added or updated FE unit tests cover the converter and nested/variant pruning paths. Local Maven validation in this runner was blocked because fe-core depends on the unpublished snapshot artifact org.apache.doris:fe-foundation:1.2-SNAPSHOT.

Residual risk: META access-path handling still appears dormant in the current pruning logic, so if that path is enabled later it should get dedicated behavioral tests.

@github-actions
Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions github-actions bot added approved Indicates a PR has been approved by one committer. reviewed labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@924060929 924060929 merged commit 795a4d0 into apache:master Apr 10, 2026
29 of 31 checks passed
zclllyybb pushed a commit to zclllyybb/doris that referenced this pull request Apr 10, 2026
…orToThriftConverter (apache#62312)

Problem Summary:
The `toThrift()` methods on `SlotDescriptor`, `TupleDescriptor`, and
`DescriptorTable` mix serialization logic with domain model classes.
Following the same pattern as `FunctionToThriftConverter`, this PR
extracts all three `toThrift()` methods into a new
`DescriptorToThriftConverter` utility class, keeping the domain classes
focused on their core responsibilities.

**Changes:**
- Created `DescriptorToThriftConverter` as a `final` utility class with
private constructor and 3 static `toThrift` overloads
- Created `DescriptorToThriftConverterTest` with 17 unit tests covering
all code paths
- Updated all 11 call sites across 7 files to use
`DescriptorToThriftConverter.toThrift()`
- Removed `toThrift()` from `SlotDescriptor`, `TupleDescriptor`, and
`DescriptorTable`
- Added necessary getters: `getMaterializedColumnName()`,
`getThriftDescTable()`, `getTupleDescs()`
- Cleaned up unused imports (`TSlotDescriptor`, `TTupleDescriptor`,
`TableIf`, `Logger/LogManager`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants