1

ファイルと、そのファイルに対して並行して実行される 2 つの異なる独立したマッパーがあるとします。そのためには、ファイルのコピーを使用する必要があります。

私が知りたいのは、「2 つのマッパーに同じファイルを使用することは可能ですか」ということです。これにより、リソースの使用率が低下し、システム時間が効率的になります。

この分野の研究や、これを克服するのに役立つ Hadoop の既存のツールはありますか。

4

2 に答える 2

3

両方のマッパーが同じ署名を持っていると仮定するとK,V、委任マッパーを使用して、2 つのマッパーの map メソッドを呼び出すことができます。

public class DelegatingMapper extends Mapper<LongWritable, Text, Text, Text> {
    public Mapper<LongWritable, Text, Text, Text> mapper1;
    public Mapper<LongWritable, Text, Text, Text> mapper2;

    protected void setup(Context context) {
        mapper1 = new MyMapper1<LongWritable, Text, Text, Text>();
        mapper1.setup(context);

        mapper2 = new MyMapper1<LongWritable, Text, Text, Text>();
        mapper2.setup(context);
    }

    public void map(LongWritable key, Text value, Context context) {
        // your map methods will need to be public for each class
        mapper1.map(key, value, context);
        mapper2.map(key, value, context);
    }

    protected void cleanup(Context context) {
        mapper1.cleanup(context);
        mapper2.cleanup(context);
    }
}
于 2013-05-27T11:04:47.690 に答える