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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to