mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-25 06:16:40 +00:00
reuse file buffer
This commit is contained in:
parent
d531d82cfb
commit
6cdd6a015c
@ -50,6 +50,8 @@ public class FsSnapshot implements Translog.Snapshot {
|
||||
|
||||
private int position = 0;
|
||||
|
||||
private byte[] cachedData;
|
||||
|
||||
public FsSnapshot(ShardId shardId, long id, RafReference raf, long length) throws FileNotFoundException {
|
||||
this.shardId = shardId;
|
||||
this.id = id;
|
||||
@ -83,9 +85,13 @@ public class FsSnapshot implements Translog.Snapshot {
|
||||
return false;
|
||||
}
|
||||
position += opSize;
|
||||
byte[] data = new byte[opSize];
|
||||
dis.readFully(data);
|
||||
lastOperationRead = TranslogStreams.readTranslogOperation(new BytesStreamInput(data));
|
||||
if (cachedData == null) {
|
||||
cachedData = new byte[opSize];
|
||||
} else if (cachedData.length < opSize) {
|
||||
cachedData = new byte[opSize];
|
||||
}
|
||||
dis.readFully(cachedData, 0, opSize);
|
||||
lastOperationRead = TranslogStreams.readTranslogOperation(new BytesStreamInput(cachedData, 0, opSize));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user