Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 7 commits into from

Conversation

sunchao
Copy link
Member

@sunchao sunchao commented Nov 26, 2018

No description provided.

@sunchao sunchao changed the title ARROW-3878: [Rust] Improve primitive types (WIP) ARROW-3878: [Rust] Improve primitive types Nov 26, 2018
.travis.yml Outdated Show resolved Hide resolved
rust/src/datatypes.rs Outdated Show resolved Hide resolved
@sunchao sunchao changed the title (WIP) ARROW-3878: [Rust] Improve primitive types ARROW-3878: [Rust] Improve primitive types Nov 28, 2018
@sunchao
Copy link
Member Author

sunchao commented Nov 28, 2018

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

Copy link
Member

@andygrove andygrove left a comment

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.

@@ -15,6 +15,8 @@
// specific language governing permissions and limitations
// under the License.

#![feature(specialization)]
Copy link
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
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
Contributor

Choose a reason for hiding this comment

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

😢

@paddyhoran
Copy link
Contributor

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

@andygrove does the merge script automatically rebase before merging?

@wesm
Copy link
Member

wesm commented Nov 29, 2018

The merge script rebases, yes

@@ -24,7 +24,7 @@ use std::sync::Arc;

use array_data::*;
use buffer::*;
Copy link
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
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.

Copy link
Contributor

@paddyhoran paddyhoran left a comment

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


fn data_ref(&self) -> &ArrayDataRef {
&self.data
}
}

/// 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
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
Member Author

Choose a reason for hiding this comment

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

Done.

pub type Float32BufferBuilder = BufferBuilder<Float32Type>;
pub type Float64BufferBuilder = BufferBuilder<Float64Type>;

pub trait BufferBuilderTrait<T: ArrowPrimitiveType> {
Copy link
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
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.

type Native: ArrowNativeType;

/// Returns the id of this primitive type.
fn get_type_id() -> DataType;
Copy link
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
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@paddyhoran paddyhoran left a comment

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.

None yet

6 participants