-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-12158] [SparkR] [SQL] Fix 'sample' functions that break R unit test cases #10160
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ec77010
add sample functions with seeds
gatorsmile 2ab89e8
combine two variants
gatorsmile 34d0118
added a test case
gatorsmile 4337c35
simplified the impl of sample_frac
gatorsmile a78109e
simplified the impl of sample_frac.
gatorsmile ad3ea31
Merge remote-tracking branch 'upstream/master' into sampleR
gatorsmile 493b368
added a new parm into the comment
gatorsmile File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
simplified the impl of sample_frac
- Loading branch information
commit 4337c35e03f8d70a6346e43888eaf3b6ba341722
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -682,6 +682,8 @@ setMethod("sample", | |
| function(x, withReplacement, fraction, seed) { | ||
| if (fraction < 0.0) stop(cat("Negative fraction value:", fraction)) | ||
| if (!missing(seed)) { | ||
| # TODO : Figure out how to send integer as java.lang.Long to JVM so | ||
| # we can send seed as an argument through callJMethod | ||
| sdf <- callJMethod(x@sdf, "sample", withReplacement, fraction, as.integer(seed)) | ||
| } else { | ||
| sdf <- callJMethod(x@sdf, "sample", withReplacement, fraction) | ||
|
|
@@ -695,11 +697,7 @@ setMethod("sample_frac", | |
| signature(x = "DataFrame", withReplacement = "logical", | ||
| fraction = "numeric"), | ||
| function(x, withReplacement, fraction, seed) { | ||
| if (!missing(seed)) { | ||
| sample(x, withReplacement, fraction, as.integer(seed)) | ||
|
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. 2 space ident. directly pass seed is ok instead of as.integer(seed)?
Member
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. Yeah, done! This is my first time to read and write R. : ) Thank you! |
||
| } else { | ||
| sample(x, withReplacement, fraction) | ||
| } | ||
| }) | ||
|
|
||
| #' nrow | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@felixcheung Shouldn't we document this param in the roxygen doc above ? Otherwise how would anybody know we support a
seed?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.
yes we should add a
@param seedabove, thanks for catching it