Skip to content

[common] Fix SliceComparator on BINARY and VARBINARY fields (#8873) - #8874

Open
jordepic wants to merge 1 commit into
apache:masterfrom
jordepic:fix-binary-pk-slice-comparator
Open

[common] Fix SliceComparator on BINARY and VARBINARY fields (#8873)#8874
jordepic wants to merge 1 commit into
apache:masterfrom
jordepic:fix-binary-pk-slice-comparator

Conversation

@jordepic

Copy link
Copy Markdown
Contributor

Purpose

Fixes #8873.

TypeCheckUtils.isComparable admits BINARY and VARBINARY, and primary keys may contain them, but SliceComparator cast every field value to Comparablebyte[] is not, so any sorted-lookup-store seek over a binary key field (lookup compaction, deletion-vector maintenance, lookup changelog producer) threw ClassCastException. Compare binary fields with SortUtil.compareBinary, the same unsigned lexicographic order BinaryRow uses, so lookup files order consistently with the rest of the merge tree.

Tests

RowCompactedSerializerTest.BinaryFieldTest: serializer round-trips over an (INT, BYTES) row type plus a slice-comparator test covering less/greater/equal and the unsigned edge (0xFF orders above 0x01).

API and Format

No changes.

Documentation

No changes.

@jordepic

Copy link
Copy Markdown
Contributor Author

cc @JingsongLi — legal binary primary keys crash the sorted lookup store's comparator the first time lookup compaction probes a higher level; the fix reuses SortUtil.compareBinary so lookup files order the same way BinaryRow does.

)

TypeCheckUtils.isComparable admits BINARY and VARBINARY, and primary keys
may contain them, but SliceComparator cast every field value to Comparable
— byte[] is not, so any sorted-lookup-store comparison over a binary key
field (lookup compaction, deletion-vector maintenance, lookup changelog
producer) threw ClassCastException. Compare binary fields with
SortUtil.compareBinary, the same unsigned lexicographic order BinaryRow
uses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] SliceComparator throws ClassCastException on BINARY/VARBINARY primary-key fields

1 participant