[
https://issues.apache.org/jira/browse/GOBBLIN-1114?focusedWorklogId=420868&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-420868
]
ASF GitHub Bot logged work on GOBBLIN-1114:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 12/Apr/20 02:00
Start Date: 12/Apr/20 02:00
Worklog Time Spent: 10m
Work Description: sv2000 commented on pull request #2954: [GOBBLIN-1114]
OrcValueMapper schema evolution up-conversion recursive
URL: https://github.com/apache/incubator-gobblin/pull/2954#discussion_r407132718
##########
File path:
gobblin-compaction/src/main/java/org/apache/gobblin/compaction/mapreduce/orc/OrcValueMapper.java
##########
@@ -24,58 +24,80 @@
import org.apache.gobblin.compaction.mapreduce.RecordKeyMapperBase;
import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.orc.OrcConf;
import org.apache.orc.TypeDescription;
import org.apache.orc.impl.ConvertTreeReaderFactory;
import org.apache.orc.impl.SchemaEvolution;
import org.apache.orc.mapred.OrcKey;
+import org.apache.orc.mapred.OrcList;
+import org.apache.orc.mapred.OrcMap;
import org.apache.orc.mapred.OrcStruct;
+import org.apache.orc.mapred.OrcUnion;
import org.apache.orc.mapred.OrcValue;
import org.apache.orc.mapreduce.OrcMapreduceRecordReader;
+import com.google.common.annotations.VisibleForTesting;
+
+import lombok.extern.slf4j.Slf4j;
+
/**
* To keep consistent with {@link OrcMapreduceRecordReader}'s decision on
implementing
* {@link RecordReader} with {@link NullWritable} as the key and generic type
of value, the ORC Mapper will
* read in the record as the input value.
*/
+@Slf4j
public class OrcValueMapper extends RecordKeyMapperBase<NullWritable,
OrcStruct, Object, OrcValue> {
private OrcValue outValue;
private TypeDescription mapperSchema;
+ // This is added mostly for debuggability.
+ private static int writeCount = 0;
+
@Override
protected void setup(Context context)
throws IOException, InterruptedException {
super.setup(context);
this.outValue = new OrcValue();
- this.mapperSchema =
TypeDescription.fromString(context.getConfiguration().get(OrcConf.MAPRED_INPUT_SCHEMA.getAttribute()));
+ this.mapperSchema =
+
TypeDescription.fromString(context.getConfiguration().get(OrcConf.MAPRED_INPUT_SCHEMA.getAttribute()));
}
@Override
protected void map(NullWritable key, OrcStruct orcStruct, Context context)
throws IOException, InterruptedException {
- OrcStruct upConvertedStruct = upConvertOrcStruct(orcStruct, context);
- if (context.getNumReduceTasks() == 0) {
- this.outValue.value = upConvertedStruct;
- context.write(NullWritable.get(), this.outValue);
- } else {
- this.outValue.value = upConvertedStruct;
- context.write(getDedupKey(upConvertedStruct), this.outValue);
+ OrcStruct upConvertedStruct = upConvertOrcStruct(orcStruct, mapperSchema);
+ try {
+ if (context.getNumReduceTasks() == 0) {
+ this.outValue.value = upConvertedStruct;
+ context.write(NullWritable.get(), this.outValue);
+ } else {
+ this.outValue.value = upConvertedStruct;
+ context.write(getDedupKey(upConvertedStruct), this.outValue);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException("Failure in write record no." + writeCount,
e);
}
+ writeCount += 1;
context.getCounter(EVENT_COUNTER.RECORD_COUNT).increment(1);
}
/**
- * If a {@link OrcStruct}'s schema differs from newest schema obtained when
creating MR jobs (which is the
- * newest schema seen by the MR job), all the other ORC object will need to
be up-converted.
+ * Up convert the {@link OrcStruct} towards {@link #mapperSchema}
recursively.
Review comment:
This comment can be improved. Do you mean to say "Recursively up convert the
{@link OrcStruct} into {@link mapperSchema}"?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 420868)
Time Spent: 1h 40m (was: 1.5h)
> ORC-mapred schema evolution enhancement
> ---------------------------------------
>
> Key: GOBBLIN-1114
> URL: https://issues.apache.org/jira/browse/GOBBLIN-1114
> Project: Apache Gobblin
> Issue Type: Improvement
> Reporter: Lei Sun
> Priority: Major
> Time Spent: 1h 40m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)