From b0ca6a72a2bf69f28d27b54cb8c8ce0d65ebd83a Mon Sep 17 00:00:00 2001 From: Jacob Getto Date: Thu, 2 Nov 2023 10:24:29 -0400 Subject: [PATCH] Expose createRecordWriter components --- .../hadoop/hbase/mapreduce/HFileOutputFormat2.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java index 40c95acfa4ed..17d7fadc6992 100644 --- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java +++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java @@ -87,6 +87,7 @@ import org.apache.hadoop.mapreduce.OutputFormat; import org.apache.hadoop.mapreduce.RecordWriter; import org.apache.hadoop.mapreduce.TaskAttemptContext; +import org.apache.hadoop.mapreduce.TaskAttemptID; import org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.mapreduce.lib.partition.TotalOrderPartitioner; @@ -220,7 +221,12 @@ static RecordWriter createRecordWrit // Get the path of the temporary output file final Path outputDir = ((FileOutputCommitter) committer).getWorkPath(); - final Configuration conf = context.getConfiguration(); + return createRecordWriter(context.getConfiguration(), outputDir, context.getTaskAttemptID()); + } + + protected static RecordWriter createRecordWriter( + final Configuration conf, Path outputDir, TaskAttemptID taskAttemptID) throws IOException { + final boolean writeMultipleTables = conf.getBoolean(MULTI_TABLE_HFILEOUTPUTFORMAT_CONF_KEY, false); final boolean writeToTableWithNamespace = conf.getBoolean( @@ -483,7 +489,7 @@ private WriterLength getNewWriter(byte[] tableName, byte[] family, Configuration private void close(final StoreFileWriter w) throws IOException { if (w != null) { w.appendFileInfo(BULKLOAD_TIME_KEY, Bytes.toBytes(EnvironmentEdgeManager.currentTime())); - w.appendFileInfo(BULKLOAD_TASK_KEY, Bytes.toBytes(context.getTaskAttemptID().toString())); + w.appendFileInfo(BULKLOAD_TASK_KEY, Bytes.toBytes(taskAttemptID.toString())); w.appendFileInfo(MAJOR_COMPACTION_KEY, Bytes.toBytes(true)); w.appendFileInfo(EXCLUDE_FROM_MINOR_COMPACTION_KEY, Bytes.toBytes(compactionExclude)); w.appendTrackedTimestampsToMetadata();