diff options
author | Wu, Ke <wuke@cs.umd.edu> | 2014-12-17 16:11:38 -0500 |
---|---|---|
committer | Wu, Ke <wuke@cs.umd.edu> | 2014-12-17 16:11:38 -0500 |
commit | 7468e8d85e99b4619442c7afaf4a0d92870111bb (patch) | |
tree | a6f17da7c69048c8900260b5490bb9d8611be3bb /klm/util/stream/io.cc | |
parent | b6dd5a683db9dda2d634dd2fdb76606819594901 (diff) | |
parent | 1a79175f9a101d46cf27ca921213d5dd9300518f (diff) |
Merge with upstream
Diffstat (limited to 'klm/util/stream/io.cc')
-rw-r--r-- | klm/util/stream/io.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/klm/util/stream/io.cc b/klm/util/stream/io.cc index 0459f706..c64004c0 100644 --- a/klm/util/stream/io.cc +++ b/klm/util/stream/io.cc @@ -36,12 +36,12 @@ void PRead::Run(const ChainPosition &position) { Link link(position); uint64_t offset = 0; for (; offset + block_size64 < size; offset += block_size64, ++link) { - PReadOrThrow(file_, link->Get(), block_size, offset); + ErsatzPRead(file_, link->Get(), block_size, offset); link->SetValidSize(block_size); } // size - offset is <= block_size, so it casts to 32-bit fine. if (size - offset) { - PReadOrThrow(file_, link->Get(), size - offset, offset); + ErsatzPRead(file_, link->Get(), size - offset, offset); link->SetValidSize(size - offset); ++link; } @@ -62,5 +62,15 @@ void WriteAndRecycle::Run(const ChainPosition &position) { } } +void PWriteAndRecycle::Run(const ChainPosition &position) { + const std::size_t block_size = position.GetChain().BlockSize(); + uint64_t offset = 0; + for (Link link(position); link; ++link) { + ErsatzPWrite(file_, link->Get(), link->ValidSize(), offset); + offset += link->ValidSize(); + link->SetValidSize(block_size); + } +} + } // namespace stream } // namespace util |