diff options
author | Cheng Lian <lian@databricks.com> | 2016-03-31 23:46:08 -0700 |
---|---|---|
committer | Xiangrui Meng <meng@databricks.com> | 2016-03-31 23:46:08 -0700 |
commit | 1b070637fa03ab4966f76427b15e433050eaa956 (patch) | |
tree | 9c9fcf5c50e2306d36c829c9e35f13d5ae533b35 /project | |
parent | 96941b12f8b465df21423275f3cd3ade579b4fa1 (diff) | |
download | spark-1b070637fa03ab4966f76427b15e433050eaa956.tar.gz spark-1b070637fa03ab4966f76427b15e433050eaa956.tar.bz2 spark-1b070637fa03ab4966f76427b15e433050eaa956.zip |
[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 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.
One unaddressed problem is that, when `numFeatures` is absent, now the input data will be scanned twice. The `buildInternalScan()` code path doesn't need to do this because it caches the raw parsed RDD in memory before computing the total number of features. However, with `FileScanRDD`, the raw parsed RDD is created in a different way (e.g. partitioning) from the final RDD.
## How was this patch tested?
Tested using existing test suites.
Author: Cheng Lian <lian@databricks.com>
Closes #12088 from liancheng/spark-14295-libsvm-build-reader.
Diffstat (limited to 'project')
0 files changed, 0 insertions, 0 deletions