Variant field names not being ordered correctly via UTF-8 byte order
- 主要语言
- Java
- 星标
- 3.1k
- 派生
- 1.6k
- 平均合并
- 3 天 12 小时
- 30 天内合并 PR
- 33
描述
### Describe the bug, including details regarding any error messages, version, and platform.
The Variant spec requires the field ids in an object's header to be sorted by the
**UTF-8 byte order** of the field names, so a reader can binary-search them.
`VariantBuilder` sorted the fields — and `Variant.getFieldByKey` binary-searched them —
using `String.compareTo`, which orders by **UTF-16 code units**, not UTF-8 bytes.
The two orderings are identical for all field names in the Basic Multilingual Plane, but
they diverge for names containing supplementary-plane characters (U+10000 and above):
`String.compareTo` orders a leading high surrogate (0xD800–0xDBFF) before code points in
U+E000..U+FFFF, whereas UTF-8 byte order (and the spec) orders them after. Consequences:
- An object parquet-java builds with such keys has field ids sorted in an order that
violates the spec.
- A spec-compliant reader (e.g. the Apache Arrow C++/Rust/Go Variant readers) binary-searching
that object can fail to find fields.
- Conversely, parquet-java's own binary search fails to find a supplementary-plane key in an
object produced by a spec-compliant writer.
The bug only surfaces when an object both contains a supplementary-plane key and is large
enough to take the binary-search path, so it has gone unnoticed.
### Component(s)
Core
贡献指南
这个仓库没有索引到贡献指南
调研方向
从 VariantBuilder 和 Variant.getFieldByKey 开始,然后使用一个字段名位于补充平面的对象,并提供足够多的字段以触发二分查找,从而重现该问题。验证字段 ID 是否遵循 UTF-8 字节顺序,并验证对于由 parquet-java 和符合规范的 writers 生成的对象,查找都能成功。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- data-engineering
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 68/100