Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/15148#discussion_r84566599
--- Diff: mllib/src/main/scala/org/apache/spark/ml/feature/LSH.scala ---
@@ -245,50 +246,50 @@ private[ml] abstract class LSHModel[T <: LSHModel[T]]
extends Model[T] with LSHP
datasetA: Dataset[_],
datasetB: Dataset[_],
threshold: Double,
- distCol: String): Dataset[_] = {
+ distCol: String,
+ leftColName: String,
+ rightColName: String): Dataset[_] = {
val explodeCols = Seq("entry", "hashValue")
- val inputName = "input"
- val explodedA = processDataset(datasetA, inputName, explodeCols)
+ val explodedA = processDataset(datasetA, leftColName, explodeCols)
// If this is a self join, we need to recreate the inputCol of
datasetB to avoid ambiguity.
// TODO: Remove recreateCol logic once SPARK-17154 is resolved.
val explodedB = if (datasetA != datasetB) {
- processDataset(datasetB, inputName, explodeCols)
+ processDataset(datasetB, rightColName, explodeCols)
} else {
val recreatedB = recreateCol(datasetB, $(inputCol),
s"${$(inputCol)}#${Random.nextString(5)}")
- processDataset(recreatedB, inputName, explodeCols)
+ processDataset(recreatedB, rightColName, explodeCols)
}
// Do a hash join on where the exploded hash values are equal.
val joinedDataset = explodedA.join(explodedB, explodeCols)
- .drop(explodeCols: _*)
+ .drop(explodeCols: _*).distinct()
// Add a new column to store the distance of the two records.
val distUDF = udf((x: Vector, y: Vector) => keyDistance(x, y),
DataTypes.DoubleType)
val joinedDatasetWithDist = joinedDataset.select(col("*"),
- distUDF(explodedA(s"$inputName.${$(inputCol)}"),
- explodedB(s"$inputName.${$(inputCol)}")).as(distCol)
+ distUDF(col(s"$leftColName.${$(inputCol)}"),
col(s"$rightColName.${$(inputCol)}")).as(distCol)
)
// Filter the joined datasets where the distance are smaller than the
threshold.
- joinedDatasetWithDist.filter(col(distCol) < threshold).distinct()
+ joinedDatasetWithDist.filter(col(distCol) < threshold)
}
/**
- * Overloaded method for approxSimilarityJoin. Use "distCol" as default
distCol.
+ * Overloaded method for approxSimilarityJoin. Use "distCol" as default
distCol, "leftCol" as
--- End diff --
Again, "datasetA" and "datasetB"
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]