You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@arrow.apache.org by Neville Dipale <ne...@gmail.com> on 2019/01/07 12:09:34 UTC

[Rust] Creating Native Types from Rust Types (e.g. i32 -> ArrowNativeType)

I'm trying to find/create a way of converting primitive rust values in Rust
to their ArrowNativeType counterparts.
I'm trying to implement some array ops which need constant values, so I can
be able to multiply say a Int32Type by 3 to get a value.

Is there currently a way of doing this that I don't know of, or can I open
a JIRA for this?

Neville

Re: [Rust] Creating Native Types from Rust Types (e.g. i32 -> ArrowNativeType)

Posted by Neville Dipale <ne...@gmail.com>.
Looks like I need the below in datatypes.rs

impl From<i32> for Int32Type {
fn from(value: i32) -> Self {
value.into()
}
}

Adding that to the `make_type` macro seems to have solved my problem. I can
now implement things like `count`, `mean`, and a few more types of
calculations and aggregations on arrays.

On Mon, 7 Jan 2019 at 18:42, Neville Dipale <ne...@gmail.com> wrote:

> Thanks Andy,
>
> I'm aware of that, and have tried it with no success. What I am looking
> for might be similar to ScalarValue in DataFusion.
>
> If I create an array like Int32Array::from(vec![1]), and try to get the
> first value from this array, I get the primitive 1i32 instead of what I'm
> looking for.
>
> On Mon, 07 Jan 2019, 17:09 Andy Grove <andygrove73@gmail.com wrote:
>
>> It is possible to create an array of Arrow types from a vec of primitives
>> e.g. Int32Array::from(vec![1, 2, 3]) IIRC.
>>
>> Andy.
>>
>> On Mon, Jan 7, 2019 at 5:09 AM Neville Dipale <ne...@gmail.com>
>> wrote:
>>
>> > I'm trying to find/create a way of converting primitive rust values in
>> Rust
>> > to their ArrowNativeType counterparts.
>> > I'm trying to implement some array ops which need constant values, so I
>> can
>> > be able to multiply say a Int32Type by 3 to get a value.
>> >
>> > Is there currently a way of doing this that I don't know of, or can I
>> open
>> > a JIRA for this?
>> >
>> > Neville
>> >
>>
>

Re: [Rust] Creating Native Types from Rust Types (e.g. i32 -> ArrowNativeType)

Posted by Neville Dipale <ne...@gmail.com>.
Thanks Andy,

I'm aware of that, and have tried it with no success. What I am looking for
might be similar to ScalarValue in DataFusion.

If I create an array like Int32Array::from(vec![1]), and try to get the
first value from this array, I get the primitive 1i32 instead of what I'm
looking for.

On Mon, 07 Jan 2019, 17:09 Andy Grove <andygrove73@gmail.com wrote:

> It is possible to create an array of Arrow types from a vec of primitives
> e.g. Int32Array::from(vec![1, 2, 3]) IIRC.
>
> Andy.
>
> On Mon, Jan 7, 2019 at 5:09 AM Neville Dipale <ne...@gmail.com>
> wrote:
>
> > I'm trying to find/create a way of converting primitive rust values in
> Rust
> > to their ArrowNativeType counterparts.
> > I'm trying to implement some array ops which need constant values, so I
> can
> > be able to multiply say a Int32Type by 3 to get a value.
> >
> > Is there currently a way of doing this that I don't know of, or can I
> open
> > a JIRA for this?
> >
> > Neville
> >
>

Re: [Rust] Creating Native Types from Rust Types (e.g. i32 -> ArrowNativeType)

Posted by Andy Grove <an...@gmail.com>.
It is possible to create an array of Arrow types from a vec of primitives
e.g. Int32Array::from(vec![1, 2, 3]) IIRC.

Andy.

On Mon, Jan 7, 2019 at 5:09 AM Neville Dipale <ne...@gmail.com> wrote:

> I'm trying to find/create a way of converting primitive rust values in Rust
> to their ArrowNativeType counterparts.
> I'm trying to implement some array ops which need constant values, so I can
> be able to multiply say a Int32Type by 3 to get a value.
>
> Is there currently a way of doing this that I don't know of, or can I open
> a JIRA for this?
>
> Neville
>