-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
SPARK-1663. Corrections for several compile errors in streaming code examples, and updates to follow API changes #589
Conversation
…d updates to follow API changes
Merged build triggered. |
Merged build started. |
While using these methods we have to specify the parameter type for the reduceFunc. |
Merged build finished. All automated tests passed. |
All automated tests passed. |
@@ -684,7 +694,7 @@ operation `reduceByKeyAndWindow`. | |||
|
|||
{% highlight scala %} | |||
// Reduce last 30 seconds of data, every 10 seconds | |||
val windowedWordCounts = pairs.reduceByKeyAndWindow(_ + _, Seconds(30), Seconds(10)) | |||
val windowedWordCounts = pairs.reduceByKeyAndWindow((a:Int,b:Int) => (a + b), Seconds(30), Seconds(10)) |
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.
Needs a space after the ,
- not a big deal I can fix on merge.
@srowen these are all great - thanks! I'm going to merge it. For the reduceByKeyAndWindow issue, I think that's just an oversight that occurred during the Java 8 re-factoring, and just needs to be changed to For the compile error, this is a sort of weird corner case with method overloading in Scala. I think you'll need to specify a type signature for the reduce function. |
…examples, and updates to follow API changes I gave the Streaming code examples, both Scala and Java, a test run today. I turned up a number of small errors, mostly compile errors in the Java examples. There were a few typos in the Scala too. I also took the liberty of adding things like imports, since in several cases they are not obvious. Feel free to push back on some changes. There's one thing I haven't quite addressed in the changes. `JavaPairDStream` uses the Java API version of `Function2` in almost all cases, as `JFunction2`. However it uses `scala.Function2` in: ``` def reduceByKeyAndWindow(reduceFunc: Function2[V, V, V], windowDuration: Duration) :JavaPairDStream[K, V] = { dstream.reduceByKeyAndWindow(reduceFunc, windowDuration) } ``` Is that a typo? Also, in Scala, I could not get this to compile: ``` val windowedWordCounts = pairs.reduceByKeyAndWindow(_ + _, Seconds(30), Seconds(10)) error: missing parameter type for expanded function ((x$1, x$2) => x$1.$plus(x$2)) ``` You can see my fix below but am I missing something? Otherwise I can say these all worked for me! Author: Sean Owen <[email protected]> Closes #589 from srowen/SPARK-1663 and squashes the following commits: 65a906b [Sean Owen] Corrections for several compile errors in streaming code examples, and updates to follow API changes (cherry picked from commit 11d5494) Signed-off-by: Patrick Wendell <[email protected]>
Sounds good @pwendell , thanks for merging with the comma fix. Should I open a separate issue for the |
SPARK-1076: Convert Int to Long to avoid overflow Patch for PR apache#578. Author: Xiangrui Meng <[email protected]> Closes apache#589 and squashes the following commits: 98c435e [Xiangrui Meng] cast Int to Long to avoid Int overflow
…examples, and updates to follow API changes I gave the Streaming code examples, both Scala and Java, a test run today. I turned up a number of small errors, mostly compile errors in the Java examples. There were a few typos in the Scala too. I also took the liberty of adding things like imports, since in several cases they are not obvious. Feel free to push back on some changes. There's one thing I haven't quite addressed in the changes. `JavaPairDStream` uses the Java API version of `Function2` in almost all cases, as `JFunction2`. However it uses `scala.Function2` in: ``` def reduceByKeyAndWindow(reduceFunc: Function2[V, V, V], windowDuration: Duration) :JavaPairDStream[K, V] = { dstream.reduceByKeyAndWindow(reduceFunc, windowDuration) } ``` Is that a typo? Also, in Scala, I could not get this to compile: ``` val windowedWordCounts = pairs.reduceByKeyAndWindow(_ + _, Seconds(30), Seconds(10)) error: missing parameter type for expanded function ((x$1, x$2) => x$1.$plus(x$2)) ``` You can see my fix below but am I missing something? Otherwise I can say these all worked for me! Author: Sean Owen <[email protected]> Closes apache#589 from srowen/SPARK-1663 and squashes the following commits: 65a906b [Sean Owen] Corrections for several compile errors in streaming code examples, and updates to follow API changes
SPARK-1076: Convert Int to Long to avoid overflow Patch for PR apache#578. Author: Xiangrui Meng <[email protected]> Closes apache#589 and squashes the following commits: 98c435e [Xiangrui Meng] cast Int to Long to avoid Int overflow
1. Change job metadata from aarch64 to arm64 2. Remove useless nodeset "ubuntu-bionic-vxh-arm64" Related-Bug: theopenlab/openlab#318
I gave the Streaming code examples, both Scala and Java, a test run today. I turned up a number of small errors, mostly compile errors in the Java examples. There were a few typos in the Scala too.
I also took the liberty of adding things like imports, since in several cases they are not obvious. Feel free to push back on some changes.
There's one thing I haven't quite addressed in the changes.
JavaPairDStream
uses the Java API version ofFunction2
in almost all cases, asJFunction2
. However it usesscala.Function2
in:Is that a typo?
Also, in Scala, I could not get this to compile:
You can see my fix below but am I missing something?
Otherwise I can say these all worked for me!