Im coming to Java from other languages, so please forgive me if this is obvious, but I've encountered a very strange behavior.
I'm writing a simple Pig UDF. I'm returning a Tuple object, which I create using a TupleFactory singleton. In the following two code examples, the first example works, while the second throws a NullPointerException when creating the newTuple
;
public class MyUDF {
public Tuple func(Tuple input) {
return TupleFactory.getInstance().newTuple(Arrays.asList(o1, o2, o3));
}
}
public class MyUDF {
...
TupleFactory _factory;
public Tuple func(Tuple input) {
_factory.getInstance();
return _factory.newTuple(Arrays.asList(o1, o2, o3));
}
}