假设 Pig UDF 创建了两种不同类型的数据记录。
Pig 脚本如何以两种不同的方式处理从这个 UDF 返回的组合元组列表?
例如:
public Tuple exec (Tuple input) // input ignored in UDF for simplicity
{
Tuple t = TupleFactory.getInstance ().newTuple ();
if (Math.random () < 0.5)
t.append ("less than half");
else
t.append (new Date ());
return t;
}
Pig 脚本应该执行以下操作:
register ...
define myUDF ...
data = load ...;
combinedList = foreach data generate myUDF (data);
stringList = filter combinedList by $0 instanceof java.lang.String; // ??
dateList = filter combinedLists by $0 instanceof java.util.Date; //??
store stringList into ... ;
store dateList into ... ;
谢谢,