Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/12319#discussion_r60367904
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/orc/OrcRelation.scala ---
@@ -160,19 +160,22 @@ private[sql] class DefaultSource
val job = Job.getInstance(conf)
FileInputFormat.setInputPaths(job, file.filePath)
- val inputFormat = new OrcNewInputFormat
val fileSplit = new FileSplit(
new Path(new URI(file.filePath)), file.start, file.length,
Array.empty
)
-
- val attemptId = new TaskAttemptID(new TaskID(new JobID(),
TaskType.MAP, 0), 0)
- val hadoopAttemptContext = new TaskAttemptContextImpl(conf,
attemptId)
- inputFormat.createRecordReader(fileSplit, hadoopAttemptContext)
+ // Create RecordReader here. This will help in getting
+ // ObjectInspector during recordReader creation itself and can
+ // avoid NN call in unwrapOrcStructs to get ObjectInspector for
the
+ // file. Would be helpful for partitioned datasets.
+ new OrcRecordReader(OrcFile.createReader(new Path(new URI(file
+ .filePath)), OrcFile.readerOptions(conf)), conf,
fileSplit.getStart(),
+ fileSplit.getLength())
}
// Unwraps `OrcStruct`s to `UnsafeRow`s
- val unsafeRowIterator = OrcRelation.unwrapOrcStructs(
- file.filePath, conf, requiredSchema, new
RecordReaderIterator[OrcStruct](orcRecordReader)
+ val unsafeRowIterator = OrcRelation.unwrapOrcStructs(conf,
requiredSchema,
+
Some(orcRecordReader.getObjectInspector.asInstanceOf[StructObjectInspector]),
+ new RecordReaderIterator[OrcStruct](orcRecordReader)
--- End diff --
Nit: Usually we wrap function arguments like this
```scala
func(
arg1, arg2, ...)
```
or
```scala
func(
arg1,
arg2,
...)
```
---
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]