0
我將Pig(0.10)從hdfs加載數據加載到hbase中。該原始記錄不具備的獨特rowkeys,所以我有一個UDF構建一個:如何區分單個豬工作中的地圖任務
public class Foo extends EvalFunc<Tuple> {
// FIXME: If there are multiple map jobs for the same batch,
// they will reuse the serial numbers.
// Need to add something to figure out a distinct per task #
private int task_id=0;
private long serial=0L;
public Tuple exec(Tuple input) throws IOException {
if (input == null || input.size() == 0)
return null;
try {
Integer batch_id=(Integer)input.get(0);
String rowkey=String.format("%7d%3d%9d", batch_id, task_id, serial++);
// ... compute other values for the return Tuple.
}
}
}
我的理解是,如果豬啓動對於相同的輸入數據同時設置兩個不同的地圖的工作(由於超過CHUNKSIZE或從一個目錄LOADing時有多個輸入文件),每個將會是一個單獨的Java實例,因此會有多個獨立的Foo.serial副本;我的rowkeys將不會是唯一的,我將覆蓋許多我正試圖加載到HBase的記錄。
如果我的UDF可以確定它是哪個映射器,碰撞就會消失。我可以回退到IP地址+進程ID,但這太浪費了。
我正在尋找一個解決方案,以避免一個reducer瓶頸。確實,我目前的數據並不龐大,如此合適的東西以至於他們通過一個單一的映射器並不是太艱難,我希望有一種技術可以在需要處理大數據時進行擴展。 – gwaigh