\brief A dummy FileFormat implementation
| 1575 | |
| 1576 | /// \brief A dummy FileFormat implementation |
| 1577 | class DummyFileFormat : public FileFormat { |
| 1578 | public: |
| 1579 | explicit DummyFileFormat(std::shared_ptr<Schema> schema = NULLPTR) |
| 1580 | : FileFormat(/*default_fragment_scan_options=*/nullptr), |
| 1581 | schema_(std::move(schema)) {} |
| 1582 | |
| 1583 | std::string type_name() const override { return "dummy"; } |
| 1584 | |
| 1585 | bool Equals(const FileFormat& other) const override { |
| 1586 | return type_name() == other.type_name() && |
| 1587 | schema_->Equals(checked_cast<const DummyFileFormat&>(other).schema_); |
| 1588 | } |
| 1589 | |
| 1590 | Result<bool> IsSupported(const FileSource& source) const override { return true; } |
| 1591 | |
| 1592 | Result<std::shared_ptr<Schema>> Inspect(const FileSource& source) const override { |
| 1593 | return schema_; |
| 1594 | } |
| 1595 | |
| 1596 | /// \brief Open a file for scanning (always returns an empty generator) |
| 1597 | Result<RecordBatchGenerator> ScanBatchesAsync( |
| 1598 | const std::shared_ptr<ScanOptions>& options, |
| 1599 | const std::shared_ptr<FileFragment>& fragment) const override { |
| 1600 | return MakeEmptyGenerator<std::shared_ptr<RecordBatch>>(); |
| 1601 | } |
| 1602 | |
| 1603 | Result<std::shared_ptr<FileWriter>> MakeWriter( |
| 1604 | std::shared_ptr<io::OutputStream> destination, std::shared_ptr<Schema> schema, |
| 1605 | std::shared_ptr<FileWriteOptions> options, |
| 1606 | fs::FileLocator destination_locator) const override { |
| 1607 | return Status::NotImplemented("writing fragment of DummyFileFormat"); |
| 1608 | } |
| 1609 | |
| 1610 | std::shared_ptr<FileWriteOptions> DefaultWriteOptions() override { return nullptr; } |
| 1611 | |
| 1612 | protected: |
| 1613 | std::shared_ptr<Schema> schema_; |
| 1614 | }; |
| 1615 | |
| 1616 | class JSONRecordBatchFileFormat : public FileFormat { |
| 1617 | public: |