我正在编写 java udf 函数以通过比较位置列来添加 pincode。这是我的代码。
import java.io.IOException;
import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;
import org.apache.commons.lang3.StringUtils;
public class MB_pincodechennai extends EvalFunc<String>
{
private String pincode(String input)
{
String property_pincode = null;
String[] items = new String[]{"600088", "600016", "600053", "600070", "600040", "600106", "632301", "600109", "600083", "600054", "600023", "600095", "600077", "600073", "600003", "603001", "600064", "600094", "600044", "600008",
};
for (String itm : items)
{
if (StringUtils.containsIgnoreCase(input, itm))
{
property_pincode = itm;
break;
}
}
return property_pincode;
}
public String exec(Tuple input) throws IOException
{
if (input == null || input.size() == 0)
return null;
try
{
String str = (String) input.get(0);
return pincode(str);
}
catch (Exception e)
{
return null;
}
}
}
这个地方看起来像这样 adyar,tambaram,pallavaram,chromepet...
当我运行上面它只打印空白值。我不知道我的错误在哪里。任何帮助将不胜感激。