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

Method ReadNext

cpp/src/arrow/adapters/orc/adapter.cc:146–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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_;

Callers 1

TESTFunction · 0.45

Calls 8

AppendBatchFunction · 0.85
OKFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
MakeFunction · 0.50
nextMethod · 0.45
resetMethod · 0.45
num_fieldsMethod · 0.45
GetFieldMethod · 0.45

Tested by 1

TESTFunction · 0.36