MCPcopy Create free account
hub / github.com/WinVector/Logistic / DefMapper

Class DefMapper

src/com/winvector/logistic/mr/MapRedScan.java:32–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 private static final String DEFFIELD = "MapRedScan.DefFieldName";
31
32 public static final class DefMapper extends Mapper<LongWritable,Text,LongWritable,WritableVariableList> {
33 // config
34 private LineBurster burster = null;
35 // derived
36 private Log log = null;
37 private String hostDescr = null;
38 // result
39 private WritableVariableList accum = null;
40
41 @Override
42 public void setup(final Context context) throws IOException {
43 log = LogFactory.getLog(DefMapper.class);
44 hostDescr = WritableUtils.hostDescr();
45 log.info(".setup() " + hostDescr);
46 // read side-channel configuration
47 accum = null;
48 try {
49 burster = SerialUtils.readSerialiazlabeFromString(context.getConfiguration().get(MapRedScan.BURSTERSERFIELD));
50 final String formulaStr = context.getConfiguration().get(FORMULAFIELD);
51 final Formula f = new Formula(formulaStr);
52 accum = new WritableVariableList();
53 accum.readyForDefTracking(f);
54 } catch (Exception e) {
55 throw new IOException(e.toString());
56 }
57 }
58
59 @Override
60 public void map(final LongWritable key, final Text value, final Context context) {
61 final BurstMap parsed = burster.parse(value.toString());
62 if(!parsed.isEmpty()) {
63 accum.trackVariableDefsFromRow(parsed);
64 }
65 }
66
67 @Override
68 public void cleanup(final Context context) throws IOException, InterruptedException {
69 context.write(new LongWritable(0),accum);
70 log.info(".cleanup() " + hostDescr);
71 burster = null;
72 accum = null;
73 }
74 }
75
76 public static final class DefReducer extends Reducer<LongWritable,WritableVariableList,LongWritable,WritableVariableList> {
77 @Override

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected