| 144 | std::shared_ptr<Schema> schema() const override { return schema_; } |
| 145 | |
| 146 | Status ReadNext(std::shared_ptr<RecordBatch>* out) override { |
| 147 | std::unique_ptr<liborc::ColumnVectorBatch> batch; |
| 148 | std::unique_ptr<RecordBatchBuilder> builder; |
| 149 | |
| 150 | ORC_BEGIN_CATCH_NOT_OK |
| 151 | batch = row_reader_->createRowBatch(batch_size_); |
| 152 | |
| 153 | const liborc::Type& type = row_reader_->getSelectedType(); |
| 154 | if (!row_reader_->next(*batch)) { |
| 155 | out->reset(); |
| 156 | return Status::OK(); |
| 157 | } |
| 158 | |
| 159 | ARROW_ASSIGN_OR_RAISE(builder, |
| 160 | RecordBatchBuilder::Make(schema_, pool_, batch->numElements)); |
| 161 | // The top-level type must be a struct to read into an arrow table |
| 162 | const auto& struct_batch = checked_cast<liborc::StructVectorBatch&>(*batch); |
| 163 | |
| 164 | for (int i = 0; i < builder->num_fields(); i++) { |
| 165 | RETURN_NOT_OK(AppendBatch(type.getSubtype(i), struct_batch.fields[i], 0, |
| 166 | batch->numElements, builder->GetField(i))); |
| 167 | } |
| 168 | ORC_END_CATCH_NOT_OK |
| 169 | |
| 170 | return builder->Flush().Value(out); |
| 171 | } |
| 172 | |
| 173 | private: |
| 174 | std::unique_ptr<liborc::RowReader> row_reader_; |