MCPcopy Create free account
hub / github.com/apache/arrow / Open

Method Open

cpp/src/arrow/ipc/feather.cc:149–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147class ReaderV1 : public Reader {
148 public:
149 Status Open(const std::shared_ptr<io::RandomAccessFile>& source) {
150 source_ = source;
151
152 ARROW_ASSIGN_OR_RAISE(int64_t size, source->GetSize());
153 int magic_size = static_cast<int>(strlen(kFeatherV1MagicBytes));
154 int footer_size = magic_size + static_cast<int>(sizeof(uint32_t));
155
156 // Now get the footer and verify
157 ARROW_ASSIGN_OR_RAISE(auto buffer, source->ReadAt(size - footer_size, footer_size,
158 /*allow_short_read=*/false));
159
160 if (memcmp(buffer->data() + sizeof(uint32_t), kFeatherV1MagicBytes, magic_size)) {
161 return Status::Invalid("Feather file footer incomplete");
162 }
163
164 uint32_t metadata_length = *reinterpret_cast<const uint32_t*>(buffer->data());
165 if (size < magic_size + footer_size + metadata_length) {
166 return Status::Invalid("File is smaller than indicated metadata size");
167 }
168 ARROW_ASSIGN_OR_RAISE(metadata_buffer_,
169 source->ReadAt(size - footer_size - metadata_length,
170 metadata_length, /*allow_short_read=*/false));
171
172 metadata_ = fbs::GetCTable(metadata_buffer_->data());
173 return ReadSchema();
174 }
175
176 Status ReadSchema() {
177 std::vector<std::shared_ptr<Field>> fields;

Callers

nothing calls this directly

Calls 6

GetCTableFunction · 0.85
ARROW_ASSIGN_OR_RAISEFunction · 0.70
ReadSchemaFunction · 0.70
InvalidFunction · 0.50
dataMethod · 0.45
ReadAtMethod · 0.45

Tested by

no test coverage detected