Skip to content

Commit cd2b05a

Browse files
Merge remote-tracking branch 'upstream/master'
2 parents 0fc12d7 + 30a86ac commit cd2b05a

File tree

184 files changed

+5056
-1785
lines changed

Some content is hidden

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

184 files changed

+5056
-1785
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ dependency-reduced-pom.xml
4949
checkpoint
5050
derby.log
5151
dist/
52-
spark-*-bin.tar.gz
52+
spark-*-bin-*.tgz
5353
unit-tests.log
5454
/lib/
5555
rat-results.txt

bin/spark-sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
# Enter posix mode for bash
2424
set -o posix
2525

26+
# NOTE: This exact class name is matched downstream by SparkSubmit.
27+
# Any changes need to be reflected there.
2628
CLASS="org.apache.spark.sql.hive.thriftserver.SparkSQLCLIDriver"
2729

2830
# Figure out where Spark is installed

core/src/main/resources/org/apache/spark/ui/static/additional-metrics.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,12 @@ $(function() {
2828
$(this).find('.expand-additional-metrics-arrow').toggleClass('arrow-closed');
2929
});
3030

31-
$("input:checkbox:not(:checked)").each(function() {
32-
var column = "table ." + $(this).attr("name");
33-
$(column).hide();
34-
});
35-
// Stripe table rows after rows have been hidden to ensure correct striping.
36-
stripeTables();
31+
stripeSummaryTable();
3732

3833
$("input:checkbox").click(function() {
3934
var column = "table ." + $(this).attr("name");
4035
$(column).toggle();
41-
stripeTables();
36+
stripeSummaryTable();
4237
});
4338

