dataInputStream の readFully メッセージを使用して、固定長のバイト配列を次のように読み取ります。
byte[] record = new byte[4660004];
in.readFully(record);
ここでの問題は、これらの多くのバイト (20000 レコードに相当) を読み取るのに 5 秒以上かかる場合があることです。そして、ソケットでこのデータを受信しています。クライアントは、4660004 バイトのバイト配列としてデータを送信しています。現在、このようなレコードを 100 万件取得するのに約 5 分かかるため、このデータをより速く受信する方法はありますか。
編集:: 完全なデータフロー:
最初にストリームを作成します:
static DataInputStream dIn = null;
dIn = new DataInputStream(connection.getInputStream());
msgType = dIn.readByte();
int msgIntLen = dIn.readInt();
processBatch(msgIntType, msgIntLen, dIn, connector);
.
.
private static void processBatch(int msgIntType, int msgIntLen, DataInputStream in,
Connector connector) throws IOException {
int recordIntLen = in.readInt();
byte[] record = new byte[msgIntLen - 4];
in.readFully(record);
}
そのwudfが役立つ場合、どこにバッファリングを含める必要がありますか?