Github user joan38 commented on a diff in the pull request:
https://github.com/apache/spark/pull/11772#discussion_r56422280
--- Diff: mllib/src/main/scala/org/apache/spark/ml/util/ReadWrite.scala ---
@@ -282,7 +282,10 @@ private[ml] object DefaultParamsReader {
*/
def loadMetadata(path: String, sc: SparkContext, expectedClassName:
String = ""): Metadata = {
val metadataPath = new Path(path, "metadata").toString
- val metadataStr = sc.textFile(metadataPath, 1).first()
+ val metadataStr = try sc.textFile(metadataPath, 1).first() catch {
+ case _: UnsupportedOperationException =>
+ throw new IllegalArgumentException(s"Empty metadata for path
$path")
+ }
--- End diff --
Or
```scala
val textFile = sc.textFile(metadataPath, 1)
if (textFile.isEmpty()) throw new IllegalArgumentException(s"Empty
metadata for path $path")
val metadataStr = textFile.first()
```
But I thought calling twice `take(1)` threw `isEmpty()` and `first()` would
be a waist.
---
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]