From 57c20d143e8a438cd76b9fdc3ca2e8ee3ac1f32a Mon Sep 17 00:00:00 2001 From: denplusplus <denplusplus@yandex-team.ru> Date: Thu, 10 Feb 2022 16:47:34 +0300 Subject: Restoring authorship annotation for <denplusplus@yandex-team.ru>. Commit 1 of 2. --- library/cpp/on_disk/chunks/reader.h | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'library/cpp/on_disk/chunks/reader.h') diff --git a/library/cpp/on_disk/chunks/reader.h b/library/cpp/on_disk/chunks/reader.h index c5fe783319..66b0155995 100644 --- a/library/cpp/on_disk/chunks/reader.h +++ b/library/cpp/on_disk/chunks/reader.h @@ -1,31 +1,31 @@ -#pragma once - +#pragma once + #include <util/generic/array_ref.h> -#include <util/generic/vector.h> -#include <util/generic/yexception.h> - -class TBlob; - -class TChunkedDataReader { +#include <util/generic/vector.h> +#include <util/generic/yexception.h> + +class TBlob; + +class TChunkedDataReader { public: TChunkedDataReader(const TBlob& blob); - + inline const void* GetBlock(size_t index) const { CheckIndex(index); return Offsets[index]; } - + inline size_t GetBlockLen(size_t index) const { CheckIndex(index); - + if (Version == 0) { if (index + 1 < Offsets.size()) { return Offsets[index + 1] - Offsets[index]; - } - + } + return Size - (Offsets.back() - Offsets.front()); - } - + } + return Lengths[index]; } @@ -41,17 +41,17 @@ public: inline size_t GetBlocksCount() const { return Offsets.size(); } - + private: inline void CheckIndex(size_t index) const { if (index >= GetBlocksCount()) { ythrow yexception() << "requested block " << index << " of " << GetBlocksCount() << " blocks"; - } + } } - + private: ui64 Version = 0; TVector<const char*> Offsets; TVector<size_t> Lengths; size_t Size = 0; -}; +}; -- cgit v1.2.3