Chris,
Attached is a patch for MapReduceFlow.java that allows a MapReduce
flow to explicitly set Taps. This commit is also at github at:
http://github.com/jashmenn/cascading/commit/90c119261826740a2008c111e12c26526086b281
A couple notes
1) I've kept the interface for the constructor that creates Taps from
the JobConf
2) I've added a convenience constructor for simply passing in a single
source and sink. In my mind, this is a common case.
3) The designated initializer now becomes the more general case of
passing in a Map<String, Tap> of sources, sinks, and traps.
Let me know what you think about this and if you want to make any
changes,
Nate
From 90c119261826740a2008c111e12c26526086b281 Mon Sep 17 00:00:00 2001
From: Nate Murray <
na...@natemurray.com>
Date: Fri, 23 Oct 2009 15:54:01 -0700
Subject: [PATCH] updated MapReduceFlow to accept explicit Taps
---
src/core/cascading/flow/MapReduceFlow.java | 54 ++++++++++++++++++++
+++++--
1 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/src/core/cascading/flow/MapReduceFlow.java b/src/core/
cascading/flow/MapReduceFlow.java
index e777140..3597d10 100644
--- a/src/core/cascading/flow/MapReduceFlow.java
+++ b/src/core/cascading/flow/MapReduceFlow.java
@@ -96,7 +96,7 @@ public class MapReduceFlow extends Flow
*/
public MapReduceFlow( String name, JobConf jobConf, boolean
deleteSinkOnInit )
{
- this( name, jobConf, deleteSinkOnInit, true );
+ this( name, jobConf, null, null, null, deleteSinkOnInit, true );
}
/**
@@ -109,13 +109,59 @@ public class MapReduceFlow extends Flow
*/
public MapReduceFlow( String name, JobConf jobConf, boolean
deleteSinkOnInit, boolean stopJobsOnExit )
{
+ this( name, jobConf, null, null, null, deleteSinkOnInit,
stopJobsOnExit );
+ this.setSources( createSources( jobConf ) );
+ this.setSinks( createSinks( jobConf ) );
+ this.setTraps( createTraps( jobConf ) );
+ }
+
+ /**
+ * Constructor MapReduceFlow creates a new MapReduceFlow instance.
+ *
+ * @param name of type String
+ * @param jobConf of type JobConf
+ * @param source of type Tap
+ * @param sink of type Tap
+ * @param deleteSinkOnInit of type boolean
+ * @param stopJobsOnExit of type boolean
+ */
+ public MapReduceFlow( String name, JobConf jobConf, Tap source, Tap
sink, boolean deleteSinkOnInit, boolean stopJobsOnExit )
+ {
+ this( name, jobConf, null, null, null, deleteSinkOnInit,
stopJobsOnExit );
+
+ Map<String, Tap> sources = new HashMap<String, Tap>();
+ Map<String, Tap> sinks = new HashMap<String, Tap>();
+ Map<String, Tap> traps = new HashMap<String, Tap>();
+
+ sources.put( source.getPath().toString(), source );
+ sinks.put( sink.getPath().toString(), sink );
+
+ this.setSources( sources );
+ this.setSinks( sinks );
+ this.setTraps( traps );
+ }
+
+ /**
+ * Constructor MapReduceFlow creates a new MapReduceFlow instance.
+ *
+ * @param name of type String
+ * @param jobConf of type JobConf
+ * @param sources of type Map<String, Tap>
+ * @param sinks of type Map<String, Tap>
+ * @param traps of type Map<String, Tap>
+ * @param deleteSinkOnInit of type boolean
+ * @param stopJobsOnExit of type boolean
+ */
+ public MapReduceFlow( String name, JobConf jobConf, Map<String,
Tap> sources, Map<String, Tap> sinks, Map<String, Tap> traps,
+ boolean deleteSinkOnInit, boolean stopJobsOnExit )
+ {
this.deleteSinkOnInit = deleteSinkOnInit;
this.stopJobsOnExit = stopJobsOnExit;
setName( name );
- setSources( createSources( jobConf ) );
- setSinks( createSinks( jobConf ) );
- setTraps( createTraps( jobConf ) );
+ setSources( sources );
+ setSinks( sinks );
+ setTraps( traps );
setStepGraph( makeStepGraph( jobConf ) );
}
--
1.6.2.4