Skip to content

Commit 6779bd9

Browse files
committed
Merge remote-tracking branch 'apache-github/master' into SPARK-14997
2 parents f1b793a + 0fd3a47 commit 6779bd9

File tree

252 files changed

+6018
-3351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

252 files changed

+6018
-3351
lines changed

R/pkg/inst/tests/testthat/test_client.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test_that("no package specified doesn't add packages flag", {
3232
})
3333

3434
test_that("multiple packages don't produce a warning", {
35-
expect_that(generateSparkSubmitArgs("", "", "", "", c("A", "B")), not(gives_warning()))
35+
expect_warning(generateSparkSubmitArgs("", "", "", "", c("A", "B")), NA)
3636
})
3737

3838
test_that("sparkJars sparkPackages as character vectors", {

R/pkg/inst/tests/testthat/test_context.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ test_that("sparkJars sparkPackages as comma-separated strings", {
138138

139139
# check normalizePath
140140
f <- dir()[[1]]
141-
expect_that(processSparkJars(f), not(gives_warning()))
141+
expect_warning(processSparkJars(f), NA)
142142
expect_match(processSparkJars(f), f)
143143
})
144144

R/pkg/inst/tests/testthat/test_mllib.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,9 @@ test_that("spark.survreg", {
450450
if (requireNamespace("survival", quietly = TRUE)) {
451451
rData <- list(time = c(4, 3, 1, 1, 2, 2, 3), status = c(1, 1, 1, 0, 1, 1, 0),
452452
x = c(0, 2, 1, 1, 1, 0, 0), sex = c(0, 0, 0, 0, 1, 1, 1))
453-
expect_that(
453+
expect_error(
454454
model <- survival::survreg(formula = survival::Surv(time, status) ~ x + sex, data = rData),
455-
not(throws_error()))
455+
NA)
456456
expect_equal(predict(model, rData)[[1]], 3.724591, tolerance = 1e-4)
457457
}
458458
})

R/pkg/inst/tests/testthat/test_sparkSQL.R

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,9 +1196,9 @@ test_that("date functions on a DataFrame", {
11961196
c(as.POSIXlt("2012-12-13 21:34:00 UTC"), as.POSIXlt("2014-12-15 10:24:34 UTC")))
11971197
expect_equal(collect(select(df2, to_utc_timestamp(df2$b, "JST")))[, 1],
11981198
c(as.POSIXlt("2012-12-13 03:34:00 UTC"), as.POSIXlt("2014-12-14 16:24:34 UTC")))
1199-
expect_more_than(collect(select(df2, unix_timestamp()))[1, 1], 0)
1200-
expect_more_than(collect(select(df2, unix_timestamp(df2$b)))[1, 1], 0)
1201-
expect_more_than(collect(select(df2, unix_timestamp(lit("2015-01-01"), "yyyy-MM-dd")))[1, 1], 0)
1199+
expect_gt(collect(select(df2, unix_timestamp()))[1, 1], 0)
1200+
expect_gt(collect(select(df2, unix_timestamp(df2$b)))[1, 1], 0)
1201+
expect_gt(collect(select(df2, unix_timestamp(lit("2015-01-01"), "yyyy-MM-dd")))[1, 1], 0)
12021202

12031203
l3 <- list(list(a = 1000), list(a = -1000))
12041204
df3 <- createDataFrame(sqlContext, l3)
@@ -1502,15 +1502,14 @@ test_that("toJSON() returns an RDD of the correct values", {
15021502

15031503
test_that("showDF()", {
15041504
df <- read.json(sqlContext, jsonPath)
1505-
s <- capture.output(showDF(df))
15061505
expected <- paste("+----+-------+\n",
15071506
"| age| name|\n",
15081507
"+----+-------+\n",
15091508
"|null|Michael|\n",
15101509
"| 30| Andy|\n",
15111510
"| 19| Justin|\n",
15121511
"+----+-------+\n", sep = "")
1513-
expect_output(s, expected)
1512+
expect_output(showDF(df), expected)
15141513
})
15151514

15161515
test_that("isLocal()", {
@@ -1896,7 +1895,7 @@ test_that("Method as.data.frame as a synonym for collect()", {
18961895
expect_equal(as.data.frame(irisDF2), collect(irisDF2))
18971896

18981897
# Make sure as.data.frame in the R base package is not covered
1899-
expect_that(as.data.frame(c(1, 2)), not(throws_error()))
1898+
expect_error(as.data.frame(c(1, 2)), NA)
19001899
})
19011900

19021901
test_that("attach() on a DataFrame", {

core/src/main/java/org/apache/spark/util/collection/unsafe/sort/RecordPointerAndKeyPrefix.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package org.apache.spark.util.collection.unsafe.sort;
1919

20-
final class RecordPointerAndKeyPrefix {
20+
public final class RecordPointerAndKeyPrefix {
2121
/**
2222
* A pointer to a record; see {@link org.apache.spark.memory.TaskMemoryManager} for a
2323
* description of how these addresses are encoded.

core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeSortDataFormat.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
* Within each long[] buffer, position {@code 2 * i} holds a pointer pointer to the record at
3030
* index {@code i}, while position {@code 2 * i + 1} in the array holds an 8-byte key prefix.
3131
*/
32-
final class UnsafeSortDataFormat extends SortDataFormat<RecordPointerAndKeyPrefix, LongArray> {
32+
public final class UnsafeSortDataFormat
33+
extends SortDataFormat<RecordPointerAndKeyPrefix, LongArray> {
3334

3435
public static final UnsafeSortDataFormat INSTANCE = new UnsafeSortDataFormat();
3536

core/src/main/scala/org/apache/spark/Accumulable.scala

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
package org.apache.spark
1919

20-
import java.io.{ObjectInputStream, Serializable}
20+
import java.io.Serializable
2121

2222
import scala.collection.generic.Growable
2323
import scala.reflect.ClassTag
2424

2525
import org.apache.spark.scheduler.AccumulableInfo
2626
import org.apache.spark.serializer.JavaSerializer
27-
import org.apache.spark.util.Utils
27+
import org.apache.spark.util.{AccumulatorContext, AccumulatorMetadata, LegacyAccumulatorWrapper}
2828

2929

3030
/**
@@ -49,6 +49,7 @@ import org.apache.spark.util.Utils
4949
* @tparam R the full accumulated data (result type)
5050
* @tparam T partial data that can be added in
5151
*/
52+
@deprecated("use AccumulatorV2", "2.0.0")
5253
class Accumulable[R, T] private (
5354
val id: Long,
5455
// SI-8813: This must explicitly be a private val, or else scala 2.11 doesn't compile
@@ -109,7 +110,13 @@ class Accumulable[R, T] private (
109110
/**
110111
* Access the accumulator's current value; only allowed on driver.
111112
*/
112-
def value: R = newAcc.value
113+
def value: R = {
114+
if (newAcc.isAtDriverSide) {
115+
newAcc.value
116+
} else {
117+
throw new UnsupportedOperationException("Can't read accumulator value in task")
118+
}
119+
}
113120

114121
/**
115122
* Get the current value of this accumulator from within a task.
@@ -120,7 +127,7 @@ class Accumulable[R, T] private (
120127
* The typical use of this method is to directly mutate the local value, eg., to add
121128
* an element to a Set.
122129
*/
123-
def localValue: R = newAcc.localValue
130+
def localValue: R = newAcc.value
124131

125132
/**
126133
* Set the accumulator's value; only allowed on driver.
@@ -162,6 +169,7 @@ class Accumulable[R, T] private (
162169
* @tparam R the full accumulated data (result type)
163170
* @tparam T partial data that can be added in
164171
*/
172+
@deprecated("use AccumulatorV2", "2.0.0")
165173
trait AccumulableParam[R, T] extends Serializable {
166174
/**
167175
* Add additional data to the accumulator value. Is allowed to modify and return `r`
@@ -191,6 +199,7 @@ trait AccumulableParam[R, T] extends Serializable {
191199
}
192200

193201

202+
@deprecated("use AccumulatorV2", "2.0.0")
194203
private[spark] class
195204
GrowableAccumulableParam[R <% Growable[T] with TraversableOnce[T] with Serializable: ClassTag, T]
196205
extends AccumulableParam[R, T] {

core/src/main/scala/org/apache/spark/Accumulator.scala

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@
1717

1818
package org.apache.spark
1919

20-
import java.util.concurrent.atomic.AtomicLong
21-
import javax.annotation.concurrent.GuardedBy
22-
23-
import scala.collection.mutable
24-
import scala.ref.WeakReference
25-
26-
import org.apache.spark.internal.Logging
27-
import org.apache.spark.storage.{BlockId, BlockStatus}
28-
29-
3020
/**
3121
* A simpler value of [[Accumulable]] where the result type being accumulated is the same
3222
* as the types of elements being merged, i.e. variables that are only "added" to through an
@@ -58,7 +48,8 @@ import org.apache.spark.storage.{BlockId, BlockStatus}
5848
* @param name human-readable name associated with this accumulator
5949
* @param countFailedValues whether to accumulate values from failed tasks
6050
* @tparam T result type
61-
*/
51+
*/
52+
@deprecated("use AccumulatorV2", "2.0.0")
6253
class Accumulator[T] private[spark] (
6354
// SI-8813: This must explicitly be a private val, or else scala 2.11 doesn't compile
6455
@transient private val initialValue: T,
@@ -75,35 +66,41 @@ class Accumulator[T] private[spark] (
7566
*
7667
* @tparam T type of value to accumulate
7768
*/
69+
@deprecated("use AccumulatorV2", "2.0.0")
7870
trait AccumulatorParam[T] extends AccumulableParam[T, T] {
7971
def addAccumulator(t1: T, t2: T): T = {
8072
addInPlace(t1, t2)
8173
}
8274
}
8375

8476

77+
@deprecated("use AccumulatorV2", "2.0.0")
8578
object AccumulatorParam {
8679

8780
// The following implicit objects were in SparkContext before 1.2 and users had to
8881
// `import SparkContext._` to enable them. Now we move them here to make the compiler find
8982
// them automatically. However, as there are duplicate codes in SparkContext for backward
9083
// compatibility, please update them accordingly if you modify the following implicit objects.
9184

85+
@deprecated("use AccumulatorV2", "2.0.0")
9286
implicit object DoubleAccumulatorParam extends AccumulatorParam[Double] {
9387
def addInPlace(t1: Double, t2: Double): Double = t1 + t2
9488
def zero(initialValue: Double): Double = 0.0
9589
}
9690

91+
@deprecated("use AccumulatorV2", "2.0.0")
9792
implicit object IntAccumulatorParam extends AccumulatorParam[Int] {
9893
def addInPlace(t1: Int, t2: Int): Int = t1 + t2
9994
def zero(initialValue: Int): Int = 0
10095
}
10196

97+
@deprecated("use AccumulatorV2", "2.0.0")
10298
implicit object LongAccumulatorParam extends AccumulatorParam[Long] {
10399
def addInPlace(t1: Long, t2: Long): Long = t1 + t2
104100
def zero(initialValue: Long): Long = 0L
105101
}
106102

103+
@deprecated("use AccumulatorV2", "2.0.0")
107104
implicit object FloatAccumulatorParam extends AccumulatorParam[Float] {
108105
def addInPlace(t1: Float, t2: Float): Float = t1 + t2
109106
def zero(initialValue: Float): Float = 0f
@@ -112,20 +109,9 @@ object AccumulatorParam {
112109
// Note: when merging values, this param just adopts the newer value. This is used only
113110
// internally for things that shouldn't really be accumulated across tasks, like input
114111
// read method, which should be the same across all tasks in the same stage.
112+
@deprecated("use AccumulatorV2", "2.0.0")
115113
private[spark] object StringAccumulatorParam extends AccumulatorParam[String] {
116114
def addInPlace(t1: String, t2: String): String = t2
117115
def zero(initialValue: String): String = ""
118116
}
119-
120-
// Note: this is expensive as it makes a copy of the list every time the caller adds an item.
121-
// A better way to use this is to first accumulate the values yourself then them all at once.
122-
private[spark] class ListAccumulatorParam[T] extends AccumulatorParam[Seq[T]] {
123-
def addInPlace(t1: Seq[T], t2: Seq[T]): Seq[T] = t1 ++ t2
124-
def zero(initialValue: Seq[T]): Seq[T] = Seq.empty[T]
125-
}
126-
127-
// For the internal metric that records what blocks are updated in a particular task
128-
private[spark] object UpdatedBlockStatusesAccumulatorParam
129-
extends ListAccumulatorParam[(BlockId, BlockStatus)]
130-
131117
}

core/src/main/scala/org/apache/spark/ContextCleaner.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import scala.collection.JavaConverters._
2525
import org.apache.spark.broadcast.Broadcast
2626
import org.apache.spark.internal.Logging
2727
import org.apache.spark.rdd.{RDD, ReliableRDDCheckpointData}
28-
import org.apache.spark.util.{ThreadUtils, Utils}
28+
import org.apache.spark.util.{AccumulatorContext, AccumulatorV2, ThreadUtils, Utils}
2929

3030
/**
3131
* Classes that represent cleaning tasks.
@@ -212,7 +212,7 @@ private[spark] class ContextCleaner(sc: SparkContext) extends Logging {
212212
}
213213
}
214214

215-
/** Perform shuffle cleanup, asynchronously. */
215+
/** Perform shuffle cleanup. */
216216
def doCleanupShuffle(shuffleId: Int, blocking: Boolean): Unit = {
217217
try {
218218
logDebug("Cleaning shuffle " + shuffleId)

core/src/main/scala/org/apache/spark/HeartbeatReceiver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import org.apache.spark.internal.Logging
2626
import org.apache.spark.rpc.{RpcCallContext, RpcEnv, ThreadSafeRpcEndpoint}
2727
import org.apache.spark.scheduler._
2828
import org.apache.spark.storage.BlockManagerId
29-
import org.apache.spark.util.{Clock, SystemClock, ThreadUtils, Utils}
29+
import org.apache.spark.util._
3030

3131
/**
3232
* A heartbeat from executors to the driver. This is a shared message used by several internal

0 commit comments

Comments
 (0)