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

Method Open

cpp/src/arrow/ipc/feather.cc:149–173  ·  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
159 if (memcmp(buffer->data() + sizeof(uint32_t), kFeatherV1MagicBytes, magic_size)) {
160 return Status::Invalid("Feather file footer incomplete");
161 }
162
163 uint32_t metadata_length = *reinterpret_cast<const uint32_t*>(buffer->data());
164 if (size < magic_size + footer_size + metadata_length) {
165 return Status::Invalid("File is smaller than indicated metadata size");
166 }
167 ARROW_ASSIGN_OR_RAISE(
168 metadata_buffer_,
169 source->ReadAt(size - footer_size - metadata_length, metadata_length));
170
171 metadata_ = fbs::GetCTable(metadata_buffer_->data());
172 return ReadSchema();
173 }
174
175 Status ReadSchema() {
176 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