ARROW-2384: [Rust] Additional test & Trait standardization#1818
ARROW-2384: [Rust] Additional test & Trait standardization#1818max-sixty wants to merge 16 commits intoapache:masterfrom
Conversation
|
LGTM |
|
I've never used Rust but I can provide non-technical guidance. |
sadikovi
left a comment
There was a problem hiding this comment.
Thanks a lot for making the change! I just left some optional minor comments that could improve readability.
rust/src/datatypes.rs
Outdated
|
|
||
| impl Field { | ||
|
|
||
There was a problem hiding this comment.
Can you remove this whitespace?
There was a problem hiding this comment.
Shall we rustfmt the whole thing?
There was a problem hiding this comment.
I don’t know, I am not very familiar with how Rust project is set up for Arrow:). It might be easier to fix manually, if you want to.
There was a problem hiding this comment.
@andygrove OK with you to run rustfmt on all the files?
There was a problem hiding this comment.
👍 to rustfmt-ing everything. Makes it much easier for new contributers.
rust/src/datatypes.rs
Outdated
| let s : Vec<String> = self.columns.iter() | ||
| impl fmt::Display for Schema { | ||
| fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
| let s: Vec<String> = self.columns |
There was a problem hiding this comment.
Very minor, but you could consider using write!, like you added, e.g.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for (i, col) in self.columns.iter().enumerate() {
write!(f, "{}", col)?;
if i < self.columns.len() - 1 {
write!(f, ", ")?;
}
}
Ok(())
}There was a problem hiding this comment.
OK great, thanks for the pointer, I'll make that change.
Why do we need the ? at the end of the lines there?
There was a problem hiding this comment.
? is a special shortcut token that is basically unrolled into something like this:
match write!(f, "...") {
Ok(...) => // do something,
Err(...) => // return err immediately,
}You would see it very often in the code, it is quite handy for unwrap Result with very minimum amount of code.
rust/src/datatypes.rs
Outdated
| .map(|c| c.to_string()) | ||
| .collect(); | ||
| s.join(",") | ||
| write!(f, "{}", s.join(",")) |
There was a problem hiding this comment.
Would you like to keep a whitespace after comma? IMHO, it makes it easier to read the schema.
There was a problem hiding this comment.
I agree, but is there a standard? Ideally we'd test against that
There was a problem hiding this comment.
Good question! I actually do not know, and asked similar question down in the comments thread.
| Field::new("street", DataType::Utf8, false), | ||
| Field::new("zip", DataType::UInt16, false), | ||
| ]), false), | ||
| Field::new("street", DataType::Utf8, false), |
There was a problem hiding this comment.
I think the shift might have been accidental here:)
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| use std::fmt; |
There was a problem hiding this comment.
nit: I think, based on other source files, we keep a new line after the license header.
|
@wesm @andygrove Is there a standard way of printing schema like in Parquet (with message type)? |
|
Side note: if you choose to use an automatic formatter on Rust code, you should probably add a lint step to the CI setup. |
I don't think a "standard" is mandated, but see For the specific question in the comments, adding a space after commas is good typographical practice. |
|
I created a JIRA for setting up rustfmt:
https://issues.apache.org/jira/browse/ARROW-2378
…On Mon, Apr 2, 2018 at 5:25 AM, Antoine Pitrou ***@***.***> wrote:
Is there a standard way of printing schema like in Parquet (with message
type)?
I don't think a "standard" is mandated, but see arrow::PrettyPrint and
also pretty_print-test.cc in the C++ codebase. You may want to reproduce
something similar.
For the specific question in the comments, adding a space after commas is
good typographical practice.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1818 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA5AxNbSOYa5lfa19SyOOUp1LkzyeOBbks5tkgqQgaJpZM4TCvPW>
.
|
|
@andygrove should I |
|
@pitrou I mean more helping with PR workflow. This PR has an unclear title and does not reference any JIRA. At some point, someone will need to merge the patch and make sure the JIRA metadata is correct (fix version, assignee, component) |
|
@wesm Yes, I can. Probably not going to have time to learn Rust but taking care of titles, consensus in PR comments & co is manageable. |
As discussed in #1818 Probably worth merging fairly soon to minimize conflicts. I'll iterate quickly on any feedback. Author: Maximilian Roos <m@maxroos.com> Closes #1825 from maxim-lian/rustfmt and squashes the following commits: bfeeb54 <Maximilian Roos> rustfmt-preview fe7c228 <Maximilian Roos> move cargo fmt to rust script e224515 <Maximilian Roos> hanging space 2c6375b <Maximilian Roos> travis lint 8a6f223 <Maximilian Roos> cargo fmt
|
Needs to be rebased on master after the rustfmt and other patches were merged. |
| .iter() | ||
| .map(|c| c.to_string()) | ||
| .collect::<Vec<String>>() | ||
| .join(", ")) |
There was a problem hiding this comment.
@sadikovi what do you think of this? I will revert to your suggestion if you prefer. This feels nicer from a functional POV (but I'm only starting rust)
There was a problem hiding this comment.
Looks good, I suggest you keep your version.
rust/src/buffer.rs
Outdated
| } | ||
| } | ||
|
|
||
| impl<T> Drop for Buffer<T> { |
There was a problem hiding this comment.
master doesn't compile because this is also at https://github.com/apache/arrow/pull/1818/files/5449cc074163ec160e366ad5be84422cfdea7ccb#diff-efb40dbeb7a3acab561ac659c2cfee74R67
There was a problem hiding this comment.
@maxim-lian Would you be able to fix this in a PR?
There was a problem hiding this comment.
Yes - this the fix!
|
Gentle ping @sadikovi |
sadikovi
left a comment
There was a problem hiding this comment.
Looks good. Great to see formatted code! Thanks for making all the changes!
| .iter() | ||
| .map(|c| c.to_string()) | ||
| .collect::<Vec<String>>() | ||
| .join(", ")) |
There was a problem hiding this comment.
Looks good, I suggest you keep your version.
|
@maxim-lian I think there are some rebase artifacts in here due to merges to master. Can you rebase again? |
|
@xhochy updated! |
A test for the string representation of a Schema.
& some standardization on
Traits rather than their method...but mainly getting my feet wet with rust & arrow