spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mengxr <...@git.apache.org>
Subject [GitHub] spark pull request #22328: [SPARK-22666][ML][SQL] Spark datasource for image...
Date Tue, 04 Sep 2018 16:27:04 GMT
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22328#discussion_r214981991
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/source/image/ImageFileFormat.scala
---
    @@ -0,0 +1,109 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.ml.source.image
    +
    +import com.google.common.io.{ByteStreams, Closeables}
    +import org.apache.hadoop.conf.Configuration
    +import org.apache.hadoop.fs.{FileStatus, Path}
    +import org.apache.hadoop.mapreduce.Job
    +
    +import org.apache.spark.ml.image.ImageSchema
    +import org.apache.spark.sql.SparkSession
    +import org.apache.spark.sql.catalyst.InternalRow
    +import org.apache.spark.sql.catalyst.encoders.RowEncoder
    +import org.apache.spark.sql.catalyst.expressions.{AttributeReference, UnsafeRow}
    +import org.apache.spark.sql.catalyst.util.CaseInsensitiveMap
    +import org.apache.spark.sql.execution.datasources.{DataSource, FileFormat, OutputWriterFactory,
PartitionedFile}
    +import org.apache.spark.sql.sources.{DataSourceRegister, Filter}
    +import org.apache.spark.sql.types.StructType
    +import org.apache.spark.util.SerializableConfiguration
    +
    +
    +private[image] class ImageFileFormatOptions(
    +    @transient private val parameters: CaseInsensitiveMap[String]) extends Serializable
{
    +
    +  def this(parameters: Map[String, String]) = this(CaseInsensitiveMap(parameters))
    +
    +  val dropImageFailures = parameters.getOrElse("dropImageFailures", "false").toBoolean
    +}
    +
    +private[image] class ImageFileFormat extends FileFormat with DataSourceRegister {
    +
    +  override def inferSchema(
    +      sparkSession: SparkSession,
    +      options: Map[String, String],
    +      files: Seq[FileStatus]): Option[StructType] = Some(ImageSchema.imageSchema)
    +
    +  override def prepareWrite(
    +      sparkSession: SparkSession,
    +      job: Job, options: Map[String, String],
    +      dataSchema: StructType): OutputWriterFactory = {
    +    throw new UnsupportedOperationException(
    +      s"prepareWrite is not supported for image data source")
    +  }
    +
    +  override def shortName(): String = "image"
    +
    +  override protected def buildReader(
    +      sparkSession: SparkSession,
    +      dataSchema: StructType,
    +      partitionSchema: StructType,
    +      requiredSchema: StructType,
    +      filters: Seq[Filter],
    +      options: Map[String, String],
    +      hadoopConf: Configuration): (PartitionedFile) => Iterator[InternalRow] = {
    --- End diff --
    
    It won't be addressed in this PR. The best way to support it is to allow data source handle
sampling operation. cc @cloud-fan 


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message