I am using Spring Boot in my project that runs a Pig script. I have defined a Pig UDF. I wonder whether I can inject a bean into this UDF class. The UDF class is something like this: The UDF that works now looks like this:
public class MyUDF extends EvalFunc<String> {
public String exec(Tuple input) throws IOException {
final ClassA instanceA = new ClassA();
return instanceA.func(input);
}
}
I wonder whether I can leave the instantiation of instanceA
to spring container? I tried
public class MyUDF extends EvalFunc<String> {
@Autowired
private final ClassA instanceA;
public String exec(Tuple input) throws IOException {
return instanceA.func(input);
}
}
and also defined a constructor, but neither of these two methods works. Is it because this instanceA
should be static?
Is there a way to use Bean factory in Pig UDF?