4439
$("#select-all-metrics").click(function() {

core/src/main/resources/org/apache/spark/ui/static/table.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@
1515
* limitations under the License.
1616
*/
1717

18-
/* Adds background colors to stripe table rows. This is necessary (instead of using css or the
19-
* table striping provided by bootstrap) to appropriately stripe tables with hidden rows. */
20-
function stripeTables() {
21-
$("table.table-striped-custom").each(function() {
22-
$(this).find("tr:not(:hidden)").each(function (index) {
23-
if (index % 2 == 1) {
24-
$(this).css("background-color", "#f9f9f9");
25-
} else {
26-
$(this).css("background-color", "#ffffff");
27-
}
28-
});
18+
/* Adds background colors to stripe table rows in the summary table (on the stage page). This is
19+
* necessary (instead of using css or the table striping provided by bootstrap) because the summary
20+
* table has hidden rows.
21+
*
22+
* An ID selector (rather than a class selector) is used to ensure this runs quickly even on pages
23+
* with thousands of task rows (ID selectors are much faster than class selectors). */
24+
function stripeSummaryTable() {
25+
$("#task-summary-table").find("tr:not(:hidden)").each(function (index) {
26+
if (index % 2 == 1) {
27+
$(this).css("background-color", "#f9f9f9");
28+
} else {
29+
$(this).css("background-color", "#ffffff");
30+
}
2931
});
3032
}

core/src/main/resources/org/apache/spark/ui/static/webui.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,9 @@ span.additional-metric-title {
168168
border-left: 5px solid black;
169169
display: inline-block;
170170
}
171+
172+
/* Hide all additional metrics by default. This is done here rather than using JavaScript to
173+
* avoid slow page loads for stage pages with large numbers (e.g., thousands) of tasks. */
174+
.scheduler_delay, .gc_time, .deserialization_time, .serialization_time, .getting_result_time {
175+
display: none;
176+
}

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.spark
1919

2020
import java.io.{ObjectInputStream, Serializable}
21+
import java.util.concurrent.atomic.AtomicLong
2122

2223
import scala.collection.generic.Growable
2324
import scala.collection.mutable.Map
@@ -228,6 +229,7 @@ GrowableAccumulableParam[R <% Growable[T] with TraversableOnce[T] with Serializa
228229
*/
229230
class Accumulator[T](@transient initialValue: T, param: AccumulatorParam[T], name: Option[String])
230231
extends Accumulable[T,T](initialValue, param, name) {
232+
231233
def this(initialValue: T, param: AccumulatorParam[T]) = this(initialValue, param, None)
232234
}
233235

@@ -244,6 +246,36 @@ trait AccumulatorParam[T] extends AccumulableParam[T, T] {
244246
}
245247
}
246248

249+
object AccumulatorParam {
250+
251+
// The following implicit objects were in SparkContext before 1.2 and users had to
252+
// `import SparkContext._` to enable them. Now we move them here to make the compiler find
253+
// them automatically. However, as there are duplicate codes in SparkContext for backward
254+
// compatibility, please update them accordingly if you modify the following implicit objects.
255+
256+
implicit object DoubleAccumulatorParam extends AccumulatorParam[Double] {
257+
def addInPlace(t1: Double, t2: Double): Double = t1 + t2
258+
def zero(initialValue: Double) = 0.0
259+
}
260+
261+
implicit object IntAccumulatorParam extends AccumulatorParam[Int] {
262+
def addInPlace(t1: Int, t2: Int): Int = t1 + t2
263+
def zero(initialValue: Int) = 0
264+
}
265+
266+
implicit object LongAccumulatorParam extends AccumulatorParam[Long] {
267+
def addInPlace(t1: Long, t2: Long) = t1 + t2
268+
def zero(initialValue: Long) = 0L
269+
}
270+
271+
implicit object FloatAccumulatorParam extends AccumulatorParam[Float] {
272+
def addInPlace(t1: Float, t2: Float) = t1 + t2
273+
def zero(initialValue: Float) = 0f
274+
}
275+
276+
// TODO: Add AccumulatorParams for other types, e.g. lists and strings
277+
}
278+
247279
// TODO: The multi-thread support in accumulators is kind of lame; check
248280
// if there's a more intuitive way of doing it right
249281
private object Accumulators {
@@ -252,7 +284,7 @@ private object Accumulators {
252284
val localAccums = Map[Thread, Map[Long, Accumulable[_, _]]]()
253285
var lastId: Long = 0
254286

255-
def newId: Long = synchronized {
287+
def newId(): Long = synchronized {
256288
lastId += 1
257289
lastId
258290
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
6161
throw new NullPointerException("null key")
6262
}
6363
if (value == null) {
64-
throw new NullPointerException("null value")
64+
throw new NullPointerException("null value for " + key)
6565
}
6666
settings(key) = value
6767
this

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

Lines changed: 122 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ class SparkContext(config: SparkConf) extends Logging {
8383
// contains a map from hostname to a list of input format splits on the host.
8484
private[spark] var preferredNodeLocationData: Map[String, Set[SplitInfo]] = Map()
8585

86+
val startTime = System.currentTimeMillis()
87+
8688
/**
8789
* Create a SparkContext that loads settings from system properties (for instance, when
8890
* launching with ./bin/spark-submit).
@@ -269,8 +271,6 @@ class SparkContext(config: SparkConf) extends Logging {
269271
/** A default Hadoop Configuration for the Hadoop code (e.g. file systems) that we reuse. */
270272
val hadoopConfiguration = SparkHadoopUtil.get.newConfiguration(conf)
271273

272-
val startTime = System.currentTimeMillis()
273-
274274
// Add each JAR given through the constructor
275275
if (jars != null) {
276276
jars.foreach(addJar)
@@ -1624,47 +1624,74 @@ object SparkContext extends Logging {
16241624

16251625
private[spark] val DRIVER_IDENTIFIER = "<driver>"
16261626

1627-
implicit object DoubleAccumulatorParam extends AccumulatorParam[Double] {
1627+
// The following deprecated objects have already been copied to `object AccumulatorParam` to
1628+
// make the compiler find them automatically. They are duplicate codes only for backward
1629+
// compatibility, please update `object AccumulatorParam` accordingly if you plan to modify the
1630+
// following ones.
1631+
1632+
@deprecated("Replaced by implicit objects in AccumulatorParam. This is kept here only for " +
1633+
"backward compatibility.", "1.2.0")
1634+
object DoubleAccumulatorParam extends AccumulatorParam[Double] {
16281635
def addInPlace(t1: Double, t2: Double): Double = t1 + t2
16291636
def zero(initialValue: Double) = 0.0
16301637
}
16311638

1632-
implicit object IntAccumulatorParam extends AccumulatorParam[Int] {
1639+
@deprecated("Replaced by implicit objects in AccumulatorParam. This is kept here only for " +
1640+
"backward compatibility.", "1.2.0")
1641+
object IntAccumulatorParam extends AccumulatorParam[Int] {
16331642
def addInPlace(t1: Int, t2: Int): Int = t1 + t2
16341643
def zero(initialValue: Int) = 0
16351644
}
16361645

1637-
implicit object LongAccumulatorParam extends AccumulatorParam[Long] {
1646+
@deprecated("Replaced by implicit objects in AccumulatorParam. This is kept here only for " +
1647+
"backward compatibility.", "1.2.0")
1648+
object LongAccumulatorParam extends AccumulatorParam[Long] {
16381649
def addInPlace(t1: Long, t2: Long) = t1 + t2
16391650
def zero(initialValue: Long) = 0L
16401651
}
16411652

1642-
implicit object FloatAccumulatorParam extends AccumulatorParam[Float] {
1653+
@deprecated("Replaced by implicit objects in AccumulatorParam. This is kept here only for " +
1654+
"backward compatibility.", "1.2.0")
1655+
object FloatAccumulatorParam extends AccumulatorParam[Float] {
16431656
def addInPlace(t1: Float, t2: Float) = t1 + t2
16441657
def zero(initialValue: Float) = 0f
16451658
}
16461659

1647-
// TODO: Add AccumulatorParams for other types, e.g. lists and strings
1660+
// The following deprecated functions have already been moved to `object RDD` to
1661+
// make the compiler find them automatically. They are still kept here for backward compatibility
1662+
// and just call the corresponding functions in `object RDD`.
16481663

1649-
implicit def rddToPairRDDFunctions[K, V](rdd: RDD[(K, V)])
1664+
@deprecated("Replaced by implicit functions in the RDD companion object. This is " +
1665+
"kept here only for backward compatibility.", "1.2.0")
1666+
def rddToPairRDDFunctions[K, V](rdd: RDD[(K, V)])
16501667
(implicit kt: ClassTag[K], vt: ClassTag[V], ord: Ordering[K] = null) = {
1651-
new PairRDDFunctions(rdd)
1668+
RDD.rddToPairRDDFunctions(rdd)
16521669
}
16531670

1654-
implicit def rddToAsyncRDDActions[T: ClassTag](rdd: RDD[T]) = new AsyncRDDActions(rdd)
1671+
@deprecated("Replaced by implicit functions in the RDD companion object. This is " +
1672+
"kept here only for backward compatibility.", "1.2.0")
1673+
def rddToAsyncRDDActions[T: ClassTag](rdd: RDD[T]) = RDD.rddToAsyncRDDActions(rdd)
16551674

1656-
implicit def rddToSequenceFileRDDFunctions[K <% Writable: ClassTag, V <% Writable: ClassTag](
1675+
@deprecated("Replaced by implicit functions in the RDD companion object. This is " +
1676+
"kept here only for backward compatibility.", "1.2.0")
1677+
def rddToSequenceFileRDDFunctions[K <% Writable: ClassTag, V <% Writable: ClassTag](
16571678
rdd: RDD[(K, V)]) =
1658-
new SequenceFileRDDFunctions(rdd)
1679+
RDD.rddToSequenceFileRDDFunctions(rdd)
16591680

1660-
implicit def rddToOrderedRDDFunctions[K : Ordering : ClassTag, V: ClassTag](
1681+
@deprecated("Replaced by implicit functions in the RDD companion object. This is " +
1682+
"kept here only for backward compatibility.", "1.2.0")
1683+
def rddToOrderedRDDFunctions[K : Ordering : ClassTag, V: ClassTag](
16611684
rdd: RDD[(K, V)]) =
1662-
new OrderedRDDFunctions[K, V, (K, V)](rdd)
1685+
RDD.rddToOrderedRDDFunctions(rdd)
16631686

1664-
implicit def doubleRDDToDoubleRDDFunctions(rdd: RDD[Double]) = new DoubleRDDFunctions(rdd)
1687+
@deprecated("Replaced by implicit functions in the RDD companion object. This is " +
1688+
"kept here only for backward compatibility.", "1.2.0")
1689+
def doubleRDDToDoubleRDDFunctions(rdd: RDD[Double]) = RDD.doubleRDDToDoubleRDDFunctions(rdd)
16651690

1666-
implicit def numericRDDToDoubleRDDFunctions[T](rdd: RDD[T])(implicit num: Numeric[T]) =
1667-
new DoubleRDDFunctions(rdd.map(x => num.toDouble(x)))
1691+
@deprecated("Replaced by implicit functions in the RDD companion object. This is " +
1692+
"kept here only for backward compatibility.", "1.2.0")
1693+
def numericRDDToDoubleRDDFunctions[T](rdd: RDD[T])(implicit num: Numeric[T]) =
1694+
RDD.numericRDDToDoubleRDDFunctions(rdd)
16681695

16691696
// Implicit conversions to common Writable types, for saveAsSequenceFile
16701697

@@ -1690,40 +1717,49 @@ object SparkContext extends Logging {
16901717
arr.map(x => anyToWritable(x)).toArray)
16911718
}
16921719

1693-
// Helper objects for converting common types to Writable
1694-
private def simpleWritableConverter[T, W <: Writable: ClassTag](convert: W => T)
1695-
: WritableConverter[T] = {
1696-
val wClass = classTag[W].runtimeClass.asInstanceOf[Class[W]]
1697-
new WritableConverter[T](_ => wClass, x => convert(x.asInstanceOf[W]))
1698-
}
1720+
// The following deprecated functions have already been moved to `object WritableConverter` to
1721+
// make the compiler find them automatically. They are still kept here for backward compatibility
1722+
// and just call the corresponding functions in `object WritableConverter`.
16991723

1700-
implicit def intWritableConverter(): WritableConverter[Int] =
1701-
simpleWritableConverter[Int, IntWritable](_.get)
1724+
@deprecated("Replaced by implicit functions in WritableConverter. This is kept here only for " +
1725+
"backward compatibility.", "1.2.0")
1726+
def intWritableConverter(): WritableConverter[Int] =
1727+
WritableConverter.intWritableConverter()
17021728

1703-
implicit def longWritableConverter(): WritableConverter[Long] =
1704-
simpleWritableConverter[Long, LongWritable](_.get)
1729+
@deprecated("Replaced by implicit functions in WritableConverter. This is kept here only for " +
1730+
"backward compatibility.", "1.2.0")
1731+
def longWritableConverter(): WritableConverter[Long] =
1732+
WritableConverter.longWritableConverter()
17051733

1706-
implicit def doubleWritableConverter(): WritableConverter[Double] =
1707-
simpleWritableConverter[Double, DoubleWritable](_.get)
1734+
@deprecated("Replaced by implicit functions in WritableConverter. This is kept here only for " +
1735+
"backward compatibility.", "1.2.0")
1736+
def doubleWritableConverter(): WritableConverter[Double] =
1737+
WritableConverter.doubleWritableConverter()
17081738

1709-
implicit def floatWritableConverter(): WritableConverter[Float] =
1710-
simpleWritableConverter[Float, FloatWritable](_.get)
1739+
@deprecated("Replaced by implicit functions in WritableConverter. This is kept here only for " +
1740+
"backward compatibility.", "1.2.0")
1741+
def floatWritableConverter(): WritableConverter[Float] =
1742+
WritableConverter.floatWritableConverter()
17111743

1712-
implicit def booleanWritableConverter(): WritableConverter[Boolean] =
1713-
simpleWritableConverter[Boolean, BooleanWritable](_.get)
1744+
@deprecated("Replaced by implicit functions in WritableConverter. This is kept here only for " +
1745+
"backward compatibility.", "1.2.0")
1746+
def booleanWritableConverter(): WritableConverter[Boolean] =
1747+
WritableConverter.booleanWritableConverter()
17141748

1715-
implicit def bytesWritableConverter(): WritableConverter[Array[Byte]] = {
1716-
simpleWritableConverter[Array[Byte], BytesWritable](bw =>
1717-
// getBytes method returns array which is longer then data to be returned
1718-
Arrays.copyOfRange(bw.getBytes, 0, bw.getLength)
1719-
)
1720-
}
1749+
@deprecated("Replaced by implicit functions in WritableConverter. This is kept here only for " +
1750+
"backward compatibility.", "1.2.0")
1751+
def bytesWritableConverter(): WritableConverter[Array[Byte]] =
1752+
WritableConverter.bytesWritableConverter()
17211753

1722-
implicit def stringWritableConverter(): WritableConverter[String] =
1723-
simpleWritableConverter[String, Text](_.toString)
1754+
@deprecated("Replaced by implicit functions in WritableConverter. This is kept here only for " +
1755+
"backward compatibility.", "1.2.0")
1756+
def stringWritableConverter(): WritableConverter[String] =
1757+
WritableConverter.stringWritableConverter()
17241758

1725-
implicit def writableWritableConverter[T <: Writable]() =
1726-
new WritableConverter[T](_.runtimeClass.asInstanceOf[Class[T]], _.asInstanceOf[T])
1759+
@deprecated("Replaced by implicit functions in WritableConverter. This is kept here only for " +
1760+
"backward compatibility.", "1.2.0")
1761+
def writableWritableConverter[T <: Writable]() =
1762+
WritableConverter.writableWritableConverter()
17271763

17281764
/**
17291765
* Find the JAR from which a given class was loaded, to make it easy for users to pass
@@ -1950,3 +1986,46 @@ private[spark] class WritableConverter[T](
19501986
val writableClass: ClassTag[T] => Class[_ <: Writable],
19511987
val convert: Writable => T)
19521988
extends Serializable
1989+
1990+
object WritableConverter {
1991+
1992+
// Helper objects for converting common types to Writable
1993+
private[spark] def simpleWritableConverter[T, W <: Writable: ClassTag](convert: W => T)
1994+
: WritableConverter[T] = {
1995+
val wClass = classTag[W].runtimeClass.asInstanceOf[Class[W]]
1996+
new WritableConverter[T](_ => wClass, x => convert(x.asInstanceOf[W]))
1997+
}
1998+
1999+
// The following implicit functions were in SparkContext before 1.2 and users had to
2000+
// `import SparkContext._` to enable them. Now we move them here to make the compiler find
2001+
// them automatically. However, we still keep the old functions in SparkContext for backward
2002+
// compatibility and forward to the following functions directly.
2003+
2004+
implicit def intWritableConverter(): WritableConverter[Int] =
2005+
simpleWritableConverter[Int, IntWritable](_.get)
2006+
2007+
implicit def longWritableConverter(): WritableConverter[Long] =
2008+
simpleWritableConverter[Long, LongWritable](_.get)
2009+
2010+
implicit def doubleWritableConverter(): WritableConverter[Double] =
2011+
simpleWritableConverter[Double, DoubleWritable](_.get)
2012+
2013+
implicit def floatWritableConverter(): WritableConverter[Float] =
2014+
simpleWritableConverter[Float, FloatWritable](_.get)
2015+
2016+
implicit def booleanWritableConverter(): WritableConverter[Boolean] =
2017+
simpleWritableConverter[Boolean, BooleanWritable](_.get)
2018+
2019+
implicit def bytesWritableConverter(): WritableConverter[Array[Byte]] = {
2020+
simpleWritableConverter[Array[Byte], BytesWritable](bw =>
2021+
// getBytes method returns array which is longer then data to be returned
2022+
Arrays.copyOfRange(bw.getBytes, 0, bw.getLength)
2023+
)
2024+
}
2025+
2026+
implicit def stringWritableConverter(): WritableConverter[String] =
2027+
simpleWritableConverter[String, Text](_.toString)
2028+
2029+
implicit def writableWritableConverter[T <: Writable]() =
2030+
new WritableConverter[T](_.runtimeClass.asInstanceOf[Class[T]], _.asInstanceOf[T])
2031+
}

core/src/main/scala/org/apache/spark/api/java/JavaPairRDD.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ import org.apache.hadoop.mapreduce.{OutputFormat => NewOutputFormat}
3232

3333
import org.apache.spark.{HashPartitioner, Partitioner}
3434
import org.apache.spark.Partitioner._
35-
import org.apache.spark.SparkContext.rddToPairRDDFunctions
3635
import org.apache.spark.annotation.Experimental
3736
import org.apache.spark.api.java.JavaSparkContext.fakeClassTag
3837
import org.apache.spark.api.java.JavaUtils.mapAsSerializableJavaMap
3938
import org.apache.spark.api.java.function.{Function => JFunction, Function2 => JFunction2, PairFunction}
4039
import org.apache.spark.partial.{BoundedDouble, PartialResult}
4140
import org.apache.spark.rdd.{OrderedRDDFunctions, RDD}
41+
import org.apache.spark.rdd.RDD.rddToPairRDDFunctions
4242
import org.apache.spark.storage.StorageLevel
4343
import org.apache.spark.util.Utils
4444

0 commit comments

Comments
 (0)