-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
[Minor][DOC] Add JavaStreamingTestExample #11776
Conversation
Test build #53399 has finished for PR 11776 at commit
|
import org.apache.spark.api.java.function.VoidFunction; | ||
import org.apache.spark.api.java.JavaRDD; | ||
import org.apache.spark.api.java.function.Function; | ||
import org.apache.spark.mllib.stat.test.BinarySample; |
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.
Please add // $example on$
and // $example off$
for the required imports.
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.
@MLnick OK, I add required imports according to your comments
Test build #53405 has finished for PR 11776 at commit
|
|
||
import org.apache.spark.Accumulator; | ||
// $example on$ | ||
import org.apache.spark.api.java.function.VoidFunction; |
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.
Don't think this import is actually required, as that code is after the final $example off$
?
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.
@MLnick Thinks, I will remove it.
Test build #53409 has finished for PR 11776 at commit
|
Merged to master. Thanks! |
|
||
long cntSignificant = rdd.filter(new Function<StreamingTestResult, Boolean>() { | ||
@Override | ||
public Boolean call(StreamingTestResult v) throws Exception { |
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.
There are some minor style sub-optimalities here, like some indentation issues, unneeded "throws Exception", and some variances from the Scala example. No big deal but this could have been left open more than a couple hours to get some eyes on it.
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.
Sorry Sean - I admit I made a fairly quick pass. What variances from the Scala example do you see?
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.
Ex: I see why this call doesn't use "fold" but could have been !rdd.filter(...).isEmpty
; you don't need an arg to createTempDir
; timeoutCounter
actually shouldn't be an accumulator here. The only one that isn't trivial is the last one.
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.
Utils.createTempDir
uses default args so args are required in Java.
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.
Ah right, scratch that one. The only thing that might be an issue here is counting with the accumulator. It's all actually local, so, I'm guessing it works OK anyway. It could be an AtomicInteger or anything that can be decremented and referred to inside the function, which will only ever run on the driver.
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.
Fair enough - if one tries to just use a local var similar to the Scala example it won't compile as it needs a final var, maybe this was the workaround. Agreed AtomicInteger is cleaner. Happy to clean that up
I think you can actually just make that variable a static int outside the I tested it and it works - no need even for an atomicinteger.
|
@MLnick How can I fix it in this PR? Or I have to open another one? |
You'll need to open another one I'm afraid. On Fri, 18 Mar 2016 at 12:50 Ruifeng Zheng [email protected] wrote:
|
@MLnick ok I will open another pr. |
## What changes were proposed in this pull request? Fix some nits discussed in #11776 (comment) use !rdd.isEmpty instead of rdd.count > 0 use static instead of AtomicInteger remove unneeded "throws Exception" ## How was this patch tested? manual tests Author: Zheng RuiFeng <[email protected]> Closes #11821 from zhengruifeng/je_fix.
## What changes were proposed in this pull request? Add the java example of StreamingTest ## How was this patch tested? manual tests in CLI: bin/run-example mllib.JavaStreamingTestExample dataDir 5 100 Author: Zheng RuiFeng <[email protected]> Closes apache#11776 from zhengruifeng/streaming_je.
## What changes were proposed in this pull request? Fix some nits discussed in apache#11776 (comment) use !rdd.isEmpty instead of rdd.count > 0 use static instead of AtomicInteger remove unneeded "throws Exception" ## How was this patch tested? manual tests Author: Zheng RuiFeng <[email protected]> Closes apache#11821 from zhengruifeng/je_fix.
What changes were proposed in this pull request?
Add the java example of StreamingTest
How was this patch tested?
manual tests in CLI: bin/run-example mllib.JavaStreamingTestExample dataDir 5 100