-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-7863][Core] Create SimpleDateFormat for every SimpleDateParam instance because it's not thread-safe #6406
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
Conversation
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 wouldn't bother with ThreadLocal. Just make new objects on demand. These aren't expensive.
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 just feel using ThreadLocal is easy and minimizes the changes.
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.
It also means you keep per-thread state lying around. I know, it's not big, but I don't think it's worth it.
|
Test build #33511 has finished for PR 6406 at commit
|
|
Test build #33509 timed out for PR 6406 at commit |
…s not thread-safe
|
@srowen updated as per your suggestion |
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.
Now this is a field though. There's no need for that. The format objects can be created on demand to parse the input. If this SimpleDateParam object is short-lived I suppose it does not matter much but I would have just inlined all this.
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.
Inlined formats.
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.
OK... but this seems like a very complicated way of saying, "parse with one format, and if it fails, parse with the other. Why not just boil this down while we're here? you can even avoid allocating at least one of the two objects in most cases.
|
Test build #33517 has finished for PR 6406 at commit
|
|
Test build #33518 has finished for PR 6406 at commit
|
|
Test build #33521 has finished for PR 6406 at commit
|
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.
why not just make this a def makeFormats or something and add a comment explaining why it needs to be a def? It would be good to not inline it because the old code is more readable.
|
Rewrote SimpleDateParam to avoid parsing twice |
|
Test build #33547 has finished for PR 6406 at commit
|
|
retest this please |
|
Test build #33551 has finished for PR 6406 at commit
|
|
This LGTM. |
… instance because it's not thread-safe SimpleDateFormat is not thread-safe. This PR creates new `SimpleDateFormat` for each `SimpleDateParam` instance. Author: zsxwing <zsxwing@gmail.com> Closes apache#6406 from zsxwing/SPARK-7863 and squashes the following commits: aeed4c1 [zsxwing] Rewrite SimpleDateParam 8cdd986 [zsxwing] Inline formats 9680a15 [zsxwing] Create SimpleDateFormat for each SimpleDateParam instance because it's not thread-safe
… instance because it's not thread-safe SimpleDateFormat is not thread-safe. This PR creates new `SimpleDateFormat` for each `SimpleDateParam` instance. Author: zsxwing <zsxwing@gmail.com> Closes apache#6406 from zsxwing/SPARK-7863 and squashes the following commits: aeed4c1 [zsxwing] Rewrite SimpleDateParam 8cdd986 [zsxwing] Inline formats 9680a15 [zsxwing] Create SimpleDateFormat for each SimpleDateParam instance because it's not thread-safe
SimpleDateFormat is not thread-safe. This PR creates new
SimpleDateFormatfor eachSimpleDateParaminstance.