Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

zhengruifeng
Copy link
Contributor

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

@SparkQA
Copy link

SparkQA commented Mar 17, 2016

Test build #53399 has finished for PR 11776 at commit ff56ff5.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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

@SparkQA
Copy link

SparkQA commented Mar 17, 2016

Test build #53405 has finished for PR 11776 at commit 7750299.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.


import org.apache.spark.Accumulator;
// $example on$
import org.apache.spark.api.java.function.VoidFunction;
Copy link
Contributor

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$?

Copy link
Contributor Author

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.

@SparkQA
Copy link

SparkQA commented Mar 17, 2016

Test build #53409 has finished for PR 11776 at commit f251229.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@MLnick
Copy link
Contributor

MLnick commented Mar 17, 2016

Merged to master. Thanks!

@asfgit asfgit closed this in 204c9de Mar 17, 2016
@zhengruifeng zhengruifeng deleted the streaming_je branch March 17, 2016 09:15

long cntSignificant = rdd.filter(new Function<StreamingTestResult, Boolean>() {
@Override
public Boolean call(StreamingTestResult v) throws Exception {
Copy link
Member

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.

Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

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

@zhengruifeng
Copy link
Contributor Author

@MLnick @srowen What should I do to refine the PR?

@MLnick
Copy link
Contributor

MLnick commented Mar 18, 2016

I think you can actually just make that variable a static int outside the
main definition, and -= it in the foreachRDD block. Similar to Scala.

I tested it and it works - no need even for an atomicinteger.
On Fri, 18 Mar 2016 at 03:33, Ruifeng Zheng [email protected]
wrote:

@MLnick https://github.com/MLnick @srowen https://github.com/srowen
What should I do to refine the PR?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#11776 (comment)

@zhengruifeng
Copy link
Contributor Author

@MLnick How can I fix it in this PR? Or I have to open another one?

@MLnick
Copy link
Contributor

MLnick commented Mar 18, 2016

You'll need to open another one I'm afraid.

On Fri, 18 Mar 2016 at 12:50 Ruifeng Zheng [email protected] wrote:

@MLnick https://github.com/MLnick How can I fix it in this PR? Or I
have to open another one?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#11776 (comment)

@zhengruifeng
Copy link
Contributor Author

@MLnick ok I will open another pr.

asfgit pushed a commit that referenced this pull request Mar 18, 2016
## 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.
roygao94 pushed a commit to roygao94/spark that referenced this pull request Mar 22, 2016
## 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.
roygao94 pushed a commit to roygao94/spark that referenced this pull request Mar 22, 2016
## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants