the wrapped array of bytes
Implementation detail: This equals method is defined in terms of the wrapped array, which is a mutable
field.
Implementation detail: This equals method is defined in terms of the wrapped array, which is a mutable
field. In general such a definition of equals is considered bad practice, but in our case we justify
the use of a mutable field because the contract of Bytes requires that the wrapped array must never
be modified (and we intentionally do not create a defensive, immutable copy because of performance
considerations).
A wrapper for
Array[Byte]that provides sane implementations ofhashCode,equals, andtoString. The wrapped array of bytes is assumed to be never modified.Note: Unfortunately we cannot make Bytes a value class because a value class may not override the
hashCodeandequalsmethods (cf. SIP-15, criterion 4).Alternatives
Instead of wrapping an
Array[Byte]with this class you can also convert anArray[Byte]to aSeq[Byte]via Scala'stoSeqmethod:Like Bytes, a
Seq[Byte]has sanehashCode,equals, andtoStringimplementations.Performance-wise we found that a
Seq[Byte]is comparable to Bytes. For example, aCMS[Seq[Byte]]was measured to be only slightly slower thanCMS[Bytes](think: single-digit percentages).the wrapped array of bytes
MinHasher