19 #ifndef avro_Reader_hh__ 20 #define avro_Reader_hh__ 25 #include <boost/noncopyable.hpp> 30 #include "Validator.hh" 31 #include "buffer/BufferReader.hh" 40 template<
class Val
idatorType>
46 explicit ReaderImpl(
const InputBuffer &buffer) :
55 void readValue(
Null &) {
59 void readValue(
bool &val) {
66 void readValue(int32_t &val) {
67 validator_.checkTypeExpected(
AVRO_INT);
68 uint32_t encoded =
static_cast<uint32_t
>(readVarInt());
69 val = decodeZigzag32(encoded);
72 void readValue(int64_t &val) {
74 uint64_t encoded = readVarInt();
75 val = decodeZigzag64(encoded);
78 void readValue(
float &val) {
88 void readValue(
double &val) {
98 void readValue(std::string &val) {
100 size_t size =
static_cast<size_t>(readSize());
101 reader_.read(val, size);
104 void readBytes(std::vector<uint8_t> &val) {
106 size_t size =
static_cast<size_t>(readSize());
108 reader_.read(reinterpret_cast<char *>(val.data()), size);
111 void readFixed(uint8_t *val,
size_t size) {
112 validator_.checkFixedSizeExpected(size);
113 reader_.read(reinterpret_cast<char *>(val), size);
117 void readFixed(uint8_t (&val)[N]) {
118 this->readFixed(val, N);
122 void readFixed(std::array<uint8_t, N> &val) {
123 this->readFixed(val.data(), N);
129 validator_.setCount(1);
132 void readRecordEnd() {
135 validator_.setCount(0);
138 int64_t readArrayBlockSize() {
143 int64_t readUnion() {
153 int64_t readMapBlockSize() {
154 validator_.checkTypeExpected(
AVRO_MAP);
158 Type nextType()
const {
159 return validator_.nextTypeExpected();
162 bool currentRecordName(std::string &name)
const {
163 return validator_.getCurrentRecordName(name);
166 bool nextFieldName(std::string &name)
const {
167 return validator_.getNextFieldName(name);
172 uint64_t readVarInt() {
173 uint64_t encoded = 0;
178 uint64_t newbits =
static_cast<uint64_t
>(val & 0x7f) << shift;
181 }
while (val & 0x80);
187 uint64_t encoded = readVarInt();
188 int64_t size = decodeZigzag64(encoded);
192 int64_t readCount() {
194 int64_t count = readSize();
195 validator_.setCount(count);
199 ValidatorType validator_;
200 BufferReader reader_;
Type
The "type" for the schema.
Definition: Types.hh:31
A bunch of templates and specializations for encoding and decoding specific types.
Definition: AvroParse.hh:30
Functions for encoding and decoding integers with zigzag compression.
Parses from an avro encoding to the requested type.
Definition: Reader.hh:41
define a type to identify Null in template functions
Definition: Types.hh:102
A ValidSchema is basically a non-mutable Schema that has passed some minumum of sanity checks...
Definition: ValidSchema.hh:40