MCPcopy Create free account
hub / github.com/activeloopai/deeplake / set_from_span

Method set_from_span

cpp/icm/bit_vector.hpp:2239–2264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2237 // Set bit_vector_view from std::span of numeric values (converts to bool)
2238 template <typename T>
2239 void set_from_span(std::span<const T> values)
2240 {
2241 ASSERT(values.size() == size_);
2242
2243 // Process 64 bits at a time for better performance
2244 int64_t full_blocks = size_ / bits_per_block;
2245 int64_t remaining_bits = size_ % bits_per_block;
2246
2247 // Process complete 64-bit blocks
2248 for (int64_t block = 0; block < full_blocks; ++block) {
2249 const T* block_start = values.data() + block * bits_per_block;
2250 uint64_t mask = bit_vector::bools_to_mask_64(block_start);
2251 int64_t global_block_idx = start_block_ + block;
2252 original_bv_->data()[global_block_idx] = mask;
2253 }
2254
2255 // Process remaining bits in the last block
2256 if (remaining_bits > 0) {
2257 const T* last_block_start = values.data() + full_blocks * bits_per_block;
2258 uint64_t mask = bit_vector::bools_to_mask_64(last_block_start, remaining_bits);
2259 // Clear unused bits (defensive, should already be handled by count parameter)
2260 mask &= (uint64_t(1) << remaining_bits) - 1;
2261 int64_t global_block_idx = start_block_ + full_blocks;
2262 original_bv_->data()[global_block_idx] = mask;
2263 }
2264 }
2265
2266private:
2267 // Helper method to get global index

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected