Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/9595#discussion_r50187396
--- Diff:
mllib/src/main/scala/org/apache/spark/ml/source/libsvm/LibSVMRelation.scala ---
@@ -99,16 +164,32 @@ private[libsvm] class LibSVMRelation(val path: String,
val numFeatures: Int, val
* @see [[https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/ LIBSVM
datasets]]
*/
@Since("1.6.0")
-class DefaultSource extends RelationProvider with DataSourceRegister {
+class DefaultSource extends HadoopFsRelationProvider with
DataSourceRegister {
@Since("1.6.0")
override def shortName(): String = "libsvm"
+ private def verifySchema(dataSchema: StructType): Unit = {
+ if (dataSchema.size != 2 ||
+ (!dataSchema(0).dataType.sameType(DataTypes.DoubleType)
+ || !dataSchema(1).dataType.sameType(new VectorUDT()))) {
+ throw new IOException(s"Illegal schema for libsvm data,
schema=${dataSchema}")
+ }
+ }
+
@Since("1.6.0")
- override def createRelation(sqlContext: SQLContext, parameters:
Map[String, String])
- : BaseRelation = {
- val path = parameters.getOrElse("path",
- throw new IllegalArgumentException("'path' must be specified"))
+ override def createRelation(sqlContext: SQLContext,
--- End diff --
chop down arguments and use 4-space indentation
---
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]