簡體   English   中英

在文件夾和子文件夾中的文件上運行Mapreduce

[英]Running Mapreduce on files in folders and sub folders

我們的日志文件存儲在HDFS中的年/月/日/小時文件夾中

參見下面的結構:

/year=2014/month=8/day=20/hour=1/logA.txt    
/year=2014/month=8/day=20/hour=2/logB.txt    
/year=2014/month=8/day=20/hour=2/logC.txt

如果我將一個日志文件作為輸入傳遞給Java mapreduce程序,則它可以工作。

See my working syntax below:
hadoop jar test.jar wc /year=2014/month=8/day=20/hour=1/logA.txt output/

如何將月= 8中的所有文件作為我的地圖縮減程序的輸入? 例如,month = 8,每天都有文件夾,每天都有幾個小時的子文件夾。 日志文件存儲在小時文件夾中。

我需要在8月的每一天的每一小時中傳遞所有文件,作為對Mapreduce程序的輸入。

你有嘗試過嗎? hadoop jar test.jar wc / year = 2014 / month = 8 / output /

Hadoop FileSystem支持globbing。 您可以在FileSystem Javadoc中找到模式的定義

要回答您的特定問題,可以使用以下模式:

/year=2014/month=8/day=*/hour=*

如果您未提供所有詳細信息並且此模式不起作用,則可以輕松地對其進行調整以匹配較少的文件。 例如:

/year=2014/month=8/day=*/hour=*/logA.txt

或者,如果您只想處理0到11之間的小時

/year=2014/month=8/day=*/hour={0,1,2,3,4,5,6,7,8,9,10,11}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM