Skip to content

Core: Z-order byte encoding for floating-point values is not order-preserving #17070

Description

@eye-gu

Apache Iceberg version

None

Query engine

None

Please describe the bug 🐞

public static ByteBuffer floatingPointOrderedBytes(double val, ByteBuffer reuse) {
ByteBuffer bytes = ByteBuffers.reuse(reuse, PRIMITIVE_BUFFER_SIZE);
long lval = Double.doubleToLongBits(val);
lval ^= ((lval >> (Integer.SIZE - 1)) | Long.MIN_VALUE);
bytes.putLong(lval);
return bytes;
}

Here the shift is >> (Integer.SIZE - 1) = >> 31.The fix is a one-character change: >> (Integer.SIZE - 1) → >> (Long.SIZE - 1).

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions