diff options
author | Chris Dyer <redpony@gmail.com> | 2014-10-13 00:42:37 -0400 |
---|---|---|
committer | Chris Dyer <redpony@gmail.com> | 2014-10-13 00:42:37 -0400 |
commit | b1ed81ef3216b212295afa76c5d20a56fb647204 (patch) | |
tree | 9633cdc1b8a341dfa58b0b7fec0e2cae44d28835 /klm/util/stream/io.cc | |
parent | 1b17f61d359be6e1c3cea29f8c100db3bcdd73a0 (diff) |
new kenlm
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 |