[C++] AppendScalar implementation uses polymorphism
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the enhancement requested
The `ArrayBuilder::AppendScalar` implementation is currently very odd:
* the `ArrayBuilder` hierarchy uses polymorphism (i.e. virtual methods) to handle type-specific operations
* but `ArrayBuilder::AppendScalar` is implemented entirely in the base class using a visitor, putting type-specific knowledge in the base class definition
* but `ArrayBuilder::AppendScalar` is *also* a virtual method overriden in dictionary and run-end-encoded builders
* furthermore, the visitor in the base class definition of `ArrayBuilder::AppendScalar` dispatched on the scalar's data type, instead of the builder's data type
We should refactor the `AppendScalar` implementation to be entirely polymorphic and remove any trace of type-specific implementations in the base class (`ArrayBuilder::AppendScalar` would probably become a pure virtual method).
This would also help in cases like https://github.com/apache/arrow/pull/50584
### Component(s)
C++
Contributor guide
Research direction
Start at ArrayBuilder::AppendScalar and trace the ArrayBuilder hierarchy, including the dictionary and run-end-encoded overrides mentioned in the issue. Confirm where scalar-type dispatch currently lives and identify the builder-specific entry points. Done means the base implementation contains no type-specific knowledge and each builder handles its own AppendScalar behavior polymorphically.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- data
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100