aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/memory/chunked_input_stream.h
blob: baef2a4c66f44920819aa3dc6e3cc6cfc8c6a143 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once

#include "ref.h"

#include <util/stream/zerocopy.h>

namespace NYT {

////////////////////////////////////////////////////////////////////////////////

class TChunkedInputStream
    : public IZeroCopyInput
{
public:
    explicit TChunkedInputStream(std::vector<TSharedRef> blocks);

    size_t DoNext(const void** ptr, size_t len) override;

private:
    const std::vector<TSharedRef> Blocks_;
    size_t Index_ = 0;
    size_t Position_ = 0;

    void SkipCompletedBlocks();
};

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT