arrow-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wes McKinney (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (ARROW-621) [C++] Implement an "inline visitor" template that enables visitor-pattern-like code without virtual function dispatch
Date Sun, 12 Mar 2017 18:54:04 GMT

     [ https://issues.apache.org/jira/browse/ARROW-621?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Wes McKinney updated ARROW-621:
-------------------------------
    Description: 
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).

  was:
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).


> [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)

Mime
View raw message