0

私のマッパーの実装

public class SimpleMapper extends Mapper<Text, Text, Text, MapWritable> {

@Override
protected void map(Text key, Text value,Context context)
        throws IOException, InterruptedException {

            MapWritable writable = new LinkedMapWritable();
            writable.put("unique_key","one");
            writable.put("another_key","two");
            context.write(new Text("key"),writable );
        }

}

そして、Reducer の実装は次のとおりです。

public class SimpleReducer extends Reducer<Text, MapWritable, NullWritable, Text> {
@Override
protected void reduce(Text key, Iterable<MapWritable> values,Context context)
        throws IOException, InterruptedException {

            // The map writables have to be ordered based on the "unique_key" inserted into it
        }

}

二次ソートを使用する必要がありますか? そうする他の方法はありますか?

4

1 に答える 1

1

レデューサーの MapWritable (値) は常に予測不可能な順序であり、この順序は実行ごとに異なる可能性があり、制御することはできません。

しかし、Map/Reduce パラダイムが保証するのは、レデューサーに提示されるキーがソートされた順序であり、単一のキーに属するすべての値が単一のレデューサーに送られることです。

そのため、ユースケースに確実にセカンダリ ソートとカスタム パーティショナーを使用できます。

于 2014-06-20T03:30:38.067 に答える