You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mrunit.apache.org by br...@apache.org on 2013/05/21 19:53:30 UTC
git commit: MRUNIT-164: Remove duplicated InputPathStoringMapper
classes
Updated Branches:
refs/heads/trunk 6e94cecff -> 0578f8652
MRUNIT-164: Remove duplicated InputPathStoringMapper classes
Project: http://git-wip-us.apache.org/repos/asf/mrunit/repo
Commit: http://git-wip-us.apache.org/repos/asf/mrunit/commit/0578f865
Tree: http://git-wip-us.apache.org/repos/asf/mrunit/tree/0578f865
Diff: http://git-wip-us.apache.org/repos/asf/mrunit/diff/0578f865
Branch: refs/heads/trunk
Commit: 0578f8652621c05feb79e992de1ac7b9e8671ec7
Parents: 6e94cec
Author: Brock Noland <br...@apache.org>
Authored: Tue May 21 12:52:00 2013 -0500
Committer: Brock Noland <br...@apache.org>
Committed: Tue May 21 12:52:00 2013 -0500
----------------------------------------------------------------------
.../mrunit/mapreduce/InputPathStoringMapper.java | 41 +++++++++++++++
.../hadoop/mrunit/mapreduce/TestMapDriver.java | 18 +------
.../mrunit/mapreduce/TestMapReduceDriver.java | 20 +-------
3 files changed, 43 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mrunit/blob/0578f865/src/test/java/org/apache/hadoop/mrunit/mapreduce/InputPathStoringMapper.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/hadoop/mrunit/mapreduce/InputPathStoringMapper.java b/src/test/java/org/apache/hadoop/mrunit/mapreduce/InputPathStoringMapper.java
new file mode 100644
index 0000000..1f66f2e
--- /dev/null
+++ b/src/test/java/org/apache/hadoop/mrunit/mapreduce/InputPathStoringMapper.java
@@ -0,0 +1,41 @@
+/**
+ * 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.hadoop.mrunit.mapreduce;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.Mapper;
+import org.apache.hadoop.mapreduce.lib.input.FileSplit;
+
+class InputPathStoringMapper<VALUEIN, VALUEOUT>
+ extends Mapper<Text, VALUEIN, Text, VALUEOUT> {
+ private Path mapInputPath;
+
+ @Override
+ public void map(Text key, VALUEIN value, Context context) throws IOException {
+ if (context.getInputSplit() instanceof FileSplit) {
+ mapInputPath = ((FileSplit) context.getInputSplit()).getPath();
+ }
+ }
+
+ Path getMapInputPath() {
+ return mapInputPath;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mrunit/blob/0578f865/src/test/java/org/apache/hadoop/mrunit/mapreduce/TestMapDriver.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/hadoop/mrunit/mapreduce/TestMapDriver.java b/src/test/java/org/apache/hadoop/mrunit/mapreduce/TestMapDriver.java
index 20acd18..2457ed3 100644
--- a/src/test/java/org/apache/hadoop/mrunit/mapreduce/TestMapDriver.java
+++ b/src/test/java/org/apache/hadoop/mrunit/mapreduce/TestMapDriver.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
@@ -430,24 +429,9 @@ public class TestMapDriver {
- private static class InputPathStoringMapper extends
- Mapper<Text, Text, Text, Text> {
- private Path mapInputPath;
-
- @Override
- public void map(Text key, Text value, Context context) throws IOException {
- if (context.getInputSplit() instanceof FileSplit) {
- mapInputPath = ((FileSplit) context.getInputSplit()).getPath();
- }
- }
-
- private Path getMapInputPath() {
- return mapInputPath;
- }
- }
@Test
public void testMapInputFile() throws IOException {
- InputPathStoringMapper mapper = new InputPathStoringMapper();
+ InputPathStoringMapper<Text, Text> mapper = new InputPathStoringMapper<Text, Text>();
Path mapInputPath = new Path("myfile");
driver = MapDriver.newMapDriver(mapper);
driver.setMapInputPath(mapInputPath);
http://git-wip-us.apache.org/repos/asf/mrunit/blob/0578f865/src/test/java/org/apache/hadoop/mrunit/mapreduce/TestMapReduceDriver.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/hadoop/mrunit/mapreduce/TestMapReduceDriver.java b/src/test/java/org/apache/hadoop/mrunit/mapreduce/TestMapReduceDriver.java
index 5d3cf22..5ce285d 100644
--- a/src/test/java/org/apache/hadoop/mrunit/mapreduce/TestMapReduceDriver.java
+++ b/src/test/java/org/apache/hadoop/mrunit/mapreduce/TestMapReduceDriver.java
@@ -33,7 +33,6 @@ import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.serializer.JavaSerializationComparator;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
-import org.apache.hadoop.mapreduce.lib.input.FileSplit;
import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.map.InverseMapper;
@@ -495,26 +494,9 @@ public class TestMapReduceDriver {
driver.runTest();
}
- private static class InputPathStoringMapper extends
- Mapper<Text, LongWritable, Text, LongWritable> {
- private Path mapInputPath;
-
- @Override
- public void map(Text key, LongWritable value, Context context)
- throws IOException {
- if (context.getInputSplit() instanceof FileSplit) {
- mapInputPath = ((FileSplit) context.getInputSplit()).getPath();
- }
- }
-
- private Path getMapInputPath() {
- return mapInputPath;
- }
- }
-
@Test
public void testMapInputFile() throws IOException {
- InputPathStoringMapper mapper = new InputPathStoringMapper();
+ InputPathStoringMapper<LongWritable, LongWritable> mapper = new InputPathStoringMapper<LongWritable, LongWritable>();
Path mapInputPath = new Path("myfile");
driver = MapReduceDriver.newMapReduceDriver(mapper, reducer);
driver.setMapInputPath(mapInputPath);