To store the length field of an external binary ID, the following encoding is used:
which allows to store numbers between 0 and 212 - 1.
The current implementation of SegmentWriter allows the length of binary IDs to range between 0 and 213 - 1, writing incorrect data when the length of the binary ID ranges from 212 to 213 - 1.
When reading this incorrect data back, an IllegalStateException is thrown complaining that the first byte of the length fields has an unexpected value record type. See
OAK-1842 for an example.