-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-5931][CORE] Use consistent naming for time properties #5236
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
Changes from 1 commit
59bf9e1
404f8c3
7db6d2a
4933fda
c9f5cad
21ef3dd
064ebd6
7320c87
272c215
3352d34
3f1cfc8
6d1518e
2fcc91c
5181597
c6a0095
cde9bff
42477aa
9a29d8d
34f87c2
8f741e1
9e2547c
499bdf0
5232a36
3a12dd8
68f4e93
70ac213
647b5ac
1c0c07c
8613631
bac9edf
1858197
3b126e1
39164f9
b2fc965
dd0a680
bf779b0
76cfa27
5193d5f
6387772
19c31af
ff40bfe
28187bf
1465390
cbf41db
d4efd26
4e48679
1a1122c
cbd2ca6
6f651a8
7d19cdd
dc7bd08
69fedcc
8927e66
642a06d
25d3f52
bc04e05
951ca2d
f5fafcd
de3bff9
4526c81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,14 +150,16 @@ private static long parseTimeString(String str, TimeUnit unit) { | |
| Matcher m = Pattern.compile("([0-9]+)([a-z]+)?").matcher(lower); | ||
| if (m.matches()) { | ||
| val = Long.parseLong(m.group(1)); | ||
| if(m.groupCount() > 1) { | ||
| if (m.group(2) != null) { | ||
| suffix = m.group(2); | ||
| } | ||
| } else { | ||
| throw new NumberFormatException("Failed to parse time string."); | ||
| else { | ||
| throw new NumberFormatException("Failed to parse time string: " + str); | ||
| } | ||
| } | ||
|
|
||
| return unit.convert(val, timeSuffixes.containsKey(suffix) ? timeSuffixes.get(suffix) : unit); | ||
| return unit.convert(val, (suffix != null) && timeSuffixes.containsKey(suffix) ? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will use the The unit tests don't catch this because all the invalid suffixes have spaces in them, so the regex doesn't match.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Marcelo - great catch! I've added a test case for this and fixed it in the latest commit. Sent with Good (www.good.com) -----Original Message----- In network/common/src/main/java/org/apache/spark/network/util/JavaUtils.javahttps://github.com//pull/5236#discussion_r28033893:
This will use the unit parameter for any suffix that is not in timeSuffixes. The containsKey check should be separate and an exception should be thrown if the suffix is not there. The unit tests don't catch this because all the invalid suffixes have spaces in them, so the regex doesn't match. — The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer. |
||
| timeSuffixes.get(suffix) : unit); | ||
| } catch (NumberFormatException e) { | ||
| String timeError = "Time must be specified as seconds (s), " + | ||
| "milliseconds (ms), microseconds (us), minutes (m or min) hour (h), or day (d). " + | ||
|
|
||
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 whole method is really dense. Should we do something like the following instead so it's easier to follow:
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.
Ugh, that was much longer than expected. It would have been a lot more concise in Scala without sacrificing any readability
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.
Using regexes this would be pretty short.
Or something along those lines.
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.
yeah, do that!