1 | #include "duckdb/common/serializer/buffered_deserializer.hpp" |
---|---|
2 | |
3 | #include <cstring> |
4 | |
5 | namespace duckdb { |
6 | |
7 | BufferedDeserializer::BufferedDeserializer(data_ptr_t ptr, idx_t data_size) : ptr(ptr), endptr(ptr + data_size) { |
8 | } |
9 | |
10 | BufferedDeserializer::BufferedDeserializer(BufferedSerializer &serializer) |
11 | : BufferedDeserializer(serializer.data, serializer.maximum_size) { |
12 | SetVersion(serializer.GetVersion()); |
13 | } |
14 | |
15 | void 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 | |
23 | ClientContext &BufferedContextDeserializer::GetContext() { |
24 | return context; |
25 | } |
26 | |
27 | } // namespace duckdb |
28 |