1#include "duckdb/common/serializer/buffered_deserializer.hpp"
2
3#include <cstring>
4
5namespace duckdb {
6
7BufferedDeserializer::BufferedDeserializer(data_ptr_t ptr, idx_t data_size) : ptr(ptr), endptr(ptr + data_size) {
8}
9
10BufferedDeserializer::BufferedDeserializer(BufferedSerializer &serializer)
11 : BufferedDeserializer(serializer.data, serializer.maximum_size) {
12 SetVersion(serializer.GetVersion());
13}
14
15void BufferedDeserializer::ReadData(data_ptr_t buffer, idx_t read_size) {
16 if (ptr + read_size > endptr) {
17 throw SerializationException("Failed to deserialize: not enough data in buffer to fulfill read request");
18 }
19 memcpy(dest: buffer, src: ptr, n: read_size);
20 ptr += read_size;
21}
22
23ClientContext &BufferedContextDeserializer::GetContext() {
24 return context;
25}
26
27} // namespace duckdb
28