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

Method Write

cpp/src/parquet/arrow/writer.cc:159–203  ·  view source on GitHub ↗

Writes out all leaf parquet columns to the RowGroupWriter that this object was constructed with. Each leaf column is written fully before the next column is written (i.e. no buffering is assumed). Columns are written in DFS order.

Source from the content-addressed store, hash-verified

157 //
158 // Columns are written in DFS order.
159 Status Write(ArrowWriteContext* ctx) {
160 for (int leaf_idx = 0; leaf_idx < leaf_count_; leaf_idx++) {
161 ColumnWriter* column_writer;
162 if (row_group_writer_->buffered()) {
163 const int column_index = start_leaf_column_index_ + leaf_idx;
164 PARQUET_CATCH_NOT_OK(column_writer = row_group_writer_->column(column_index));
165 } else {
166 PARQUET_CATCH_NOT_OK(column_writer = row_group_writer_->NextColumn());
167 }
168 for (auto& level_builder : level_builders_) {
169 RETURN_NOT_OK(level_builder->Write(
170 leaf_idx, ctx, [&](const MultipathLevelBuilderResult& result) {
171 size_t visited_component_size = result.post_list_visited_elements.size();
172 DCHECK_GT(visited_component_size, 0);
173 std::shared_ptr<Array> values_array;
174 if (visited_component_size == 1) {
175 const ElementRange& range = result.post_list_visited_elements[0];
176 values_array = result.leaf_array->Slice(range.start, range.Size());
177 } else {
178 // Multiple leaf ranges can be produced when child values are
179 // skipped, such as null fixed-size-list slots, or when
180 // list-view ranges are non-contiguous. Concatenate the slices
181 // in logical write order.
182 ::arrow::ArrayVector arrays;
183 arrays.reserve(visited_component_size);
184 for (const auto& range : result.post_list_visited_elements) {
185 DCHECK(!range.Empty());
186 arrays.push_back(result.leaf_array->Slice(range.start, range.Size()));
187 }
188 ARROW_ASSIGN_OR_RAISE(values_array,
189 ::arrow::Concatenate(arrays, ctx->memory_pool));
190 }
191
192 return column_writer->WriteArrow(result.def_levels, result.rep_levels,
193 result.def_rep_level_count, *values_array,
194 ctx, result.leaf_is_nullable);
195 }));
196 }
197
198 if (!row_group_writer_->buffered()) {
199 PARQUET_CATCH_NOT_OK(column_writer->Close());
200 }
201 }
202 return Status::OK();
203 }
204
205 // Make a new object by converting each chunk in |data| to a MultipathLevelBuilder.
206 //

Callers 2

WriteColumnChunkMethod · 0.45
WriteRecordBatchMethod · 0.45

Calls 14

ConcatenateFunction · 0.85
push_backMethod · 0.80
WriteArrowMethod · 0.80
ARROW_ASSIGN_OR_RAISEFunction · 0.70
OKFunction · 0.50
bufferedMethod · 0.45
columnMethod · 0.45
NextColumnMethod · 0.45
sizeMethod · 0.45
SliceMethod · 0.45
SizeMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected