1. 程式人生 > >Hadoop 原始碼詳解之FileInputFormat類

Hadoop 原始碼詳解之FileInputFormat類

Hadoop 原始碼詳解之FileInputFormat類【updating…】

1. 類釋義

A base class for file-based InputFormats.
針對基於檔案的 InputFormats 一個基類

FileInputFormat is the base class for all file-based InputFormats. This provides a generic implementation of getSplits(JobContext). Implementations of FileInputFormat can also override the isSplitable(JobContext, Path) method to prevent input files from being split-up in certain situations. Implementations that may deal with non-splittable files must override this method, since the default implementation assumes splitting is always possible.
FileInputFormat

是一個基類對於素有基於檔案的InputFormats。這個類提供了一個一般的實現——getSplits(JobContext)FileInputFormat的實現也覆寫了isSplitable(JobContext,Path)方法去阻止輸入檔案被檔案在某些場景下被切割。 必須覆寫這個方法才能同時實現不切割檔案,因為預設的實現總是假設切割是可能的 。

2. 類原始碼

public abstract class FileOutputFormat<K, V> extends OutputFormat<K, V> {
...
}

3. 方法詳解

3.1 setInputPaths()
方法

Sets the given comma separated paths as the list of inputs for the map-reduce job.
使用給定的逗號分隔路徑作為 為map-reduce job的檔案列表

static void 	setInputPaths(Job job, Path... inputPaths)
Set the array of Paths as the list of inputs for the map-reduce job.

在這裡插入圖片描述注意,在呼叫這個方式時,可以看到有一個commaSeparate,這個表明的就是後面可跟逗號分隔的檔案列表。