Skip to content

Commit dd57922

Browse files
committed
Merge remote-tracking branch 'upstream/master' into pyspark-inputformats
Conflicts: core/src/main/scala/org/apache/spark/api/python/PythonRDD.scala project/SparkBuild.scala python/pyspark/context.py python/pyspark/serializers.py
2 parents e67212a + 9689b66 commit dd57922

File tree

11,947 files changed

+271831
-5121
lines changed

Some content is hidden

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

11,947 files changed

+271831
-5121
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
sbt/*.jar
88
.settings
99
.cache
10+
.mima-excludes
1011
/build/
1112
work/
1213
out/
@@ -45,3 +46,5 @@ dist/
4546
spark-*-bin.tar.gz
4647
unit-tests.log
4748
/lib/
49+
rat-results.txt
50+
scalastyle.txt

.rat-excludes

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
target
2+
.gitignore
3+
.project
4+
.classpath
5+
.mima-excludes
6+
.rat-excludes
7+
.*md
8+
derby.log
9+
TAGS
10+
RELEASE
11+
control
12+
docs
13+
fairscheduler.xml.template
14+
log4j.properties
15+
log4j.properties.template
16+
metrics.properties.template
17+
slaves
18+
spark-env.sh
19+
spark-env.sh.template
20+
log4j-defaults.properties
21+
sorttable.js
22+
.*txt
23+
.*data
24+
.*log
25+
cloudpickle.py
26+
join.py
27+
SparkExprTyper.scala
28+
SparkILoop.scala
29+
SparkILoopInit.scala
30+
SparkIMain.scala
31+
SparkImports.scala
32+
SparkJLineCompletion.scala
33+
SparkJLineReader.scala
34+
SparkMemberHandlers.scala
35+
sbt
36+
sbt-launch-lib.bash
37+
plugins.sbt
38+
work
39+
.*\.q
40+
golden
41+
test.out/*
42+
.*iml

.travis.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
language: scala
17+
scala:
18+
- "2.10.3"
19+
jdk:
20+
- oraclejdk7
21+
env:
22+
matrix:
23+
- TEST="scalastyle assembly/assembly"
24+
- TEST="catalyst/test sql/test streaming/test mllib/test graphx/test bagel/test"
25+
- TEST=hive/test
26+
cache:
27+
directories:
28+
- $HOME/.m2
29+
- $HOME/.ivy2
30+
- $HOME/.sbt
31+
script:
32+
- "sbt ++$TRAVIS_SCALA_VERSION $TEST"

NOTICE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,12 @@ Copyright 2014 The Apache Software Foundation.
33

44
This product includes software developed at
55
The Apache Software Foundation (http://www.apache.org/).
6+
7+
In addition, this product includes:
8+
9+
- JUnit (http://www.junit.org) is a testing framework for Java. We included it
10+
under the terms of the Eclipse Public License v1.0.
11+
12+
- JTransforms (https://sites.google.com/site/piotrwendykier/software/jtransforms)
13+
provides fast transforms in Java. It is tri-licensed, and we included it under
14+
the terms of the Mozilla Public License v1.1.

assembly/pom.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
<artifactId>spark-graphx_${scala.binary.version}</artifactId>
8080
<version>${project.version}</version>
8181
</dependency>
82+
<dependency>
83+
<groupId>org.apache.spark</groupId>
84+
<artifactId>spark-sql_${scala.binary.version}</artifactId>
85+
<version>${project.version}</version>
86+
</dependency>
8287
<dependency>
8388
<groupId>net.sf.py4j</groupId>
8489
<artifactId>py4j</artifactId>
@@ -158,6 +163,16 @@
158163
</dependency>
159164
</dependencies>
160165
</profile>
166+
<profile>
167+
<id>hive</id>
168+
<dependencies>
169+
<dependency>
170+
<groupId>org.apache.spark</groupId>
171+
<artifactId>spark-hive_${scala.binary.version}</artifactId>
172+
<version>${project.version}</version>
173+
</dependency>
174+
</dependencies>
175+
</profile>
161176
<profile>
162177
<id>spark-ganglia-lgpl</id>
163178
<dependencies>
@@ -203,7 +218,7 @@
203218
<plugin>
204219
<groupId>org.codehaus.mojo</groupId>
205220
<artifactId>buildnumber-maven-plugin</artifactId>
206-
<version>1.1</version>
221+
<version>1.2</version>
207222
<executions>
208223
<execution>
209224
<phase>validate</phase>

bagel/src/main/scala/org/apache/spark/bagel/Bagel.scala

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,27 +220,31 @@ object Bagel extends Logging {
220220
*/
221221
private def comp[K: Manifest, V <: Vertex, M <: Message[K], C](
222222
sc: SparkContext,
223-
grouped: RDD[(K, (Seq[C], Seq[V]))],
223+
grouped: RDD[(K, (Iterable[C], Iterable[V]))],
224224
compute: (V, Option[C]) => (V, Array[M]),
225225
storageLevel: StorageLevel
226226
): (RDD[(K, (V, Array[M]))], Int, Int) = {
227227
var numMsgs = sc.accumulator(0)
228228
var numActiveVerts = sc.accumulator(0)
229-
val processed = grouped.flatMapValues {
230-
case (_, vs) if vs.size == 0 => None
231-
case (c, vs) =>
229+
val processed = grouped.mapValues(x => (x._1.iterator, x._2.iterator))
230+
.flatMapValues {
231+
case (_, vs) if !vs.hasNext => None
232+
case (c, vs) => {
232233
val (newVert, newMsgs) =
233-
compute(vs(0), c match {
234-
case Seq(comb) => Some(comb)
235-
case Seq() => None
236-
})
234+
compute(vs.next,
235+
c.hasNext match {
236+
case true => Some(c.next)
237+
case false => None
238+
}
239+
)
237240

238241
numMsgs += newMsgs.size
239242
if (newVert.active) {
240243
numActiveVerts += 1
241244
}
242245

243246
Some((newVert, newMsgs))
247+
}
244248
}.persist(storageLevel)
245249

246250
// Force evaluation of processed RDD for accurate performance measurements

bin/compute-classpath.sh

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,55 @@ SCALA_VERSION=2.10
2525
# Figure out where Spark is installed
2626
FWDIR="$(cd `dirname $0`/..; pwd)"
2727

28-
# Load environment variables from conf/spark-env.sh, if it exists
29-
if [ -e "$FWDIR/conf/spark-env.sh" ] ; then
30-
. $FWDIR/conf/spark-env.sh
31-
fi
28+
. $FWDIR/bin/load-spark-env.sh
3229

3330
# Build up classpath
3431
CLASSPATH="$SPARK_CLASSPATH:$FWDIR/conf"
3532

33+
ASSEMBLY_DIR="$FWDIR/assembly/target/scala-$SCALA_VERSION"
34+
3635
# First check if we have a dependencies jar. If so, include binary classes with the deps jar
37-
if [ -f "$FWDIR"/assembly/target/scala-$SCALA_VERSION/spark-assembly*hadoop*-deps.jar ]; then
36+
if [ -f "$ASSEMBLY_DIR"/spark-assembly*hadoop*-deps.jar ]; then
3837
CLASSPATH="$CLASSPATH:$FWDIR/core/target/scala-$SCALA_VERSION/classes"
3938
CLASSPATH="$CLASSPATH:$FWDIR/repl/target/scala-$SCALA_VERSION/classes"
4039
CLASSPATH="$CLASSPATH:$FWDIR/mllib/target/scala-$SCALA_VERSION/classes"
4140
CLASSPATH="$CLASSPATH:$FWDIR/bagel/target/scala-$SCALA_VERSION/classes"
4241
CLASSPATH="$CLASSPATH:$FWDIR/graphx/target/scala-$SCALA_VERSION/classes"
4342
CLASSPATH="$CLASSPATH:$FWDIR/streaming/target/scala-$SCALA_VERSION/classes"
43+
CLASSPATH="$CLASSPATH:$FWDIR/tools/target/scala-$SCALA_VERSION/classes"
44+
CLASSPATH="$CLASSPATH:$FWDIR/sql/catalyst/target/scala-$SCALA_VERSION/classes"
45+
CLASSPATH="$CLASSPATH:$FWDIR/sql/core/target/scala-$SCALA_VERSION/classes"
46+
CLASSPATH="$CLASSPATH:$FWDIR/sql/hive/target/scala-$SCALA_VERSION/classes"
4447

45-
DEPS_ASSEMBLY_JAR=`ls "$FWDIR"/assembly/target/scala-$SCALA_VERSION/spark-assembly*hadoop*-deps.jar`
48+
DEPS_ASSEMBLY_JAR=`ls "$ASSEMBLY_DIR"/spark-assembly*hadoop*-deps.jar`
4649
CLASSPATH="$CLASSPATH:$DEPS_ASSEMBLY_JAR"
4750
else
4851
# Else use spark-assembly jar from either RELEASE or assembly directory
4952
if [ -f "$FWDIR/RELEASE" ]; then
50-
ASSEMBLY_JAR=`ls "$FWDIR"/jars/spark-assembly*.jar`
53+
ASSEMBLY_JAR=`ls "$FWDIR"/jars/spark*-assembly*.jar`
5154
else
52-
ASSEMBLY_JAR=`ls "$FWDIR"/assembly/target/scala-$SCALA_VERSION/spark-assembly*hadoop*.jar`
55+
ASSEMBLY_JAR=`ls "$ASSEMBLY_DIR"/spark*-assembly*hadoop*.jar`
5356
fi
5457
CLASSPATH="$CLASSPATH:$ASSEMBLY_JAR"
5558
fi
5659

60+
# When Hive support is needed, Datanucleus jars must be included on the classpath.
61+
# Datanucleus jars do not work if only included in the uber jar as plugin.xml metadata is lost.
62+
# Both sbt and maven will populate "lib_managed/jars/" with the datanucleus jars when Spark is
63+
# built with Hive, so first check if the datanucleus jars exist, and then ensure the current Spark
64+
# assembly is built for Hive, before actually populating the CLASSPATH with the jars.
65+
# Note that this check order is faster (by up to half a second) in the case where Hive is not used.
66+
num_datanucleus_jars=$(ls "$FWDIR"/lib_managed/jars/ 2>/dev/null | grep "datanucleus-.*\\.jar" | wc -l)
67+
if [ $num_datanucleus_jars -gt 0 ]; then
68+
AN_ASSEMBLY_JAR=${ASSEMBLY_JAR:-$DEPS_ASSEMBLY_JAR}
69+
num_hive_files=$(jar tvf "$AN_ASSEMBLY_JAR" org/apache/hadoop/hive/ql/exec 2>/dev/null | wc -l)
70+
if [ $num_hive_files -gt 0 ]; then
71+
echo "Spark assembly has been built with Hive, including Datanucleus jars on classpath" 1>&2
72+
DATANUCLEUSJARS=$(echo "$FWDIR/lib_managed/jars"/datanucleus-*.jar | tr " " :)
73+
CLASSPATH=$CLASSPATH:$DATANUCLEUSJARS
74+
fi
75+
fi
76+
5777
# Add test classes if we're running from SBT or Maven with SPARK_TESTING set to 1
5878
if [[ $SPARK_TESTING == 1 ]]; then
5979
CLASSPATH="$CLASSPATH:$FWDIR/core/target/scala-$SCALA_VERSION/test-classes"
@@ -62,6 +82,9 @@ if [[ $SPARK_TESTING == 1 ]]; then
6282
CLASSPATH="$CLASSPATH:$FWDIR/bagel/target/scala-$SCALA_VERSION/test-classes"
6383
CLASSPATH="$CLASSPATH:$FWDIR/graphx/target/scala-$SCALA_VERSION/test-classes"
6484
CLASSPATH="$CLASSPATH:$FWDIR/streaming/target/scala-$SCALA_VERSION/test-classes"
85+
CLASSPATH="$CLASSPATH:$FWDIR/sql/catalyst/target/scala-$SCALA_VERSION/test-classes"
86+
CLASSPATH="$CLASSPATH:$FWDIR/sql/core/target/scala-$SCALA_VERSION/test-classes"
87+
CLASSPATH="$CLASSPATH:$FWDIR/sql/hive/target/scala-$SCALA_VERSION/test-classes"
6588
fi
6689

6790
# Add hadoop conf dir if given -- otherwise FileSystem.*, etc fail !

bin/load-spark-env.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership.
7+
# The ASF licenses this file to You under the Apache License, Version 2.0
8+
# (the "License"); you may not use this file except in compliance with
9+
# the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
# This script loads spark-env.sh if it exists, and ensures it is only loaded once.
21+
# spark-env.sh is loaded from SPARK_CONF_DIR if set, or within the current directory's
22+
# conf/ subdirectory.
23+
24+
if [ -z "$SPARK_ENV_LOADED" ]; then
25+
export SPARK_ENV_LOADED=1
26+
27+
# Returns the parent of the directory this script lives in.
28+
parent_dir="$(cd `dirname $0`/..; pwd)"
29+
30+
use_conf_dir=${SPARK_CONF_DIR:-"$parent_dir/conf"}
31+
32+
if [ -f "${use_conf_dir}/spark-env.sh" ]; then
33+
# Promote all variable declarations to environment (exported) variables
34+
set -a
35+
. "${use_conf_dir}/spark-env.sh"
36+
set +a
37+
fi
38+
fi

bin/pyspark

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ if [ ! -f "$FWDIR/RELEASE" ]; then
3636
fi
3737
fi
3838

39-
# Load environment variables from conf/spark-env.sh, if it exists
40-
if [ -e "$FWDIR/conf/spark-env.sh" ] ; then
41-
. $FWDIR/conf/spark-env.sh
42-
fi
39+
. $FWDIR/bin/load-spark-env.sh
4340

4441
# Figure out which Python executable to use
4542
if [ -z "$PYSPARK_PYTHON" ] ; then
@@ -58,7 +55,8 @@ if [ -n "$IPYTHON_OPTS" ]; then
5855
IPYTHON=1
5956
fi
6057

61-
if [[ "$IPYTHON" = "1" ]] ; then
58+
# Only use ipython if no command line arguments were provided [SPARK-1134]
59+
if [[ "$IPYTHON" = "1" && $# = 0 ]] ; then
6260
exec ipython $IPYTHON_OPTS
6361
else
6462
exec "$PYSPARK_PYTHON" "$@"

bin/run-example

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ FWDIR="$(cd `dirname $0`/..; pwd)"
3030
# Export this as SPARK_HOME
3131
export SPARK_HOME="$FWDIR"
3232

33-
# Load environment variables from conf/spark-env.sh, if it exists
34-
if [ -e "$FWDIR/conf/spark-env.sh" ] ; then
35-
. $FWDIR/conf/spark-env.sh
36-
fi
33+
. $FWDIR/bin/load-spark-env.sh
3734

3835
if [ -z "$1" ]; then
3936
echo "Usage: run-example <example-class> [<args>]" >&2

0 commit comments

Comments
 (0)