blob: e8074372fd73754516d54aa0971b85002ba77695 (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#include "rope_over_buffer.h"
#include <yql/essentials/utils/yql_panic.h>
namespace NYql {
namespace {
class TContigousChunkOverBuf : public IContiguousChunk {
public:
TContigousChunkOverBuf(const std::shared_ptr<const void>& owner, TContiguousSpan span)
: Owner_(owner)
, Span_(span)
{
}
private:
TContiguousSpan GetData() const override {
return Span_;
}
TMutableContiguousSpan GetDataMut() override {
YQL_ENSURE(false, "Payload mutation is not supported");
}
size_t GetOccupiedMemorySize() const override {
return Span_.GetSize();
}
const std::shared_ptr<const void> Owner_;
const TContiguousSpan Span_;
};
} // namespace
TRope MakeReadOnlyRope(const std::shared_ptr<const void>& owner, const char* data, size_t size) {
if (!size) {
return TRope();
}
return TRope(new TContigousChunkOverBuf(owner, {data, size}));
}
} // namespace NYql
|