blob: b88d5c037d4858a72c406851ceb7900e1a2e0784 (
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
|
#pragma once
#include <IO/ReadBuffer.h>
#include <IO/ReadHelpers.h>
#include <IO/VarInt.h>
#include <base/StringRef.h>
#include <Common/Arena.h>
namespace DB
{
namespace ErrorCodes
{
extern const int TOO_LARGE_STRING_SIZE;
}
inline StringRef readStringBinaryInto(Arena & arena, ReadBuffer & buf)
{
size_t size = 0;
readVarUInt(size, buf);
if (unlikely(size > DEFAULT_MAX_STRING_SIZE))
throw Exception(ErrorCodes::TOO_LARGE_STRING_SIZE, "Too large string size.");
char * data = arena.alloc(size);
buf.readStrict(data, size);
return StringRef(data, size);
}
}
|