ClickHouse/src/IO/ReadHelpersArena.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
604 B
C++
Raw Normal View History

2023-04-14 08:35:33 +00:00
#pragma once
2023-04-12 13:36:23 +00:00
#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);
}
}