diff options
author | max42 <max42@yandex-team.com> | 2023-07-29 00:02:16 +0300 |
---|---|---|
committer | max42 <max42@yandex-team.com> | 2023-07-29 00:02:16 +0300 |
commit | 73b89de71748a21e102d27b9f3ed1bf658766cb5 (patch) | |
tree | 188bbd2d622fa91cdcbb1b6d6d77fbc84a0646f5 /library/cpp/skiff/zerocopy_output_writer-inl.h | |
parent | 528e321bcc2a2b67b53aeba58c3bd88305a141ee (diff) | |
download | ydb-73b89de71748a21e102d27b9f3ed1bf658766cb5.tar.gz |
YT-19210: expose YQL shared library for YT.
After this, a new target libyqlplugin.so appears. in open-source cmake build.
Diff in open-source YDB repo looks like the following: https://paste.yandex-team.ru/f302bdb4-7ef2-4362-91c7-6ca45f329264
Diffstat (limited to 'library/cpp/skiff/zerocopy_output_writer-inl.h')
-rw-r--r-- | library/cpp/skiff/zerocopy_output_writer-inl.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/library/cpp/skiff/zerocopy_output_writer-inl.h b/library/cpp/skiff/zerocopy_output_writer-inl.h new file mode 100644 index 0000000000..6bd067c9fa --- /dev/null +++ b/library/cpp/skiff/zerocopy_output_writer-inl.h @@ -0,0 +1,51 @@ +#pragma once +#ifndef ZEROCOPY_OUTPUT_WRITER_INL_H_ +#error "Direct inclusion of this file is not allowed, include zerocopy_output_writer.h" +// For the sake of sane code completion. +#include "zerocopy_output_writer.h" +#endif + +#include <util/system/yassert.h> + +namespace NSkiff { + +//////////////////////////////////////////////////////////////////////////////// + +char* TZeroCopyOutputStreamWriter::Current() const +{ + return Current_; +} + +ui64 TZeroCopyOutputStreamWriter::RemainingBytes() const +{ + return RemainingBytes_; +} + +void TZeroCopyOutputStreamWriter::Advance(size_t bytes) +{ + Y_VERIFY(bytes <= RemainingBytes_); + Current_ += bytes; + RemainingBytes_ -= bytes; +} + +void TZeroCopyOutputStreamWriter::Write(const void* buffer, size_t length) +{ + if (length > RemainingBytes_) { + UndoRemaining(); + Output_->Write(buffer, length); + TotalWrittenBlockSize_ += length; + ObtainNextBlock(); + } else { + memcpy(Current_, buffer, length); + Advance(length); + } +} + +ui64 TZeroCopyOutputStreamWriter::GetTotalWrittenSize() const +{ + return TotalWrittenBlockSize_ - RemainingBytes_; +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NSkiff |