MCPcopy Create free account
hub / github.com/apache/arrow / SafeLoadUpTo8Bytes

Function SafeLoadUpTo8Bytes

cpp/src/arrow/compute/util.cc:33–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31namespace bit_util {
32
33inline uint64_t SafeLoadUpTo8Bytes(const uint8_t* bytes, int num_bytes) {
34 // This will not be correct on big-endian architectures.
35#if !ARROW_LITTLE_ENDIAN
36 ARROW_DCHECK(false);
37#endif
38 ARROW_DCHECK(num_bytes >= 0 && num_bytes <= 8);
39 if (num_bytes == 8) {
40 return util::SafeLoad(reinterpret_cast<const uint64_t*>(bytes));
41 } else {
42 uint64_t word = 0;
43 for (int i = 0; i < num_bytes; ++i) {
44 word |= static_cast<uint64_t>(bytes[i]) << (8 * i);
45 }
46 return word;
47 }
48}
49
50inline void SafeStoreUpTo8Bytes(uint8_t* bytes, int num_bytes, uint64_t value) {
51 // This will not be correct on big-endian architectures.

Callers 2

bits_to_indexes_internalFunction · 0.85
bytes_to_bitsFunction · 0.85

Calls 1

SafeLoadFunction · 0.85

Tested by

no test coverage detected