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

Method DecodeRowGroups

cpp/src/parquet/arrow/reader.cc:1321–1358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1319}
1320
1321Future<std::shared_ptr<Table>> FileReaderImpl::DecodeRowGroups(
1322 std::shared_ptr<FileReaderImpl> self, const std::vector<int>& row_groups,
1323 const std::vector<int>& column_indices, ::arrow::internal::Executor* cpu_executor) {
1324 // `self` is used solely to keep `this` alive in an async context - but we use this
1325 // in a sync context too so use `this` over `self`
1326 std::vector<std::shared_ptr<ColumnReaderImpl>> readers;
1327 std::shared_ptr<::arrow::Schema> result_schema;
1328 RETURN_NOT_OK(GetFieldReaders(column_indices, row_groups, &readers, &result_schema));
1329 // OptionalParallelForAsync requires an executor
1330 if (!cpu_executor) cpu_executor = ::arrow::internal::GetCpuThreadPool();
1331
1332 auto read_column = [row_groups, self, this](size_t i,
1333 std::shared_ptr<ColumnReaderImpl> reader)
1334 -> ::arrow::Result<std::shared_ptr<::arrow::ChunkedArray>> {
1335 std::shared_ptr<::arrow::ChunkedArray> column;
1336 RETURN_NOT_OK(ReadColumn(static_cast<int>(i), row_groups, reader.get(), &column));
1337 return column;
1338 };
1339 auto make_table = [result_schema, row_groups, self,
1340 this](const ::arrow::ChunkedArrayVector& columns)
1341 -> ::arrow::Result<std::shared_ptr<Table>> {
1342 int64_t num_rows = 0;
1343 if (!columns.empty()) {
1344 num_rows = columns[0]->length();
1345 } else {
1346 for (int i : row_groups) {
1347 num_rows += parquet_reader()->metadata()->RowGroup(i)->num_rows();
1348 }
1349 }
1350 auto table = Table::Make(std::move(result_schema), columns, num_rows);
1351 RETURN_NOT_OK(table->Validate());
1352 return table;
1353 };
1354 return ::arrow::internal::OptionalParallelForAsync(reader_properties_.use_threads(),
1355 std::move(readers), read_column,
1356 cpu_executor)
1357 .Then(std::move(make_table));
1358}
1359
1360std::shared_ptr<RowGroupReader> FileReaderImpl::RowGroup(int row_group_index) {
1361 return std::make_shared<RowGroupReaderImpl>(this, row_group_index);

Callers 1

ReadOneRowGroupMethod · 0.80

Calls 12

GetCpuThreadPoolFunction · 0.85
OptionalParallelForAsyncFunction · 0.85
ThenMethod · 0.80
MakeFunction · 0.50
getMethod · 0.45
emptyMethod · 0.45
lengthMethod · 0.45
num_rowsMethod · 0.45
RowGroupMethod · 0.45
metadataMethod · 0.45
ValidateMethod · 0.45
use_threadsMethod · 0.45

Tested by

no test coverage detected