steveloughran commented on code in PR #55928:
URL: https://github.com/apache/spark/pull/55928#discussion_r3258639003


##########
common/variant/src/main/java/org/apache/spark/types/variant/Variant.java:
##########
@@ -146,9 +146,12 @@ public int objectSize() {
   public Variant getFieldByKey(String key) {
     return handleObject(value, pos, (size, idSize, offsetSize, idStart, 
offsetStart, dataStart) -> {
       // Use linear search for a short list. Switch to binary search when the 
length reaches
-      // `BINARY_SEARCH_THRESHOLD`.
+      // `BINARY_SEARCH_THRESHOLD` and the object fields are sorted by key 
name (indicated by
+      // bit 5 of the type info in the header byte).
       final int BINARY_SEARCH_THRESHOLD = 32;
-      if (size < BINARY_SEARCH_THRESHOLD) {
+      int typeInfo = (value[pos] >> BASIC_TYPE_BITS) & TYPE_INFO_MASK;
+      boolean sorted = ((typeInfo >> 5) & 0x1) != 0;

Review Comment:
   you could do `(typeInfo & 0x10000) != 0` and keep the ALU barrel shifter 
idle. Or even do the same on L52
   
   



-- 
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