您可以通過將第一個文件放入分佈式緩存並遍歷映射階段中的第二個文件進行連接來執行mapside連接。
如何從分佈式緩存讀取:
@Override
protected void setup(Context context) throws IOException,InterruptedException
{
Path[] filelist=DistributedCache.getLocalCacheFiles(context.getConfiguration());
for(Path findlist:filelist)
{
if(findlist.getName().toString().trim().equals("mapmainfile.dat"))
{
fetchvalue(findlist,context);
}
}
}
public void fetchvalue(Path realfile,Context context) throws NumberFormatException, IOException
{
BufferedReader buff=new BufferedReader(new FileReader(realfile.toString()));
//some operations with the file
}
如何將文件添加到分佈式緩存:
DistributedCache.addCacheFile(new URI("/user/hduser`/test/mapmainfile.dat"),conf);`
有多大,你想這些文件使用MapReduce? – YoungHobbit
第二個文件至少爲1GB。第一個文件實際上是給定第二個文件上MapReduce的結果,例如所有以「u1」開頭的行。 – user5004049