Skip to content

Commit bc46fc8

Browse files
committed
Merge github.com:apache/spark
2 parents e2f4ff9 + 1440154 commit bc46fc8

File tree

89 files changed

+1685
-388
lines changed

Some content is hidden

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

89 files changed

+1685
-388
lines changed

.rat-excludes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ work
3939
.*\.q
4040
golden
4141
test.out/*
42+
.*iml

assembly/pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@
163163
</dependency>
164164
</dependencies>
165165
</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>
166176
<profile>
167177
<id>spark-ganglia-lgpl</id>
168178
<dependencies>
@@ -208,7 +218,7 @@
208218
<plugin>
209219
<groupId>org.codehaus.mojo</groupId>
210220
<artifactId>buildnumber-maven-plugin</artifactId>
211-
<version>1.1</version>
221+
<version>1.2</version>
212222
<executions>
213223
<execution>
214224
<phase>validate</phase>

bin/compute-classpath.sh

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,7 @@ FWDIR="$(cd `dirname $0`/..; pwd)"
3030
# Build up classpath
3131
CLASSPATH="$SPARK_CLASSPATH:$FWDIR/conf"
3232

33-
# Support for interacting with Hive. Since hive pulls in a lot of dependencies that might break
34-
# existing Spark applications, it is not included in the standard spark assembly. Instead, we only
35-
# include it in the classpath if the user has explicitly requested it by running "sbt hive/assembly"
36-
# Hopefully we will find a way to avoid uber-jars entirely and deploy only the needed packages in
37-
# the future.
38-
if [ -f "$FWDIR"/sql/hive/target/scala-$SCALA_VERSION/spark-hive-assembly-*.jar ]; then
39-
40-
# Datanucleus jars do not work if only included in the uberjar as plugin.xml metadata is lost.
41-
DATANUCLEUSJARS=$(JARS=("$FWDIR/lib_managed/jars"/datanucleus-*.jar); IFS=:; echo "${JARS[*]}")
42-
CLASSPATH=$CLASSPATH:$DATANUCLEUSJARS
43-
44-
ASSEMBLY_DIR="$FWDIR/sql/hive/target/scala-$SCALA_VERSION/"
45-
else
46-
ASSEMBLY_DIR="$FWDIR/assembly/target/scala-$SCALA_VERSION/"
47-
fi
33+
ASSEMBLY_DIR="$FWDIR/assembly/target/scala-$SCALA_VERSION"
4834

4935
# First check if we have a dependencies jar. If so, include binary classes with the deps jar
5036
if [ -f "$ASSEMBLY_DIR"/spark-assembly*hadoop*-deps.jar ]; then
@@ -59,7 +45,7 @@ if [ -f "$ASSEMBLY_DIR"/spark-assembly*hadoop*-deps.jar ]; then
5945
CLASSPATH="$CLASSPATH:$FWDIR/sql/core/target/scala-$SCALA_VERSION/classes"
6046
CLASSPATH="$CLASSPATH:$FWDIR/sql/hive/target/scala-$SCALA_VERSION/classes"
6147

62-
DEPS_ASSEMBLY_JAR=`ls "$ASSEMBLY_DIR"/spark*-assembly*hadoop*-deps.jar`
48+
DEPS_ASSEMBLY_JAR=`ls "$ASSEMBLY_DIR"/spark-assembly*hadoop*-deps.jar`
6349
CLASSPATH="$CLASSPATH:$DEPS_ASSEMBLY_JAR"
6450
else
6551
# Else use spark-assembly jar from either RELEASE or assembly directory
@@ -71,6 +57,23 @@ else
7157
CLASSPATH="$CLASSPATH:$ASSEMBLY_JAR"
7258
fi
7359

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/ | 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+
7477
# Add test classes if we're running from SBT or Maven with SPARK_TESTING set to 1
7578
if [[ $SPARK_TESTING == 1 ]]; then
7679
CLASSPATH="$CLASSPATH:$FWDIR/core/target/scala-$SCALA_VERSION/test-classes"

bin/spark-class

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,3 @@ if [ "$SPARK_PRINT_LAUNCH_COMMAND" == "1" ]; then
154154
fi
155155

156156
exec "$RUNNER" -cp "$CLASSPATH" $JAVA_OPTS "$@"
157-
158-

core/pom.xml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,10 @@
117117
<dependency>
118118
<groupId>com.twitter</groupId>
119119
<artifactId>chill_${scala.binary.version}</artifactId>
120-
<version>0.3.1</version>
121120
</dependency>
122121
<dependency>
123122
<groupId>com.twitter</groupId>
124123
<artifactId>chill-java</artifactId>
125-
<version>0.3.1</version>
126124
</dependency>
127125
<dependency>
128126
<groupId>commons-net</groupId>
@@ -200,6 +198,53 @@
200198
<artifactId>derby</artifactId>
201199
<scope>test</scope>
202200
</dependency>
201+
<dependency>
202+
<groupId>org.tachyonproject</groupId>
203+
<artifactId>tachyon</artifactId>
204+
<version>0.4.1-thrift</version>
205+
<exclusions>
206+
<exclusion>
207+
<groupId>org.apache.hadoop</groupId>
208+
<artifactId>hadoop-client</artifactId>
209+
</exclusion>
210+
<exclusion>
211+
<groupId>org.apache.curator</groupId>
212+
<artifactId>curator-recipes</artifactId>
213+
</exclusion>
214+
<exclusion>
215+
<groupId>org.eclipse.jetty</groupId>
216+
<artifactId>jetty-jsp</artifactId>
217+
</exclusion>
218+
<exclusion>
219+
<groupId>org.eclipse.jetty</groupId>
220+
<artifactId>jetty-webapp</artifactId>
221+
</exclusion>
222+
<exclusion>
223+
<groupId>org.eclipse.jetty</groupId>
224+
<artifactId>jetty-server</artifactId>
225+
</exclusion>
226+
<exclusion>
227+
<groupId>org.eclipse.jetty</groupId>
228+
<artifactId>jetty-servlet</artifactId>
229+
</exclusion>
230+
<exclusion>
231+
<groupId>junit</groupId>
232+
<artifactId>junit</artifactId>
233+
</exclusion>
234+
<exclusion>
235+
<groupId>org.powermock</groupId>
236+
<artifactId>powermock-module-junit4</artifactId>
237+
</exclusion>
238+
<exclusion>
239+
<groupId>org.powermock</groupId>
240+
<artifactId>powermock-api-mockito</artifactId>
241+
</exclusion>
242+
<exclusion>
243+
<groupId>org.apache.curator</groupId>
244+
<artifactId>curator-test</artifactId>
245+
</exclusion>
246+
</exclusions>
247+
</dependency>
203248
<dependency>
204249
<groupId>org.scalatest</groupId>
205250
<artifactId>scalatest_${scala.binary.version}</artifactId>

core/src/main/java/org/apache/spark/api/java/StorageLevels.java

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,18 @@
2323
* Expose some commonly useful storage level constants.
2424
*/
2525
public class StorageLevels {
26-
public static final StorageLevel NONE = create(false, false, false, 1);
27-
public static final StorageLevel DISK_ONLY = create(true, false, false, 1);
28-
public static final StorageLevel DISK_ONLY_2 = create(true, false, false, 2);
29-
public static final StorageLevel MEMORY_ONLY = create(false, true, true, 1);
30-
public static final StorageLevel MEMORY_ONLY_2 = create(false, true, true, 2);
31-
public static final StorageLevel MEMORY_ONLY_SER = create(false, true, false, 1);
32-
public static final StorageLevel MEMORY_ONLY_SER_2 = create(false, true, false, 2);
33-
public static final StorageLevel MEMORY_AND_DISK = create(true, true, true, 1);
34-
public static final StorageLevel MEMORY_AND_DISK_2 = create(true, true, true, 2);
35-
public static final StorageLevel MEMORY_AND_DISK_SER = create(true, true, false, 1);
36-
public static final StorageLevel MEMORY_AND_DISK_SER_2 = create(true, true, false, 2);
26+
public static final StorageLevel NONE = create(false, false, false, false, 1);
27+
public static final StorageLevel DISK_ONLY = create(true, false, false, false, 1);
28+
public static final StorageLevel DISK_ONLY_2 = create(true, false, false, false, 2);
29+
public static final StorageLevel MEMORY_ONLY = create(false, true, false, true, 1);
30+
public static final StorageLevel MEMORY_ONLY_2 = create(false, true, false, true, 2);
31+
public static final StorageLevel MEMORY_ONLY_SER = create(false, true, false, false, 1);
32+
public static final StorageLevel MEMORY_ONLY_SER_2 = create(false, true, false, false, 2);
33+
public static final StorageLevel MEMORY_AND_DISK = create(true, true, false, true, 1);
34+
public static final StorageLevel MEMORY_AND_DISK_2 = create(true, true, false, true, 2);
35+
public static final StorageLevel MEMORY_AND_DISK_SER = create(true, true, false, false, 1);
36+
public static final StorageLevel MEMORY_AND_DISK_SER_2 = create(true, true, false, false, 2);
37+
public static final StorageLevel OFF_HEAP = create(false, false, true, false, 1);
3738

3839
/**
3940
* Create a new StorageLevel object.
@@ -42,7 +43,26 @@ public class StorageLevels {
4243
* @param deserialized saved as deserialized objects, if true
4344
* @param replication replication factor
4445
*/
45-
public static StorageLevel create(boolean useDisk, boolean useMemory, boolean deserialized, int replication) {
46-
return StorageLevel.apply(useDisk, useMemory, deserialized, replication);
46+
@Deprecated
47+
public static StorageLevel create(boolean useDisk, boolean useMemory, boolean deserialized,
48+
int replication) {
49+
return StorageLevel.apply(useDisk, useMemory, false, deserialized, replication);
50+
}
51+
52+
/**
53+
* Create a new StorageLevel object.
54+
* @param useDisk saved to disk, if true
55+
* @param useMemory saved to memory, if true
56+
* @param useOffHeap saved to Tachyon, if true
57+
* @param deserialized saved as deserialized objects, if true
58+
* @param replication replication factor
59+
*/
60+
public static StorageLevel create(
61+
boolean useDisk,
62+
boolean useMemory,
63+
boolean useOffHeap,
64+
boolean deserialized,
65+
int replication) {
66+
return StorageLevel.apply(useDisk, useMemory, useOffHeap, deserialized, replication);
4767
}
4868
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ package org.apache.spark
1919

2020
import java.io._
2121
import java.net.URI
22-
import java.util.{Properties, UUID}
2322
import java.util.concurrent.atomic.AtomicInteger
24-
23+
import java.util.{Properties, UUID}
24+
import java.util.UUID.randomUUID
2525
import scala.collection.{Map, Set}
2626
import scala.collection.generic.Growable
2727
import scala.collection.mutable.{ArrayBuffer, HashMap}
2828
import scala.reflect.{ClassTag, classTag}
29-
3029
import org.apache.hadoop.conf.Configuration
3130
import org.apache.hadoop.fs.Path
3231
import org.apache.hadoop.io.{ArrayWritable, BooleanWritable, BytesWritable, DoubleWritable, FloatWritable, IntWritable, LongWritable, NullWritable, Text, Writable}
@@ -130,6 +129,11 @@ class SparkContext(
130129
val master = conf.get("spark.master")
131130
val appName = conf.get("spark.app.name")
132131

132+
// Generate the random name for a temp folder in Tachyon
133+
// Add a timestamp as the suffix here to make it more safe
134+
val tachyonFolderName = "spark-" + randomUUID.toString()
135+
conf.set("spark.tachyonStore.folderName", tachyonFolderName)
136+
133137
val isLocal = (master == "local" || master.startsWith("local["))
134138

135139
if (master == "yarn-client") System.setProperty("SPARK_YARN_MODE", "true")
@@ -393,7 +397,7 @@ class SparkContext(
393397
* (a-hdfs-path/part-nnnnn, its content)
394398
* }}}
395399
*
396-
* @note Small files are perferred, large file is also allowable, but may cause bad performance.
400+
* @note Small files are preferred, as each file will be loaded fully in memory.
397401
*/
398402
def wholeTextFiles(path: String): RDD[(String, String)] = {
399403
newAPIHadoopFile(
@@ -725,10 +729,6 @@ class SparkContext(
725729
*/
726730
def getPersistentRDDs: Map[Int, RDD[_]] = persistentRdds.toMap
727731

728-
def getStageInfo: Map[Stage, StageInfo] = {
729-
dagScheduler.stageToInfos
730-
}
731-
732732
/**
733733
* Return information about blocks stored in all of the slaves
734734
*/

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

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

1818
package org.apache.spark.api.java
1919

20-
import java.util.{Comparator, List => JList}
20+
import java.util.{Comparator, Iterator => JIterator, List => JList}
21+
import java.lang.{Iterable => JIterable}
2122

2223
import scala.collection.JavaConversions._
2324
import scala.reflect.ClassTag
@@ -280,6 +281,17 @@ trait JavaRDDLike[T, This <: JavaRDDLike[T, This]] extends Serializable {
280281
new java.util.ArrayList(arr)
281282
}
282283

284+
/**
285+
* Return an iterator that contains all of the elements in this RDD.
286+
*
287+
* The iterator will consume as much memory as the largest partition in this RDD.
288+
*/
289+
def toLocalIterator(): JIterator[T] = {
290+
import scala.collection.JavaConversions._
291+
rdd.toLocalIterator
292+
}
293+
294+
283295
/**
284296
* Return an array that contains all of the elements in this RDD.
285297
* @deprecated As of Spark 1.0.0, toArray() is deprecated, use {@link #collect()} instead

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class JavaSparkContext(val sc: SparkContext) extends JavaSparkContextVarargsWork
177177
* (a-hdfs-path/part-nnnnn, its content)
178178
* }}}
179179
*
180-
* @note Small files are perferred, large file is also allowable, but may cause bad performance.
180+
* @note Small files are preferred, as each file will be loaded fully in memory.
181181
*/
182182
def wholeTextFiles(path: String): JavaPairRDD[String, String] =
183183
new JavaPairRDD(sc.wholeTextFiles(path))

core/src/main/scala/org/apache/spark/api/python/PythonRDD.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package org.apache.spark.api.python
1919

2020
import java.io._
2121
import java.net._
22+
import java.nio.charset.Charset
2223
import java.util.{List => JList, ArrayList => JArrayList, Map => JMap, Collections}
2324

2425
import scala.collection.JavaConversions._
@@ -206,6 +207,7 @@ private object SpecialLengths {
206207
}
207208

208209
private[spark] object PythonRDD {
210+
val UTF8 = Charset.forName("UTF-8")
209211

210212
def readRDDFromFile(sc: JavaSparkContext, filename: String, parallelism: Int):
211213
JavaRDD[Array[Byte]] = {
@@ -266,7 +268,7 @@ private[spark] object PythonRDD {
266268
}
267269

268270
def writeUTF(str: String, dataOut: DataOutputStream) {
269-
val bytes = str.getBytes("UTF-8")
271+
val bytes = str.getBytes(UTF8)
270272
dataOut.writeInt(bytes.length)
271273
dataOut.write(bytes)
272274
}
@@ -286,7 +288,7 @@ private[spark] object PythonRDD {
286288

287289
private
288290
class BytesToString extends org.apache.spark.api.java.function.Function[Array[Byte], String] {
289-
override def call(arr: Array[Byte]) : String = new String(arr, "UTF-8")
291+
override def call(arr: Array[Byte]) : String = new String(arr, PythonRDD.UTF8)
290292
}
291293

292294
/**

0 commit comments

Comments
 (0)