You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/04/18 10:51:43 UTC

[GitHub] [flink] fhueske commented on a change in pull request #8034: [FLINK-11733] Provide HadoopMapFunction for org.apache.hadoop.mapreduce.Mapper

fhueske commented on a change in pull request #8034: [FLINK-11733] Provide HadoopMapFunction for org.apache.hadoop.mapreduce.Mapper
URL: https://github.com/apache/flink/pull/8034#discussion_r276595922
 
 

 ##########
 File path: flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/hadoopcompatibility/mapreduce/HadoopMapFunction.java
 ##########
 @@ -0,0 +1,125 @@
+/*
+ * 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.flink.hadoopcompatibility.mapreduce;
+
+import org.apache.flink.annotation.Public;
+import org.apache.flink.api.common.functions.RichFlatMapFunction;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.typeutils.ResultTypeQueryable;
+import org.apache.flink.api.java.typeutils.TupleTypeInfo;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.hadoopcompatibility.mapreduce.wrapper.HadoopProxyMapper;
+import org.apache.flink.util.Collector;
+import org.apache.flink.util.InstantiationUtil;
+import org.apache.flink.util.Preconditions;
+
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.mapreduce.Mapper;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+/**
+ * This wrapper maps a Hadoop Mapper (mapreduce API) to a Flink FlatMapFunction.
+ */
+@SuppressWarnings("rawtypes")
+@Public
+public class HadoopMapFunction<KEYIN, VALUEIN, KEYOUT, VALUEOUT>
+	extends RichFlatMapFunction<Tuple2<KEYIN, VALUEIN>, Tuple2<KEYOUT, VALUEOUT>>
+	implements ResultTypeQueryable<Tuple2<KEYOUT, VALUEOUT>>, Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	private transient HadoopProxyMapper<KEYIN, VALUEIN, KEYOUT, VALUEOUT> hadoopProxyMapper;
+	private transient Mapper<KEYIN, VALUEIN, KEYOUT, VALUEOUT> hadoopMapper;
+	private transient Job jobConf;
+	private transient HadoopProxyMapper.HadoopDummyMapperContext mapperContext;
+
+	public HadoopMapFunction(Mapper<KEYIN, VALUEIN, KEYOUT, VALUEOUT> hadoopMapper) throws IOException {
+		this(hadoopMapper, Job.getInstance());
+	}
+
+	public HadoopMapFunction(Mapper<KEYIN, VALUEIN, KEYOUT, VALUEOUT> hadoopMapper, Job conf) {
+		this.hadoopMapper = Preconditions.checkNotNull(hadoopMapper);
+		this.hadoopProxyMapper = new HadoopProxyMapper<>();
 
 Review comment:
   We don't need to create the proxy yet. It's sufficient to do that in `open()`

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services