MCPcopy Create free account
hub / github.com/apache/impala / ReadFileHeader

Method ReadFileHeader

be/src/exec/avro/hdfs-avro-scanner.cc:98–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98Status HdfsAvroScanner::ReadFileHeader() {
99 DCHECK(only_parsing_header_);
100 avro_header_ = reinterpret_cast<AvroFileHeader*>(header_);
101
102 // Check version header
103 uint8_t* header;
104 RETURN_IF_FALSE(stream_->ReadBytes(
105 sizeof(AVRO_VERSION_HEADER), &header, &parse_status_));
106 if (memcmp(header, AVRO_VERSION_HEADER, sizeof(AVRO_VERSION_HEADER))) {
107 return Status(TErrorCode::AVRO_BAD_VERSION_HEADER,
108 stream_->filename(), ReadWriteUtil::HexDump(header, sizeof(AVRO_VERSION_HEADER)));
109 }
110
111 // Decode relevant metadata (encoded as Avro map)
112 RETURN_IF_ERROR(ParseMetadata());
113
114 // Read file sync marker
115 uint8_t* sync;
116 RETURN_IF_FALSE(stream_->ReadBytes(SYNC_HASH_SIZE, &sync, &parse_status_));
117 memcpy(header_->sync, sync, SYNC_HASH_SIZE);
118
119 header_->header_size = stream_->total_bytes_returned() - SYNC_HASH_SIZE;
120
121 // Transfer ownership so the memory remains valid for subsequent scanners that process
122 // the data portions of the file.
123 scan_node_->TransferToSharedStatePool(template_tuple_pool_.get());
124 return Status::OK();
125}
126
127Status HdfsAvroScanner::ParseMetadata() {
128 header_->is_compressed = false;

Callers

nothing calls this directly

Calls 8

HexDumpFunction · 0.85
OKFunction · 0.85
ReadBytesMethod · 0.80
total_bytes_returnedMethod · 0.80
getMethod · 0.65
StatusClass · 0.50
filenameMethod · 0.45

Tested by

no test coverage detected