Skip to content

Commit 2b46c4b

Browse files
committed
Merge remote-tracking branch 'origin/master' into countDistinctPartial
2 parents 8ff6402 + 217b5e9 commit 2b46c4b

Some content is hidden

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

42 files changed

+818
-79
lines changed

.travis.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

core/src/main/scala/org/apache/spark/scheduler/EventLoggingListener.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ private[spark] class EventLoggingListener(
5454
private val testing = sparkConf.getBoolean("spark.eventLog.testing", false)
5555
private val outputBufferSize = sparkConf.getInt("spark.eventLog.buffer.kb", 100) * 1024
5656
private val logBaseDir = sparkConf.get("spark.eventLog.dir", DEFAULT_LOG_DIR).stripSuffix("/")
57-
private val name = appName.replaceAll("[ :/]", "-").toLowerCase + "-" + System.currentTimeMillis
57+
private val name = appName.replaceAll("[ :/]", "-").replaceAll("[${}'\"]", "_")
58+
.toLowerCase + "-" + System.currentTimeMillis
5859
val logDir = Utils.resolveURI(logBaseDir) + "/" + name.stripSuffix("/")
5960

6061
protected val logger = new FileLogger(logDir, sparkConf, hadoopConf, outputBufferSize,

examples/src/main/python/als.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,5 @@ def update(i, vec, mat, ratings):
9797
error = rmse(R, ms, us)
9898
print "Iteration %d:" % i
9999
print "\nRMSE: %5.4f\n" % error
100+
101+
sc.stop()

examples/src/main/python/cassandra_inputformat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,5 @@
7777
output = cass_rdd.collect()
7878
for (k, v) in output:
7979
print (k, v)
80+
81+
sc.stop()

examples/src/main/python/cassandra_outputformat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,5 @@
8181
conf=conf,
8282
keyConverter="org.apache.spark.examples.pythonconverters.ToCassandraCQLKeyConverter",
8383
valueConverter="org.apache.spark.examples.pythonconverters.ToCassandraCQLValueConverter")
84+
85+
sc.stop()

examples/src/main/python/hbase_inputformat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,5 @@
7171
output = hbase_rdd.collect()
7272
for (k, v) in output:
7373
print (k, v)
74+
75+
sc.stop()

examples/src/main/python/hbase_outputformat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@
6363
conf=conf,
6464
keyConverter="org.apache.spark.examples.pythonconverters.StringToImmutableBytesWritableConverter",
6565
valueConverter="org.apache.spark.examples.pythonconverters.StringListToPutConverter")
66+
67+
sc.stop()

examples/src/main/python/kmeans.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,5 @@ def closestPoint(p, centers):
7777
kPoints[x] = y
7878

7979
print "Final centers: " + str(kPoints)
80+
81+
sc.stop()

examples/src/main/python/logistic_regression.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,5 @@ def add(x, y):
8080
w -= points.map(lambda m: gradient(m, w)).reduce(add)
8181

8282
print "Final w: " + str(w)
83+
84+
sc.stop()
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
"""
19+
Correlations using MLlib.
20+
"""
21+
22+
import sys
23+
24+
from pyspark import SparkContext
25+
from pyspark.mllib.regression import LabeledPoint
26+
from pyspark.mllib.stat import Statistics
27+
from pyspark.mllib.util import MLUtils
28+
29+
30+
if __name__ == "__main__":
31+
if len(sys.argv) not in [1,2]:
32+
print >> sys.stderr, "Usage: correlations (<file>)"
33+
exit(-1)
34+
sc = SparkContext(appName="PythonCorrelations")
35+
if len(sys.argv) == 2:
36+
filepath = sys.argv[1]
37+
else:
38+
filepath = 'data/mllib/sample_linear_regression_data.txt'
39+
corrType = 'pearson'
40+
41+
points = MLUtils.loadLibSVMFile(sc, filepath)\
42+
.map(lambda lp: LabeledPoint(lp.label, lp.features.toArray()))
43+
44+
print
45+
print 'Summary of data file: ' + filepath
46+
print '%d data points' % points.count()
47+
48+
# Statistics (correlations)
49+
print
50+
print 'Correlation (%s) between label and each feature' % corrType
51+
print 'Feature\tCorrelation'
52+
numFeatures = points.take(1)[0].features.size
53+
labelRDD = points.map(lambda lp: lp.label)
54+
for i in range(numFeatures):
55+
featureRDD = points.map(lambda lp: lp.features[i])
56+
corr = Statistics.corr(labelRDD, featureRDD, corrType)
57+
print '%d\t%g' % (i, corr)
58+
print
59+
60+
sc.stop()

0 commit comments

Comments
 (0)