| 147 | class 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; |
nothing calls this directly
no test coverage detected