Skip to content

ARROW-3878: [Rust] Improve primitive types#3031

Closed
sunchao wants to merge 7 commits into
apache:masterfrom
sunchao:types
Closed

ARROW-3878: [Rust] Improve primitive types#3031
sunchao wants to merge 7 commits into
apache:masterfrom
sunchao:types

Conversation

@sunchao

@sunchao sunchao commented Nov 26, 2018

Copy link
Copy Markdown
Member

No description provided.

@sunchao sunchao changed the title ARROW-3878: [Rust] Improve primitive types (WIP) ARROW-3878: [Rust] Improve primitive types Nov 26, 2018
Comment thread .travis.yml Outdated
Comment thread rust/src/datatypes.rs Outdated
Comment thread rust/examples/dynamic_types.rs Outdated
@sunchao sunchao changed the title (WIP) ARROW-3878: [Rust] Improve primitive types ARROW-3878: [Rust] Improve primitive types Nov 28, 2018
@sunchao

sunchao commented Nov 28, 2018

Copy link
Copy Markdown
Member Author

@kszucs @paddyhoran @andygrove could you review this? Thanks.

@andygrove andygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - I like having the specific numeric type trait.

Comment thread rust/src/lib.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain how we are now using the specialization feature?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used in BufferBuilder where we defined a trait BufferBuilderTrait (I'm not too happy with this name..) and implemented this separately for BufferBuilder<T: ArrowNumericType> and BufferBuilder<BooleanType>. Without this, we'd have to implement PrimitiveArrayBuilder separately for ArrowNumericType and BooleanType, with the same code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢

@paddyhoran

Copy link
Copy Markdown
Contributor

@sunchao I think this needs a re-base after merging ARROW-3855

@andygrove does the merge script automatically rebase before merging?

@wesm

wesm commented Nov 29, 2018

Copy link
Copy Markdown
Member

The merge script rebases, yes

Comment thread rust/src/array.rs Outdated
@@ -24,7 +24,7 @@ use std::sync::Arc;

use array_data::*;
use buffer::*;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I there is a need to use the use <module>::* pattern for builder and datatypes (and array) because they define a lot of types, but maybe we should avoid this for array_data and buffer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Done.

@paddyhoran paddyhoran left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I am loving this update. The macros were making it very hard to build higher level types. Just a couple of nits.

Thanks @sunchao

Comment thread rust/src/array.rs Outdated
}

/// Macro to define primitive arrays for different data types and native types.
/// Boolean arrays are bit-packed and so are not defined by this macro

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments need to be updated here as the macro is gone.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread rust/src/builder.rs
pub type Float32BufferBuilder = BufferBuilder<Float32Type>;
pub type Float64BufferBuilder = BufferBuilder<Float64Type>;

pub trait BufferBuilderTrait<T: ArrowPrimitiveType> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs need to be updated for BufferBuilderTrait in general. Also, is there a way to avoid anonymous function parameters as these are deprecated, see RFC-1685

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Fixed.

Comment thread rust/src/datatypes.rs Outdated
type Native: ArrowNativeType;

/// Returns the id of this primitive type.
fn get_type_id() -> DataType;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think type_id is the term used in the C++ impl, but we have used data_type. Should we stick with data_type everywhere or convert to use type_id everywhere?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@paddyhoran paddyhoran left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @sunchao this is a great improvement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants