-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-3446] Expose underlying job ids in FutureAction. #2337
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark | ||
|
|
||
| import scala.concurrent.Await | ||
| import scala.concurrent.duration.Duration | ||
|
|
||
| import org.scalatest.{BeforeAndAfter, FunSuite, Matchers} | ||
|
|
||
| import org.apache.spark.SparkContext._ | ||
|
|
||
| class FutureActionSuite extends FunSuite with BeforeAndAfter with Matchers with LocalSparkContext { | ||
|
|
||
| before { | ||
| sc = new SparkContext("local", "FutureActionSuite") | ||
|
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. can you add a test here for the case when multiple job id's are used?
Contributor
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. Isn't that the test on L41 ("complex async action")?
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. ah got it, my bad. |
||
| } | ||
|
|
||
| test("simple async action") { | ||
| val rdd = sc.parallelize(1 to 10, 2) | ||
| val job = rdd.countAsync() | ||
| val res = Await.result(job, Duration.Inf) | ||
| res should be (10) | ||
| job.jobIds.size should be (1) | ||
| } | ||
|
|
||
| test("complex async action") { | ||
| val rdd = sc.parallelize(1 to 15, 3) | ||
| val job = rdd.takeAsync(10) | ||
| val res = Await.result(job, Duration.Inf) | ||
| res should be (1 to 10) | ||
| job.jobIds.size should be (2) | ||
| } | ||
|
|
||
| } | ||
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.
Just wondering - any reason to make this a
varinstead of avalListBuffer? And then we could return an immutableSeqin jobIds?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'm trying to avoid synchonization. Having a mutable list here means I'd have to synchronize when returning the immutable Seq in
jobIds; with the volatile var, I'm only doing read operations on theSeqs themselves, so I don't need to synchronize.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.
cool, makes sense