-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
@kszucs @paddyhoran @andygrove could you review this? Thanks. |
There was a problem hiding this 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)] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😢
@sunchao I think this needs a re-base after merging ARROW-3855 @andygrove does the merge script automatically rebase before merging? |
The merge script rebases, yes |
rust/src/array.rs
Outdated
@@ -24,7 +24,7 @@ use std::sync::Arc; | |||
|
|||
use array_data::*; | |||
use buffer::*; |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Done.
There was a problem hiding this 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
rust/src/array.rs
Outdated
|
||
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Fixed.
rust/src/datatypes.rs
Outdated
type Native: ArrowNativeType; | ||
|
||
/// Returns the id of this primitive type. | ||
fn get_type_id() -> DataType; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this 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!
No description provided.