yadavay-amzn commented on code in PR #55928:
URL: https://github.com/apache/spark/pull/55928#discussion_r3262707289
##########
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:
Applied the bitmask approach by using `(typeInfo & 0x20) != 0` since
`typeInfo` is 6 bits wide (masked by `TYPE_INFO_MASK = 0x3F`) and the sort bit
is at position 5 within that. `0x20` = `1 << 5` = 32.
I think `0x10000` (65536) might be a typo since it exceeds the 6-bit range?
Please let me know if I'm reading this wrong.
--
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]