SavicStefan commented on code in PR #59669:
URL: https://github.com/apache/spark/pull/59669#discussion_r4452818143
##########
common/variant/src/main/java/org/apache/spark/types/variant/VariantBuilder.java:
##########
@@ -282,23 +358,25 @@ public void appendBoolean(boolean b) {
// range of the long value.
public void appendLong(long l) {
checkCapacity(1 + 8);
- if (l == (byte) l) {
- writeBuffer[writePos++] = primitiveHeader(INT1);
- writeLong(writeBuffer, writePos, l, 1);
- writePos += 1;
- } else if (l == (short) l) {
- writeBuffer[writePos++] = primitiveHeader(INT2);
- writeLong(writeBuffer, writePos, l, 2);
- writePos += 2;
- } else if (l == (int) l) {
- writeBuffer[writePos++] = primitiveHeader(INT4);
- writeLong(writeBuffer, writePos, l, 4);
- writePos += 4;
- } else {
- writeBuffer[writePos++] = primitiveHeader(INT8);
- writeLong(writeBuffer, writePos, l, 8);
- writePos += 8;
+ int typeInfo = minimalLongTypeInfo(l);
Review Comment:
Agreed. I reverted the changes to appendLong, appendDecimal and the metadata
header write in result() to their current bodies, so the width helpers are only
used by the canonicalization check and marked as having to match the append
methods.
What remains in existing code is only what canonicalization needs. I will
make a follow up PR to addresse those shared codes, after me merge this PR.
--
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]