Skip to content

Commit 25229c6

Browse files
committed
Merge remote-tracking branch 'apache/master'
2 parents aa20a6e + 15e0d2b commit 25229c6

File tree

515 files changed

+11580
-5188
lines changed

Some content is hidden

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

515 files changed

+11580
-5188
lines changed

bin/load-spark-env.cmd

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@echo off
2+
3+
rem
4+
rem Licensed to the Apache Software Foundation (ASF) under one or more
5+
rem contributor license agreements. See the NOTICE file distributed with
6+
rem this work for additional information regarding copyright ownership.
7+
rem The ASF licenses this file to You under the Apache License, Version 2.0
8+
rem (the "License"); you may not use this file except in compliance with
9+
rem the License. You may obtain a copy of the License at
10+
rem
11+
rem http://www.apache.org/licenses/LICENSE-2.0
12+
rem
13+
rem Unless required by applicable law or agreed to in writing, software
14+
rem distributed under the License is distributed on an "AS IS" BASIS,
15+
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
rem See the License for the specific language governing permissions and
17+
rem limitations under the License.
18+
rem
19+
20+
rem This script loads spark-env.cmd if it exists, and ensures it is only loaded once.
21+
rem spark-env.cmd is loaded from SPARK_CONF_DIR if set, or within the current directory's
22+
rem conf/ subdirectory.
23+
24+
if [%SPARK_ENV_LOADED%] == [] (
25+
set SPARK_ENV_LOADED=1
26+
27+
if not [%SPARK_CONF_DIR%] == [] (
28+
set user_conf_dir=%SPARK_CONF_DIR%
29+
) else (
30+
set user_conf_dir=%~dp0..\..\conf
31+
)
32+
33+
call :LoadSparkEnv
34+
)
35+
36+
rem Setting SPARK_SCALA_VERSION if not already set.
37+
38+
set ASSEMBLY_DIR2=%SPARK_HOME%/assembly/target/scala-2.11
39+
set ASSEMBLY_DIR1=%SPARK_HOME%/assembly/target/scala-2.10
40+
41+
if [%SPARK_SCALA_VERSION%] == [] (
42+
43+
if exist %ASSEMBLY_DIR2% if exist %ASSEMBLY_DIR1% (
44+
echo "Presence of build for both scala versions(SCALA 2.10 and SCALA 2.11) detected."
45+
echo "Either clean one of them or, set SPARK_SCALA_VERSION=2.11 in spark-env.cmd."
46+
exit 1
47+
)
48+
if exist %ASSEMBLY_DIR2% (
49+
set SPARK_SCALA_VERSION=2.11
50+
) else (
51+
set SPARK_SCALA_VERSION=2.10
52+
)
53+
)
54+
exit /b 0
55+
56+
:LoadSparkEnv
57+
if exist "%user_conf_dir%\spark-env.cmd" (
58+
call "%user_conf_dir%\spark-env.cmd"
59+
)

bin/pyspark2.cmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ rem
2020
rem Figure out where the Spark framework is installed
2121
set SPARK_HOME=%~dp0..
2222

23-
rem Load environment variables from conf\spark-env.cmd, if it exists
24-
if exist "%SPARK_HOME%\conf\spark-env.cmd" call "%SPARK_HOME%\conf\spark-env.cmd"
23+
call %SPARK_HOME%\bin\load-spark-env.cmd
2524

