apache / apache/arrow

[C++][Decimal] Get rid of code duplication at Decimal

Open
#26,455 1 comment 0 reactions 0 assignees View on GitHub
Component: C++ Type: task
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

In classes related to Decimal types: [DecimalArray](https://github.com/apache/arrow/blob/9f13810d4407d1e2fd83a975c4eb281693e2ca9c/cpp/src/arrow/array/array_decimal.cc#L35), [DecimalBuilder](https://github.com/apache/arrow/blob/9f13810d4407d1e2fd83a975c4eb281693e2ca9c/cpp/src/arrow/array/builder_decimal.cc#L38), [DecimalType](https://github.com/apache/arrow/blob/9f13810d4407d1e2fd83a975c4eb281693e2ca9c/cpp/src/arrow/type.h#L879), etc, there is a lot of code duplications between decimals with different bit widths.

The proposal here is to create base classes for them, that will contain common logic for decimals of all bit widths.

These changes should simplify adding of new width decimals to C++ part.

**Reporter**: [Dmitry Chigarev](https://issues.apache.org/jira/browse/ARROW-10479)
#### Related issues:
- [[C++] Make Decimal representations consistent](https://github.com/apache/arrow/issues/29258) (is related to)
#### PRs and other links:
- [GitHub Pull Request #8578](https://github.com/apache/arrow/pull/8578)

**Note**: *This issue was originally created as [ARROW-10479](https://issues.apache.org/jira/browse/ARROW-10479). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*

Contributor guide

Open the contributing guide

Research direction

Start by comparing the DecimalArray and DecimalBuilder implementations in cpp/src/arrow/array/array_decimal.cc and builder_decimal.cc with DecimalType in cpp/src/arrow/type.h. Review the related consistency issue and PR for context before deciding the shared-class design. Done means common Decimal logic is centralized and adding another bit width requires less duplicated C++ code.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
data
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.