LUCENE-10143: Delegate primitive writes in RateLimitedIndexOutput (#352)

This commit is contained in:
Uwe Schindler 2021-10-05 14:02:22 +02:00 committed by GitHub
parent 5d2a031159
commit 9e0f3758d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -292,6 +292,9 @@ Improvements
* LUCENE-10125: Optimize primitive writes in OutputStreamIndexOutput.
(Uwe Schindler, Robert Muir, Adrien Grand)
* LUCENE-10143: Delegate primitive writes in RateLimitedIndexOutput.
(Uwe Schindler, Robert Muir, Adrien Grand)
Bug fixes
* LUCENE-9686: Fix read past EOF handling in DirectIODirectory. (Zach Chen,

View File

@ -73,6 +73,27 @@ public final class RateLimitedIndexOutput extends IndexOutput {
delegate.writeBytes(b, offset, length);
}
@Override
public void writeInt(int i) throws IOException {
bytesSinceLastPause += Integer.BYTES;
checkRate();
delegate.writeInt(i);
}
@Override
public void writeShort(short i) throws IOException {
bytesSinceLastPause += Short.BYTES;
checkRate();
delegate.writeShort(i);
}
@Override
public void writeLong(long i) throws IOException {
bytesSinceLastPause += Long.BYTES;
checkRate();
delegate.writeLong(i);
}
private void checkRate() throws IOException {
if (bytesSinceLastPause > currentMinPauseCheckBytes) {
rateLimiter.pause(bytesSinceLastPause);