2625
rem Figure out which Python to use.
2726
if "x%PYSPARK_DRIVER_PYTHON%"=="x" (

bin/run-example2.cmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ set FWDIR=%~dp0..\
2525
rem Export this as SPARK_HOME
2626
set SPARK_HOME=%FWDIR%
2727

28-
rem Load environment variables from conf\spark-env.cmd, if it exists
29-
if exist "%FWDIR%conf\spark-env.cmd" call "%FWDIR%conf\spark-env.cmd"
28+
call %SPARK_HOME%\bin\load-spark-env.cmd
3029

3130
rem Test that an argument was given
3231
if not "x%1"=="x" goto arg_given

bin/spark-class

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,46 @@ else
4040
fi
4141
fi
4242

43-
# Look for the launcher. In non-release mode, add the compiled classes directly to the classpath
44-
# instead of looking for a jar file.
45-
SPARK_LAUNCHER_CP=
46-
if [ -f $SPARK_HOME/RELEASE ]; then
47-
LAUNCHER_DIR="$SPARK_HOME/lib"
48-
num_jars="$(ls -1 "$LAUNCHER_DIR" | grep "^spark-launcher.*\.jar$" | wc -l)"
49-
if [ "$num_jars" -eq "0" -a -z "$SPARK_LAUNCHER_CP" ]; then
50-
echo "Failed to find Spark launcher in $LAUNCHER_DIR." 1>&2
51-
echo "You need to build Spark before running this program." 1>&2
52-
exit 1
53-
fi
43+
# Find assembly jar
44+
SPARK_ASSEMBLY_JAR=
45+
if [ -f "$SPARK_HOME/RELEASE" ]; then
46+
ASSEMBLY_DIR="$SPARK_HOME/lib"
47+
else
48+
ASSEMBLY_DIR="$SPARK_HOME/assembly/target/scala-$SPARK_SCALA_VERSION"
49+
fi
5450

55-
LAUNCHER_JARS="$(ls -1 "$LAUNCHER_DIR" | grep "^spark-launcher.*\.jar$" || true)"
56-
if [ "$num_jars" -gt "1" ]; then
57-
echo "Found multiple Spark launcher jars in $LAUNCHER_DIR:" 1>&2
58-
echo "$LAUNCHER_JARS" 1>&2
59-
echo "Please remove all but one jar." 1>&2
60-
exit 1
61-
fi
51+
num_jars="$(ls -1 "$ASSEMBLY_DIR" | grep "^spark-assembly.*hadoop.*\.jar$" | wc -l)"
52+
if [ "$num_jars" -eq "0" -a -z "$SPARK_ASSEMBLY_JAR" ]; then
53+
echo "Failed to find Spark assembly in $ASSEMBLY_DIR." 1>&2
54+
echo "You need to build Spark before running this program." 1>&2
55+
exit 1
56+
fi
57+
ASSEMBLY_JARS="$(ls -1 "$ASSEMBLY_DIR" | grep "^spark-assembly.*hadoop.*\.jar$" || true)"
58+
if [ "$num_jars" -gt "1" ]; then
59+
echo "Found multiple Spark assembly jars in $ASSEMBLY_DIR:" 1>&2
60+
echo "$ASSEMBLY_JARS" 1>&2
61+
echo "Please remove all but one jar." 1>&2
62+
exit 1
63+
fi
6264

63-
SPARK_LAUNCHER_CP="${LAUNCHER_DIR}/${LAUNCHER_JARS}"
65+
SPARK_ASSEMBLY_JAR="${ASSEMBLY_DIR}/${ASSEMBLY_JARS}"
66+
67+
# Verify that versions of java used to build the jars and run Spark are compatible
68+
if [ -n "$JAVA_HOME" ]; then
69+
JAR_CMD="$JAVA_HOME/bin/jar"
6470
else
65-
LAUNCHER_DIR="$SPARK_HOME/launcher/target/scala-$SPARK_SCALA_VERSION"
66-
if [ ! -d "$LAUNCHER_DIR/classes" ]; then
67-
echo "Failed to find Spark launcher classes in $LAUNCHER_DIR." 1>&2
68-
echo "You need to build Spark before running this program." 1>&2
71+
JAR_CMD="jar"
72+
fi
73+
74+
if [ $(command -v "$JAR_CMD") ] ; then
75+
jar_error_check=$("$JAR_CMD" -tf "$SPARK_ASSEMBLY_JAR" nonexistent/class/path 2>&1)
76+
if [[ "$jar_error_check" =~ "invalid CEN header" ]]; then
77+
echo "Loading Spark jar with '$JAR_CMD' failed. " 1>&2
78+
echo "This is likely because Spark was compiled with Java 7 and run " 1>&2
79+
echo "with Java 6. (see SPARK-1703). Please use Java 7 to run Spark " 1>&2
80+
echo "or build Spark with Java 6." 1>&2
6981
exit 1
7082
fi
71-
SPARK_LAUNCHER_CP="$LAUNCHER_DIR/classes"
7283
fi
7384

7485
# The launcher library will print arguments separated by a NULL character, to allow arguments with
@@ -77,7 +88,7 @@ fi
7788
CMD=()
7889
while IFS= read -d '' -r ARG; do
7990
CMD+=("$ARG")
80-
done < <("$RUNNER" -cp "$SPARK_LAUNCHER_CP" org.apache.spark.launcher.Main "$@")
91+
done < <("$RUNNER" -cp "$SPARK_ASSEMBLY_JAR" org.apache.spark.launcher.Main "$@")
8192

8293
if [ "${CMD[0]}" = "usage" ]; then
8394
"${CMD[@]}"

bin/spark-class2.cmd

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,28 @@ rem
2020
rem Figure out where the Spark framework is installed
2121
set SPARK_HOME=%~dp0..
2222

23-
rem Load environment variables from conf\spark-env.cmd, if it exists
24-
if exist "%SPARK_HOME%\conf\spark-env.cmd" call "%SPARK_HOME%\conf\spark-env.cmd"
23+
call %SPARK_HOME%\bin\load-spark-env.cmd
2524

2625
rem Test that an argument was given
2726
if "x%1"=="x" (
2827
echo Usage: spark-class ^<class^> [^<args^>]
2928
exit /b 1
3029
)
3130

32-
set LAUNCHER_CP=0
33-
if exist %SPARK_HOME%\RELEASE goto find_release_launcher
31+
rem Find assembly jar
32+
set SPARK_ASSEMBLY_JAR=0
3433

35-
rem Look for the Spark launcher in both Scala build directories. The launcher doesn't use Scala so
36-
rem it doesn't really matter which one is picked up. Add the compiled classes directly to the
37-
rem classpath instead of looking for a jar file, since it's very common for people using sbt to use
38-
rem the "assembly" target instead of "package".
39-
set LAUNCHER_CLASSES=%SPARK_HOME%\launcher\target\scala-2.10\classes
40-
if exist %LAUNCHER_CLASSES% (
41-
set LAUNCHER_CP=%LAUNCHER_CLASSES%
34+
if exist "%SPARK_HOME%\RELEASE" (
35+
set ASSEMBLY_DIR=%SPARK_HOME%\lib
36+
) else (
37+
set ASSEMBLY_DIR=%SPARK_HOME%\assembly\target\scala-%SPARK_SCALA_VERSION%
4238
)
43-
set LAUNCHER_CLASSES=%SPARK_HOME%\launcher\target\scala-2.11\classes
44-
if exist %LAUNCHER_CLASSES% (
45-
set LAUNCHER_CP=%LAUNCHER_CLASSES%
46-
)
47-
goto check_launcher
4839

49-
:find_release_launcher
50-
for %%d in (%SPARK_HOME%\lib\spark-launcher*.jar) do (
51-
set LAUNCHER_CP=%%d
40+
for %%d in (%ASSEMBLY_DIR%\spark-assembly*hadoop*.jar) do (
41+
set SPARK_ASSEMBLY_JAR=%%d
5242
)
53-
54-
:check_launcher
55-
if "%LAUNCHER_CP%"=="0" (
56-
echo Failed to find Spark launcher JAR.
43+
if "%SPARK_ASSEMBLY_JAR%"=="0" (
44+
echo Failed to find Spark assembly JAR.
5745
echo You need to build Spark before running this program.
5846
exit /b 1
5947
)
@@ -64,7 +52,7 @@ if not "x%JAVA_HOME%"=="x" set RUNNER=%JAVA_HOME%\bin\java
6452

6553
rem The launcher library prints the command to be executed in a single line suitable for being
6654
rem executed by the batch interpreter. So read all the output of the launcher into a variable.
67-
for /f "tokens=*" %%i in ('cmd /C ""%RUNNER%" -cp %LAUNCHER_CP% org.apache.spark.launcher.Main %*"') do (
55+
for /f "tokens=*" %%i in ('cmd /C ""%RUNNER%" -cp %SPARK_ASSEMBLY_JAR% org.apache.spark.launcher.Main %*"') do (
6856
set SPARK_CMD=%%i
6957
)
7058
%SPARK_CMD%

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $(function() {
3030

3131
stripeSummaryTable();
3232

33-
$("input:checkbox").click(function() {
33+
$('input[type="checkbox"]').click(function() {
3434
var column = "table ." + $(this).attr("name");
3535
$(column).toggle();
3636
stripeSummaryTable();
@@ -39,15 +39,15 @@ $(function() {
3939
$("#select-all-metrics").click(function() {
4040
if (this.checked) {
4141
// Toggle all un-checked options.
42-
$('input:checkbox:not(:checked)').trigger('click');
42+
$('input[type="checkbox"]:not(:checked)').trigger('click');
4343
} else {
4444
// Toggle all checked options.
45-
$('input:checkbox:checked').trigger('click');
45+
$('input[type="checkbox"]:checked').trigger('click');
4646
}
4747
});
4848

4949
// Trigger a click on the checkbox if a user clicks the label next to it.
5050
$("span.additional-metric-title").click(function() {
51-
$(this).parent().find('input:checkbox').trigger('click');
51+
$(this).parent().find('input[type="checkbox"]').trigger('click');
5252
});
5353
});

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
package org.apache.spark
1919

2020
import java.io.{ObjectInputStream, Serializable}
21-
import java.util.concurrent.atomic.AtomicLong
22-
import java.lang.ThreadLocal
2321

2422
import scala.collection.generic.Growable
2523
import scala.collection.mutable.Map
@@ -109,7 +107,7 @@ class Accumulable[R, T] (
109107
* The typical use of this method is to directly mutate the local value, eg., to add
110108
* an element to a Set.
111109
*/
112-
def localValue = value_
110+
def localValue: R = value_
113111

114112
/**
115113
* Set the accumulator's value; only allowed on master.
@@ -137,7 +135,7 @@ class Accumulable[R, T] (
137135
Accumulators.register(this, false)
138136
}
139137

140-
override def toString = if (value_ == null) "null" else value_.toString
138+
override def toString: String = if (value_ == null) "null" else value_.toString
141139
}
142140

143141
/**
@@ -257,22 +255,22 @@ object AccumulatorParam {
257255

258256
implicit object DoubleAccumulatorParam extends AccumulatorParam[Double] {
259257
def addInPlace(t1: Double, t2: Double): Double = t1 + t2
260-
def zero(initialValue: Double) = 0.0
258+
def zero(initialValue: Double): Double = 0.0
261259
}
262260

263261
implicit object IntAccumulatorParam extends AccumulatorParam[Int] {
264262
def addInPlace(t1: Int, t2: Int): Int = t1 + t2
265-
def zero(initialValue: Int) = 0
263+
def zero(initialValue: Int): Int = 0
266264
}
267265

268266
implicit object LongAccumulatorParam extends AccumulatorParam[Long] {
269-
def addInPlace(t1: Long, t2: Long) = t1 + t2
270-
def zero(initialValue: Long) = 0L
267+
def addInPlace(t1: Long, t2: Long): Long = t1 + t2
268+
def zero(initialValue: Long): Long = 0L
271269
}
272270

273271
implicit object FloatAccumulatorParam extends AccumulatorParam[Float] {
274-
def addInPlace(t1: Float, t2: Float) = t1 + t2
275-
def zero(initialValue: Float) = 0f
272+
def addInPlace(t1: Float, t2: Float): Float = t1 + t2
273+
def zero(initialValue: Float): Float = 0f
276274
}
277275

278276
// TODO: Add AccumulatorParams for other types, e.g. lists and strings
@@ -351,6 +349,7 @@ private[spark] object Accumulators extends Logging {
351349
}
352350
}
353351

354-
def stringifyPartialValue(partialValue: Any) = "%s".format(partialValue)
355-
def stringifyValue(value: Any) = "%s".format(value)
352+
def stringifyPartialValue(partialValue: Any): String = "%s".format(partialValue)
353+
354+
def stringifyValue(value: Any): String = "%s".format(value)
356355
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ShuffleDependency[K, V, C](
7474
val mapSideCombine: Boolean = false)
7575
extends Dependency[Product2[K, V]] {
7676

77-
override def rdd = _rdd.asInstanceOf[RDD[Product2[K, V]]]
77+
override def rdd: RDD[Product2[K, V]] = _rdd.asInstanceOf[RDD[Product2[K, V]]]
7878

7979
val shuffleId: Int = _rdd.context.newShuffleId()
8080

@@ -91,7 +91,7 @@ class ShuffleDependency[K, V, C](
9191
*/
9292
@DeveloperApi
9393
class OneToOneDependency[T](rdd: RDD[T]) extends NarrowDependency[T](rdd) {
94-
override def getParents(partitionId: Int) = List(partitionId)
94+
override def getParents(partitionId: Int): List[Int] = List(partitionId)
9595
}
9696

9797

@@ -107,7 +107,7 @@ class OneToOneDependency[T](rdd: RDD[T]) extends NarrowDependency[T](rdd) {
107107
class RangeDependency[T](rdd: RDD[T], inStart: Int, outStart: Int, length: Int)
108108
extends NarrowDependency[T](rdd) {
109109

110-
override def getParents(partitionId: Int) = {
110+
override def getParents(partitionId: Int): List[Int] = {
111111
if (partitionId >= outStart && partitionId < outStart + length) {
112112
List(partitionId - outStart + inStart)
113113
} else {

0 commit comments

Comments
 (0)