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

Function CopyBitsInInteger

cpp/src/arrow/util/bit_util.h:197–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195/// guarantee that the range of bits to copy does not cover the whole range.
196template <typename Uint, bool kAllowFullCopy = true>
197[[nodiscard]] constexpr Uint CopyBitsInInteger(const CopyBitsParams<Uint>& params) {
198 constexpr auto kUintSizeBits = static_cast<int>(sizeof(Uint) * 8);
199 assert(params.start <= params.end);
200 assert(params.start < kUintSizeBits);
201 assert(params.end <= kUintSizeBits);
202
203 const int length = params.end - params.start;
204 if constexpr (kAllowFullCopy) {
205 if (length == kUintSizeBits) {
206 return params.src;
207 }
208 }
209 assert(length < kUintSizeBits);
210 const Uint mask =
211 static_cast<Uint>(LeastSignificantBitMask<Uint, false>(length) << params.start);
212 return (~mask & params.dst) | (mask & params.src);
213}
214
215static inline void ClearBit(uint8_t* bits, int64_t i) {
216 bits[i / 8] &= kFlippedBitmask[i % 8];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected