Github user wagnermarkd commented on a diff in the pull request:
https://github.com/apache/orc/pull/27#discussion_r65271707
--- Diff:
java/mapreduce/src/java/org.apache.orc.mapreduce/OrcInputFormat.java ---
@@ -0,0 +1,95 @@
+/**
+ * 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.orc.mapreduce;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.io.Input;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.ql.io.sarg.SearchArgument;
+import org.apache.hadoop.hive.ql.io.sarg.SearchArgumentImpl;
+import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.mapreduce.InputSplit;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+import org.apache.hadoop.mapreduce.lib.input.FileSplit;
+
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.NullWritable;
+import org.apache.orc.OrcConf;
+import org.apache.orc.OrcFile;
+import org.apache.orc.Reader;
+import org.apache.orc.TypeDescription;
+
+/**
+ * An ORC input format that satisfies the org.apache.hadoop.mapreduce API.
+ */
+public class OrcInputFormat<V extends Writable>
+ extends FileInputFormat<NullWritable, V> {
+
+ /**
+ * Put the given SearchArgument into the configuration for an
OrcInputFormat.
+ * @param conf the configuration to modify
+ * @param sarg the SearchArgument to put in the configuration
+ * @param columnNames the list of column names for the SearchArgument
+ */
+ public static void setSearchArgument(Configuration conf,
+ SearchArgument sarg,
+ String[] columnNames) {
+ org.apache.orc.mapred.OrcInputFormat.setSearchArgument(conf, sarg,
+ columnNames);
+ }
+
+ @Override
+ public RecordReader<NullWritable, V>
+ createRecordReader(InputSplit inputSplit,
+ TaskAttemptContext taskAttemptContext
+ ) throws IOException, InterruptedException {
+ FileSplit split = (FileSplit) inputSplit;
+ Configuration conf = taskAttemptContext.getConfiguration();
+ Reader file = OrcFile.createReader(split.getPath(),
+ OrcFile.readerOptions(conf)
+ .maxLength(OrcConf.MAX_FILE_LENGTH.getLong(conf)));
+ TypeDescription schema =
+ TypeDescription.fromString(OrcConf.SCHEMA.getString(conf));
+ Reader.Options options = new Reader.Options()
+ .range(split.getStart(), split.getLength())
+ .useZeroCopy(OrcConf.USE_ZEROCOPY.getBoolean(conf))
+ .skipCorruptRecords(OrcConf.SKIP_CORRUPT_DATA.getBoolean(conf));
--- End diff --
These two lines seem to duplicate logic in RecordReaderImpl:
https://github.com/apache/orc/blob/7a4fe255e84bea097ca478d2008d257e07f8808a/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java#L184.
As far as I can see that's the only reason conf is passed at all. It could be
cleaner if Reader.Options's constructor pulled the requisite values from the
conf and only stored/exposed those.
---
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.
---