MCPcopy Create free account
hub / github.com/apache/avro / readHeader

Method readHeader

lang/php/lib/DataFile/AvroDataIOReader.php:107–135  ·  view source on GitHub ↗

* Reads header of object container * @throws AvroDataIOException if the file is not an Avro data file. */

()

Source from the content-addressed store, hash-verified

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()

Callers 1

__constructMethod · 0.95

Calls 6

seekMethod · 0.95
readMethod · 0.95
magicSizeMethod · 0.80
magicMethod · 0.80
metadataSchemaMethod · 0.80
readDataMethod · 0.45

Tested by

no test coverage detected