Skip to content

Range index does not create buckets correctly for FLOAT columns #7436

@richardstartin

Description

@richardstartin

When there is a range index on a FLOAT column, all values may be grouped under the same bucket whenever all values have the same integer floor value.

This is caused by a bug in persisting the floating point data, where the value is converted to an integer:

  private static class FloatValueBuffer implements NumberValueBuffer {
    private final PinotDataBuffer _dataBuffer;

    FloatValueBuffer(PinotDataBuffer dataBuffer) {
      _dataBuffer = dataBuffer;
    }

    @Override
    public void put(int position, Number value) {
      _dataBuffer.putFloat(position << 2, value.intValue()); // oops!
    }

    @Override
    public Number get(int position) {
      return _dataBuffer.getFloat(position << 2);
    }

    @Override
    public int compare(Number val1, Number val2) {
      return Float.compare(val1.floatValue(), val2.floatValue());
    }
  }

The current test for the RangeIndexCreator passes because it uses RangeIndexCreator._rangeStartArray as part of the test set up, so doesn't catch that RangeIndexCreator._rangeStartArray only has one element:

Screenshot 2021-09-15 at 14 46 51

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions