You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2021/10/05 12:02:29 UTC

[lucene] branch main updated: LUCENE-10143: Delegate primitive writes in RateLimitedIndexOutput (#352)

This is an automated email from the ASF dual-hosted git repository.

uschindler pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new 9e0f375  LUCENE-10143: Delegate primitive writes in RateLimitedIndexOutput (#352)
9e0f375 is described below

commit 9e0f3758d2615f45f9aaccd7fcd70652f021762e
Author: Uwe Schindler <us...@apache.org>
AuthorDate: Tue Oct 5 14:02:22 2021 +0200

    LUCENE-10143: Delegate primitive writes in RateLimitedIndexOutput (#352)
---
 lucene/CHANGES.txt                                  |  3 +++
 .../apache/lucene/store/RateLimitedIndexOutput.java | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index eeb993f..01d05b5 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -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,
diff --git a/lucene/core/src/java/org/apache/lucene/store/RateLimitedIndexOutput.java b/lucene/core/src/java/org/apache/lucene/store/RateLimitedIndexOutput.java
index 38190d2..76fa7d6 100644
--- a/lucene/core/src/java/org/apache/lucene/store/RateLimitedIndexOutput.java
+++ b/lucene/core/src/java/org/apache/lucene/store/RateLimitedIndexOutput.java
@@ -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);