diff options
author | Tor Egge <Tor.Egge@online.no> | 2023-03-22 11:52:05 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2023-03-22 11:52:05 +0100 |
commit | f147a79d4c4d0b6a9239a737501abb044e5e49b9 (patch) | |
tree | 7ec2fe62b5363eab6c6e65d09b8be6081a285e7b | |
parent | a74fc174fd55f39aaaf4fbe1d68ce5a2e7719999 (diff) |
Add comment describing serialization format for sort blobs generated from raw values.
-rw-r--r-- | searchlib/src/vespa/searchlib/attribute/raw_attribute.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/raw_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/raw_attribute.cpp index f8c6768ba5b..d4a0ef93e47 100644 --- a/searchlib/src/vespa/searchlib/attribute/raw_attribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/raw_attribute.cpp @@ -20,6 +20,16 @@ unsigned char remap(unsigned char val) return (desc ? (0xff - val) : val); } +/* + * Serialize raw data to a sort blob that can be passed to memcmp. + * + * End of raw data is encoded as 0, while a bias of 1 is added to raw data byte values to + * differentiate from end of raw data. To avoid wraparound, 0xfe and 0xff are encoded + * as two bytes (0xfe => [0xff, 0xfe] and 0xff => [0xff, 0xff]). + * + * If sort order is descending, all encoded values are inverted, this + * is done by remap function above. + */ template <bool desc> long serialize_for_sort(vespalib::ConstArrayRef<char> raw, void* serTo, long available) { |