tprelle commented on a change in pull request #3242:
URL: https://github.com/apache/iceberg/pull/3242#discussion_r729071321
##########
File path:
mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergInputFormat.java
##########
@@ -100,23 +101,39 @@
.toArray(InputSplit[]::new);
}
+ // Need for testing
+ protected void checkHive3Present() {
+ Preconditions.checkArgument(MetastoreUtil.hive3PresentOnClasspath(),
"Vectorization only supported for Hive 3+");
+ }
+
+ protected RecordReader<Void, Container<Record>>
getVectorizedRecordReader(IcebergSplit icebergSplit,
+
JobConf job,
+
Reporter reporter) {
+ return (RecordReader) HIVE_VECTORIZED_RECORDREADER_CTOR.newInstance(
+ new org.apache.iceberg.mr.mapreduce.IcebergInputFormat<>(),
+ icebergSplit,
+ job,
+ reporter);
+ }
+
@Override
public RecordReader<Void, Container<Record>> getRecordReader(InputSplit
split, JobConf job,
Reporter
reporter) throws IOException {
String[] selectedColumns = ColumnProjectionUtils.getReadColumnNames(job);
job.setStrings(InputFormatConfig.SELECTED_COLUMNS, selectedColumns);
-
- if (HiveConf.getBoolVar(job,
HiveConf.ConfVars.HIVE_VECTORIZATION_ENABLED)) {
- Preconditions.checkArgument(MetastoreUtil.hive3PresentOnClasspath(),
"Vectorization only supported for Hive 3+");
-
+ // Testing if vectorization was enabled and ok for hive
+ if (HiveConf.getBoolVar(job, HiveConf.ConfVars.HIVE_VECTORIZATION_ENABLED)
&&
+ Utilities.getVectorizedRowBatchCtx(job) != null) {
+ checkHive3Present();
IcebergSplit icebergSplit = ((IcebergSplitContainer)
split).icebergSplit();
// bogus cast for favouring code reuse over syntax
- return (RecordReader) HIVE_VECTORIZED_RECORDREADER_CTOR.newInstance(
- new org.apache.iceberg.mr.mapreduce.IcebergInputFormat<>(),
+ return getVectorizedRecordReader(
icebergSplit,
job,
reporter);
} else {
+ // Forcing IN_MEMORY_DATA_MODEL to generic in case that vectorization
can not be performed by hive
+ job.setEnum(InputFormatConfig.IN_MEMORY_DATA_MODEL,
InputFormatConfig.InMemoryDataModel.GENERIC);
Review comment:
fix thanks for the review @szlta
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]