Hadoopを使って計算を分散してみました。
シーケンスの入力ファイルと出力ファイル、およびカスタム Writable を使用しています。
入力は三角形のリストで、最大サイズは 2Mb ですが、50kb ほど小さくすることもできます。中間値と出力は、カスタム Writable の map(int,double) です。これがボトルネックですか?
問題は、計算が Hadoop なしのバージョンよりもはるかに遅いことです。また、ノードを 2 から 10 に増やしても、プロセスは高速化されません。
1 つの可能性は、入力サイズが小さいために十分なマッパーを取得できないことです。を変更してテストを行いましたmapreduce.input.fileinputformat.split.maxsize
が、良くなるどころか悪化しました。
ローカルで Hadoop 2.2.0 を使用しており、Amazon Elastic mapreduce で使用しています。
私は何かを見落としましたか?それとも、これは Hadoop なしで実行する必要があるタスクの種類ですか? (mapreduce を使用するのは初めてです)。
コード部分を見たいですか?
ありがとうございました。
public void map(IntWritable triangleIndex, TriangleWritable triangle, Context context) throws IOException, InterruptedException {
StationWritable[] stations = kernel.newton(triangle.getPoints());
if (stations != null) {
for (StationWritable station : stations) {
context.write(new IntWritable(station.getId()), station);
}
}
}
class TriangleWritable implements Writable {
private final float[] points = new float[9];
@Override
public void write(DataOutput d) throws IOException {
for (int i = 0; i < 9; i++) {
d.writeFloat(points[i]);
}
}
@Override
public void readFields(DataInput di) throws IOException {
for (int i = 0; i < 9; i++) {
points[i] = di.readFloat();
}
}
}
public class StationWritable implements Writable {
private int id;
private final TIntDoubleHashMap values = new TIntDoubleHashMap();
StationWritable(int iz) {
this.id = iz;
}
@Override
public void write(DataOutput d) throws IOException {
d.writeInt(id);
d.writeInt(values.size());
TIntDoubleIterator iterator = values.iterator();
while (iterator.hasNext()) {
iterator.advance();
d.writeInt(iterator.key());
d.writeDouble(iterator.value());
}
}
@Override
public void readFields(DataInput di) throws IOException {
id = di.readInt();
int count = di.readInt();
for (int i = 0; i < count; i++) {
values.put(di.readInt(), di.readDouble());
}
}
}