Using static variables inside Cascading -
when start mapreduce job save current timestamp date
object in static variable of main class.
later when want read value different class (such custom cascading filter or cascading function class) job crashes java.lang.nullpointerexception
according driven.
is not possible access static variable within cascading logic? have no idea why doesn't work. date
variable not null print console when job launched , afterwards not touched logic.
this class throws error. if create new date
(with current time) within operate() method works fine.
public class timestampappender extends baseoperation implements function { public timestampappender(fields fielddeclaration) { super(fields.args); } public void operate(flowprocess flowprocess, functioncall functioncall) { tupleentry argument = functioncall.getarguments(); date timestamp = main.timeframemiddle; string arg0 = argument.getstring(0); string arg1 = argument.getstring(1); tuple result = new tuple(); result.addstring(arg0); result.addstring(arg1); result.addlong(timestamp.gettime()); functioncall.getoutputcollector().add(result); } }
it not clear main.timeframemiddle.could please include main class well. if trying current time can within cascading function.
Comments
Post a Comment