[
https://issues.apache.org/jira/browse/FLINK-15538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17012394#comment-17012394
]
Liya Fan commented on FLINK-15538:
----------------------------------
[~ykt836] Good point.
Admittedly, a virtual function or a branch statement, it is hard to say which
is more expensive in general. It depends on some environmental factors and JIT
behaviors.
Some results [1] suggest that the performance of bimorphic virtual function (a
virtual function with two possible implementations) calls is not too much worse
than a final function call, and much better than the performance of a general
(megamorphic) virtual function call.
Another benefit is that the subclasses do not contain irrelavent data fields
(e.g. LooseDecimal does not hold the long value).
[1]
http://insightfullogic.com/2014/May/12/fast-and-megamorphic-what-influences-method-invoca/
> Separate decimal implementations into separate sub-classes
> ----------------------------------------------------------
>
> Key: FLINK-15538
> URL: https://issues.apache.org/jira/browse/FLINK-15538
> Project: Flink
> Issue Type: Improvement
> Components: Table SQL / Runtime
> Reporter: Liya Fan
> Priority: Major
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The current implementation of Decimal values have two (somewhat independent)
> implementations: one is based on Long, while the other is based on
> BigDecimal.
> This makes the Decmial class not clear (both implementations cluttered in a
> single class) and less efficient (each method involves a if-else branch).
> So in this issue, we make Decimal an abstract class, and separate the two
> implementation into two sub-classes. This makes the code clearer and more
> efficient.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)