You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/09/19 18:10:22 UTC

[GitHub] [lucene] uschindler commented on pull request #308: LUCENE-10113: Use VarHandles to access int/long/short types in byte arrays (e.g. ByteArrayDataInput)

uschindler commented on pull request #308:
URL: https://github.com/apache/lucene/pull/308#issuecomment-922514111


   > > by the way @uschindler, one idea i had when going thru this stuff, is maybe to put these VHs into `org.apache.lucene.util.ArrayUtil` instead of `org.apache.lucene.util.BitUtil`. It seems like a more natural place for people to look?
   > 
   > I thought about that, too. ArrayUtil is more about handling _arrays_ (like resize,...), but this is more about encoding/decoding values in a byte array. BitUtil is more about encoding/decoding (e.g, zigzag encoding is also there). So to me the latter fitted better.
   > 
   > An alternative would be a new class `PrimitiveValueConverter` or similar.
   > 
   > We can easily change this at a later stage using eclipse's "move" refactoring.
   
   Alos for Later: We may also change to static methods in PrimitiveValueConverter and hide the varhandles again. I know this is one more abstraction, but the "nice" thing is: We have type safety. VarHandles are not so easy to use, because autocomplete does not work. By wrapping with static methods it is enforced by compiler (of course this adds more code and less SLOC is harder to reach)!
   
   In addition, in later Java versions (Java 16) you can change varhandles to be "type safe" (they behave like `MethodHandle#invokeExact()` and do not silently adapt types: https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/invoke/VarHandle.html#withInvokeExactBehavior()


-- 
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-unsubscribe@lucene.apache.org

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



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