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

Method __construct

lang/php/lib/DataFile/AvroDataIOReader.php:77–101  ·  view source on GitHub ↗

* @param AvroIO $io source from which to read * @param AvroIODatumReader $datum_reader reader that understands * the data schema * @throws AvroDataIOException if $io is not an instance of AvroIO * or the codec specified in the header * is not supported * @uses readHeader()

($io, $datum_reader)

Source from the content-addressed store, hash-verified

75 * @uses readHeader()
76 */
77 public function __construct($io, $datum_reader)
78 {
79
80 if (!($io instanceof AvroIO)) {
81 throw new AvroDataIOException('io must be instance of AvroIO');
82 }
83
84 $this->io = $io;
85 $this->decoder = new AvroIOBinaryDecoder($this->io);
86 $this->datum_reader = $datum_reader;
87 $this->readHeader();
88
89 $codec = $this->metadata[AvroDataIO::METADATA_CODEC_ATTR] ?? null;
90 if ($codec && !AvroDataIO::isValidCodec($codec)) {
91 throw new AvroDataIOException(sprintf('Unknown codec: %s', $codec));
92 }
93 $this->codec = $codec;
94
95 $this->block_count = 0;
96 // FIXME: Seems unsanitary to set writers_schema here.
97 // Can't constructor take it as an argument?
98 $this->datum_reader->setWritersSchema(
99 AvroSchema::parse($this->metadata[AvroDataIO::METADATA_SCHEMA_ATTR])
100 );
101 }
102
103 /**
104 * Reads header of object container

Callers

nothing calls this directly

Calls 4

readHeaderMethod · 0.95
isValidCodecMethod · 0.80
setWritersSchemaMethod · 0.80
parseMethod · 0.65

Tested by

no test coverage detected