You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Wes McKinney (JIRA)" <ji...@apache.org> on 2017/03/12 18:57:04 UTC
[jira] [Commented] (ARROW-621) [C++] Implement an "inline visitor"
template that enables visitor-pattern-like code without virtual function
dispatch
[ https://issues.apache.org/jira/browse/ARROW-621?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15906646#comment-15906646 ]
Wes McKinney commented on ARROW-621:
------------------------------------
[~xhochy] I think this is a solution to your comment about DRY in visitor pattern -- since we could use {{std::enable_if}} when implementing certain Visit functions
> [C++] Implement an "inline visitor" template that enables visitor-pattern-like code without virtual function dispatch
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: ARROW-621
> URL: https://issues.apache.org/jira/browse/ARROW-621
> Project: Apache Arrow
> Issue Type: New Feature
> Components: C++
> Reporter: Wes McKinney
>
> For performance-sensitive dynamic dispatch, the current visitor pattern may be suboptimal due to having two virtual function dispatches per invocation. For example, we might have:
> {code}
> ArrayVisitor* visitor = ...;
> RETURN_NOT_OK(array->Accept(visitor));
> {code}
> For certain types of visitors, it may be possible to create a reusable pattern like:
> {code:language=c++}
> template <typename VISITOR>
> Status VisitArrayInline(const Array& array, VISITOR* visitor) {
> switch(array.type_id()) {
> case UINT8:
> return visitor->Visit(static_cast<const UInt8Array&>(array));
> ...
> default:
> break;
> }
> return Status::NotImplemented("Array type not implemented");
> }
> {code}
> It would be useful to have an understanding of how this design pattern realistically impacts performance in canonical Arrow use cases (e.g. IPC record batch loading / unloading).
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)