MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / GetBlocks

Method GetBlocks

oneflow/core/embedding/persistent_table.cpp:419–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417
418template<typename Key, typename Engine>
419void PersistentTableImpl<Key, Engine>::GetBlocks(uint32_t num_keys, const void* keys, void* blocks,
420 uint32_t* offsets) {
421 std::lock_guard<std::recursive_mutex> lock(mutex_);
422 ParallelFor(num_keys, [&](Engine* engine, size_t start, size_t end) {
423 for (uint64_t i = start; i < end; ++i) {
424 const Key key = static_cast<const Key*>(keys)[i];
425 auto it = row_id_mapping_.find(key);
426 if (it == row_id_mapping_.end()) {
427 offsets[i] = logical_block_size_;
428 } else {
429 const uint64_t id = it->second;
430 const uint64_t block_id = id / num_values_per_block_;
431 const uint32_t id_in_block = id - block_id * num_values_per_block_;
432 const uint32_t offset_in_block = id_in_block * value_size_;
433 const uint64_t chunk_id = block_id / num_logical_blocks_per_chunk_;
434 const uint64_t block_in_chunk = block_id - chunk_id * num_logical_blocks_per_chunk_;
435 const uint64_t block_offset = block_in_chunk * logical_block_size_;
436 PosixFile& file = value_files_.at(chunk_id);
437 offsets[i] = offset_in_block;
438 engine->AsyncPread(file.fd(), BytesOffset(blocks, i * logical_block_size_),
439 logical_block_size_, block_offset);
440 }
441 }
442 });
443}
444
445template<typename Key, typename Engine>
446void PersistentTableImpl<Key, Engine>::Get(uint32_t num_keys, const void* keys, void* values,

Callers

nothing calls this directly

Calls 6

BytesOffsetFunction · 0.85
findMethod · 0.80
AsyncPreadMethod · 0.80
fdMethod · 0.80
endMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected