[
https://issues.apache.org/jira/browse/ARROW-229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16138635#comment-16138635
]
Ankit Aggarwal edited comment on ARROW-229 at 8/23/17 4:57 PM:
---------------------------------------------------------------
Scope: To define safe casts functions for the each type (arrow::Type). For
example - TIME32 to TIME64, Union Array to Dictionary Array
A possible implementation of how it can be done:
Tag dispatching and calling the SetData function for the required type
(arrow::Array) if it is array type or reinterpret_cast for the numerical type
and assigning it to the output pointer.
{code:java}
Status SafeCast(const Array& input, const std::shared_ptr<DataType>&
target_type,
MemoryPool* pool,
std::shared_ptr<Array>* out);
{code}
In the API suggested why do we need the MemoryPool pointer?
Do we need to check whether the SafeCast is possible or not?
was (Author: ankit5012):
Scope: To define safe casts functions for the each type (arrow::Type). For
example - TIME32 to TIME64, Union Array to Dictionary Array
A possible implementation of how it can be done:
Tag dispatching and calling the SetData function for the target_type and
assigning it to the output pointer.
{code:java}
Status SafeCast(const Array& input, const std::shared_ptr<DataType>&
target_type,
MemoryPool* pool,
std::shared_ptr<Array>* out);
{code}
In the API suggested why do we need the MemoryPool pointer?
Do we need to check whether the SafeCast is possible or not?
> [C++] Implement safe casts for primitive types
> ----------------------------------------------
>
> Key: ARROW-229
> URL: https://issues.apache.org/jira/browse/ARROW-229
> Project: Apache Arrow
> Issue Type: New Feature
> Components: C++
> Reporter: Uwe L. Korn
> Fix For: 0.7.0
>
>
> In some situations, you want to cast the data in a PrimitiveArray to a
> different (but similar) data type, e.g. from {{uint32_t}} to {{int32_t}} or
> {{uint32_t}} to {{uint8_t}}. This can either be done by reinterpreting the
> data or needs to involve a copy if the size of the underlying type changes.
> There is already an implementation for this in {{parquet-cpp}} that could be
> pulled out into Arrow:
> https://github.com/apache/parquet-cpp/blob/9a0407e684c0a6299d0e6ab98c11c1162915c0ee/src/parquet/arrow/writer.cc#L71
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)