easyice commented on PR #13825:
URL: https://github.com/apache/lucene/pull/13825#issuecomment-2378380489

   
   Sorry for the confusion. We move group-varint encoding into DataInput to let 
subclasses make an optimized implementation.
   
   In the first version, the `readGroupVInts` method is `public`. see 
[delta](https://github.com/apache/lucene/pull/12841/commits/e58154e44a62235450b4f9d837e9307f4f5a8619%0ADataInput.java):
 
   
   
   class DataInput
   ```java
   public void readGroupVInts(long[] docs, int limit) throws IOException {
      fallbackReadGroupVInt(...)
   }
   ```
   
   ```java
   protected void fallbackReadGroupVInt(long[] docs, int offset) throws 
IOException {
   }
   ```
   
   
   subclass MemorySegmentIndexInput
   ```java
   @Override
   public void readGroupVInts(long[] docs, int limit) throws IOException {
   }
     
   private void readGroupVInt(long[] docs, int pos) throws IOException {
       if (...) {
         super.fallbackReadGroupVInt(docs, pos);
         return;
       }
       ....
   }
   ```
   
   The problem with this version is that subclasses have some duplicate code 
with small changes. then we try to move the duplicate code to a util class in 
the subclasses, but it has a bit performance regression. see 
[delta](https://github.com/apache/lucene/pull/12841#issuecomment-1850424855)
   
   class MemorySegmentIndexInput
   ```java
     @Override
     public void readGroupVInts(long[] dst, int limit) throws IOException {
       try {
         GroupVIntUtil.readGroupVInts(..);
       }
     }
   
   ```
   
   Finally, we remove the `readGroupVInts` method from subclasses, and make the 
base class `DataInput` implement as `final`(because nothing to optimize there 
anymore), the subclasses just override the `protected readGroupVInt()`.  see 
[delta](https://github.com/apache/lucene/pull/12841#issuecomment-1851098019)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to