GitHub user liancheng opened a pull request:

    https://github.com/apache/spark/pull/12088

    [SPARK-14295][SPARK-14274][SQL] Implements buildReader() for LibSVM

    ## What changes were proposed in this pull request?
    
    This PR implements `FileFormat.buildReader()` for the LibSVM data source. 
Besides that, a new interface method `prepareRead()` is added to `FileFormat`:
    
    ```scala
      def prepareRead(
          sqlContext: SQLContext,
          options: Map[String, String],
          files: Seq[FileStatus]): Map[String, String] = options
    ```
    
    After migrating from `buildInternalScan()` to `buildReader()`, we lost the 
opportunity to collect necessary global information, since `buildReader()` 
works in a per-partition manner. For example, LibSVM needs to infer the total 
number of features if the `numFeatures` data source option is not set. Any 
necessary collected global information should be returned using the data source 
options map. By default, this method just returns the original options 
untouched.
    
    An alternative approach is to combine absorb `inferSchema()` into 
`prepareRead()`, since schema inference is also some kind of global information 
gathering. However, this approach wasn't chosen because schema inference is 
optional, while `prepareRead()` must be called whenever a `HadoopFsRelation` 
based data source relation is instantiated.
    
    ## How was this patch tested?
    
    Tested using existing test suites.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/liancheng/spark 
spark-14295-libsvm-build-reader

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/12088.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #12088
    
----
commit 64c3efba2bb76f461466ba95109b48428d5f3698
Author: Cheng Lian <[email protected]>
Date:   2016-03-31T14:19:41Z

    Implements buildReader() for LibSVM

----


---
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]

Reply via email to