Skip to content

Commit

Permalink
load_from_hdfs adopts zero-copy method
Browse files Browse the repository at this point in the history
  • Loading branch information
luliyucoordinate committed Jul 14, 2022
1 parent bdd5da4 commit 4579ee6
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,10 @@ class TableWrapperOptimized final : public TableWrapperBase<K, V> {

while (i < file_size) {
TF_RETURN_IF_ERROR(reader.ReadNBytes(record_len, &content));
K k;
std::memcpy(&k, reinterpret_cast<uint8*>(content.data()), sizeof(K));

ValueType value_vec;
std::memcpy(value_vec.data(),
reinterpret_cast<uint8*>(content.data()) + sizeof(K),
value_len);
table_->insert_or_assign(k, value_vec);
K* k = reinterpret_cast<K*>(content.data());
ValueType* value_vec =
reinterpret_cast<ValueType*>(content.data() + sizeof(K));
table_->insert_or_assign(*k, *value_vec);
i += record_len;
}
return Status::OK();
Expand Down

0 comments on commit 4579ee6

Please sign in to comment.