forked from byzer-org/byzer-lang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request byzer-org#236 from allwefantasy/mlsql
添加加载图片类
- Loading branch information
Showing
5 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...ingpro-opencv/src/main/java/streaming/dsl/mmlib/algs/processing/image/DefaultSource.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package streaming.dsl.mmlib.algs.processing.image | ||
|
||
import org.apache.spark.internal.Logging | ||
import org.apache.spark.rdd.RDD | ||
import org.apache.spark.sql.{SQLContext, SaveMode, _} | ||
import org.apache.spark.sql.sources._ | ||
import org.apache.spark.sql.types.StructType | ||
|
||
/** | ||
* Created by allwefantasy on 29/5/2018. | ||
*/ | ||
class DefaultSource extends RelationProvider with CreatableRelationProvider with DataSourceRegister { | ||
override def createRelation(sqlContext: SQLContext, parameters: Map[String, String]): BaseRelation = { | ||
ImageRelation(parameters, None)(sqlContext) | ||
} | ||
|
||
override def createRelation(sqlContext: SQLContext, mode: SaveMode, parameters: Map[String, String], data: DataFrame): BaseRelation = { | ||
null | ||
} | ||
|
||
override def shortName(): String = "Image" | ||
} | ||
|
||
case class ImageRelation( | ||
parameters: Map[String, String], | ||
userSpecifiedschema: Option[StructType] | ||
)(@transient val sqlContext: SQLContext) | ||
extends BaseRelation with TableScan with Logging { | ||
override def schema: StructType = ImageSchema.imageDFSchema | ||
|
||
override def buildScan(): RDD[Row] = { | ||
val path = parameters("path") | ||
val recursive = parameters.getOrElse("recursive", "false").toBoolean | ||
val dropImageFailures = parameters.getOrElse("dropImageFailures", "false").toBoolean | ||
val sampleRatio = parameters.getOrElse("sampleRatio", "1.0").toDouble | ||
val spark = sqlContext.sparkSession | ||
ImageSchema.readImages(path = path, sparkSession = spark, recursive = recursive, sampleRatio = sampleRatio, dropImageFailures = dropImageFailures).rdd | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters