* Reads header of object container * @throws AvroDataIOException if the file is not an Avro data file. */
()
| 105 | * @throws AvroDataIOException if the file is not an Avro data file. |
| 106 | */ |
| 107 | private function readHeader() |
| 108 | { |
| 109 | $this->seek(0, AvroIO::SEEK_SET); |
| 110 | |
| 111 | $magic = $this->read(AvroDataIO::magicSize()); |
| 112 | |
| 113 | if (strlen($magic) < AvroDataIO::magicSize()) { |
| 114 | throw new AvroDataIOException( |
| 115 | 'Not an Avro data file: shorter than the Avro magic block' |
| 116 | ); |
| 117 | } |
| 118 | |
| 119 | if (AvroDataIO::magic() != $magic) { |
| 120 | throw new AvroDataIOException( |
| 121 | sprintf( |
| 122 | 'Not an Avro data file: %s does not match %s', |
| 123 | $magic, |
| 124 | AvroDataIO::magic() |
| 125 | ) |
| 126 | ); |
| 127 | } |
| 128 | |
| 129 | $this->metadata = $this->datum_reader->readData( |
| 130 | AvroDataIO::metadataSchema(), |
| 131 | AvroDataIO::metadataSchema(), |
| 132 | $this->decoder |
| 133 | ); |
| 134 | $this->sync_marker = $this->read(AvroDataIO::SYNC_SIZE); |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * @uses AvroIO::seek() |
no test coverage detected