value = t1.get(pos);
valueLoaded = true;
return value;
}
ReadToEndLoader loader;
try {
pos = DataType.toInteger(input.get(0));
scalarfilename = DataType.toString(input.get(1));
// Hadoop security need this property to be set
Configuration conf = UDFContext.getUDFContext().getJobConf();
if (System.getenv("HADOOP_TOKEN_FILE_LOCATION") != null) {
conf.set(MRConfiguration.JOB_CREDENTIALS_BINARY,
System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
}
loader = new ReadToEndLoader(
new InterStorage(), conf, scalarfilename, 0);
} catch (Exception e) {
throw new ExecException("Failed to open file '" + scalarfilename
+ "'; error = " + e.getMessage());
}
try {
Tuple t1 = loader.getNext();
if(t1 == null){
log.warn("No scalar field to read, returning null");
valueLoaded = true;
return null;
}
value = t1.get(pos);
Tuple t2 = loader.getNext();
if(t2 != null){
String msg = "Scalar has more than one row in the output. "
+ "1st : " + t1 + ", 2nd :" + t2;
throw new ExecException(msg);
}