Skip to content

Commit 846f83e

Browse files
committed
Merge branch 'master' of https://github.com/apache/spark into SPARK-6694
2 parents dbe8c63 + e40ea87 commit 846f83e

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

mllib/src/main/scala/org/apache/spark/mllib/linalg/distributed/RowMatrix.scala

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,6 @@ class RowMatrix(
531531
val rand = new XORShiftRandom(indx)
532532
val scaled = new Array[Double](p.size)
533533
iter.flatMap { row =>
534-
val buf = new ListBuffer[((Int, Int), Double)]()
535534
row match {
536535
case SparseVector(size, indices, values) =>
537536
val nnz = indices.size
@@ -540,8 +539,9 @@ class RowMatrix(
540539
scaled(k) = values(k) / q(indices(k))
541540
k += 1
542541
}
543-
k = 0
544-
while (k < nnz) {
542+
543+
Iterator.tabulate (nnz) { k =>
544+
val buf = new ListBuffer[((Int, Int), Double)]()
545545
val i = indices(k)
546546
val iVal = scaled(k)
547547
if (iVal != 0 && rand.nextDouble() < p(i)) {
@@ -555,17 +555,17 @@ class RowMatrix(
555555
l += 1
556556
}
557557
}
558-
k += 1
559-
}
558+
buf
559+
}.flatten
560560
case DenseVector(values) =>
561561
val n = values.size
562562
var i = 0
563563
while (i < n) {
564564
scaled(i) = values(i) / q(i)
565565
i += 1
566566
}
567-
i = 0
568-
while (i < n) {
567+
Iterator.tabulate (n) { i =>
568+
val buf = new ListBuffer[((Int, Int), Double)]()
569569
val iVal = scaled(i)
570570
if (iVal != 0 && rand.nextDouble() < p(i)) {
571571
var j = i + 1
@@ -577,10 +577,9 @@ class RowMatrix(
577577
j += 1
578578
}
579579
}
580-
i += 1
581-
}
580+
buf
581+
}.flatten
582582
}
583-
buf
584583
}
585584
}.reduceByKey(_ + _).map { case ((i, j), sim) =>
586585
MatrixEntry(i.toLong, j.toLong, sim)

sql/core/src/main/scala/org/apache/spark/sql/jdbc/DriverQuirks.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ private[sql] object DriverQuirks {
4949
* Fetch the DriverQuirks class corresponding to a given database url.
5050
*/
5151
def get(url: String): DriverQuirks = {
52-
if (url.substring(0, 10).equals("jdbc:mysql")) {
52+
if (url.startsWith("jdbc:mysql")) {
5353
new MySQLQuirks()
54-
} else if (url.substring(0, 15).equals("jdbc:postgresql")) {
54+
} else if (url.startsWith("jdbc:postgresql")) {
5555
new PostgresQuirks()
5656
} else {
5757
new NoQuirks()

0 commit comments

Comments
 (0)