/** * @brief Extract a part of a big-endian byte array of given length as KeySlice. * @param[in] be_bytes a big-endian byte array. * @param[in] slice_length key length for this slice. * @return normalized value that preserves the value-order * @ingroup MASSTREE */ inline KeySlice slice_key(const void* be_bytes, uint16_t slice_length) { if (slice_length >= 8) { return normalize_be_bytes_full(be_bytes); } else { return normalize_be_bytes_fragment(be_bytes, slice_length); } }
/** * @brief Extract a part of a big-endian byte array of given length as KeySlice. * @param[in] be_bytes a big-endian byte array. * @param[in] key_length total key length. * @param[in] current_layer extract a slice for this layer. * @return normalized value that preserves the value-order * @ingroup MASSTREE */ inline KeySlice slice_layer(const void* be_bytes, KeyLength key_length, Layer current_layer) { const KeyLength skipped = current_layer * sizeof(KeySlice); const KeyLength remainder_length = key_length - skipped; const char* casted = reinterpret_cast<const char*>(be_bytes); if (remainder_length >= sizeof(KeySlice)) { return normalize_be_bytes_full(casted + skipped); } else { return normalize_be_bytes_fragment(casted + skipped, remainder_length); } }
/** * @brief Extract a part of a big-endian byte array of given length as KeySlice. * @param[in] be_bytes a big-endian byte array. * @param[in] key_length total key length. * @param[in] current_layer extract a slice for this layer. * @return normalized value that preserves the value-order * @ingroup MASSTREE */ inline KeySlice slice_layer(const void* be_bytes, uint16_t key_length, uint8_t current_layer) { uint8_t remaining_length = key_length - current_layer * 8; if (remaining_length >= 8) { return normalize_be_bytes_full(reinterpret_cast<const char*>(be_bytes) + current_layer * 8); } else { return normalize_be_bytes_fragment( reinterpret_cast<const char*>(be_bytes) + current_layer * 8, remaining_length); } }