19 #ifndef avro_Reader_hh__
20 #define avro_Reader_hh__
24 #include <boost/noncopyable.hpp>
29 #include "Validator.hh"
30 #include "buffer/BufferReader.hh"
39 template<
class Val
idatorType>
45 explicit ReaderImpl(
const InputBuffer &buffer) :
54 void readValue(
Null &) {
58 void readValue(
bool &val) {
65 void readValue(int32_t &val) {
66 validator_.checkTypeExpected(
AVRO_INT);
67 uint32_t encoded =
static_cast<uint32_t
>(readVarInt());
68 val = decodeZigzag32(encoded);
71 void readValue(int64_t &val) {
73 uint64_t encoded = readVarInt();
74 val = decodeZigzag64(encoded);
77 void readValue(
float &val) {
87 void readValue(
double &val) {
97 void readValue(std::string &val) {
99 size_t size =
static_cast<size_t>(readSize());
100 reader_.read(val, size);
103 void readBytes(std::vector<uint8_t> &val) {
105 size_t size =
static_cast<size_t>(readSize());
107 reader_.read(reinterpret_cast<char *>(&val[0]), size);
110 void readFixed(uint8_t *val,
size_t size) {
111 validator_.checkFixedSizeExpected(size);
112 reader_.read(reinterpret_cast<char *>(val), size);
116 void readFixed(uint8_t (&val)[N]) {
117 this->readFixed(val, N);
121 void readFixed(boost::array<uint8_t, N> &val) {
122 this->readFixed(val.c_array(), N);
128 validator_.setCount(1);
131 void readRecordEnd() {
134 validator_.setCount(0);
137 int64_t readArrayBlockSize() {
142 int64_t readUnion() {
152 int64_t readMapBlockSize() {
153 validator_.checkTypeExpected(
AVRO_MAP);
157 Type nextType()
const {
158 return validator_.nextTypeExpected();
161 bool currentRecordName(std::string &name)
const {
162 return validator_.getCurrentRecordName(name);
165 bool nextFieldName(std::string &name)
const {
166 return validator_.getNextFieldName(name);
171 uint64_t readVarInt() {
172 uint64_t encoded = 0;
177 uint64_t newbits =
static_cast<uint64_t
>(val & 0x7f) << shift;
180 }
while (val & 0x80);
186 uint64_t encoded = readVarInt();
187 int64_t size = decodeZigzag64(encoded);
191 int64_t readCount() {
193 int64_t count = readSize();
194 validator_.setCount(count);
198 ValidatorType validator_;
199 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:31
Functions for encoding and decoding integers with zigzag compression.
Parses from an avro encoding to the requested type.
Definition: Reader.hh:40
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