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

Method DecodeRowGroups

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

Source from the content-addressed store, hash-verified

1270}
1271
1272Future<std::shared_ptr<Table>> FileReaderImpl::DecodeRowGroups(
1273 std::shared_ptr<FileReaderImpl> self, const std::vector<int>& row_groups,
1274 const std::vector<int>& column_indices, ::arrow::internal::Executor* cpu_executor) {
1275 // `self` is used solely to keep `this` alive in an async context - but we use this
1276 // in a sync context too so use `this` over `self`
1277 std::vector<std::shared_ptr<ColumnReaderImpl>> readers;
1278 std::shared_ptr<::arrow::Schema> result_schema;
1279 RETURN_NOT_OK(GetFieldReaders(column_indices, row_groups, &readers, &result_schema));
1280 // OptionalParallelForAsync requires an executor
1281 if (!cpu_executor) cpu_executor = ::arrow::internal::GetCpuThreadPool();
1282
1283 auto read_column = [row_groups, self, this](size_t i,
1284 std::shared_ptr<ColumnReaderImpl> reader)
1285 -> ::arrow::Result<std::shared_ptr<::arrow::ChunkedArray>> {
1286 std::shared_ptr<::arrow::ChunkedArray> column;
1287 RETURN_NOT_OK(ReadColumn(static_cast<int>(i), row_groups, reader.get(), &column));
1288 return column;
1289 };
1290 auto make_table = [result_schema, row_groups, self,
1291 this](const ::arrow::ChunkedArrayVector& columns)
1292 -> ::arrow::Result<std::shared_ptr<Table>> {
1293 int64_t num_rows = 0;
1294 if (!columns.empty()) {
1295 num_rows = columns[0]->length();
1296 } else {
1297 for (int i : row_groups) {
1298 num_rows += parquet_reader()->metadata()->RowGroup(i)->num_rows();
1299 }
1300 }
1301 auto table = Table::Make(std::move(result_schema), columns, num_rows);
1302 RETURN_NOT_OK(table->Validate());
1303 return table;
1304 };
1305 return ::arrow::internal::OptionalParallelForAsync(reader_properties_.use_threads(),
1306 std::move(readers), read_column,
1307 cpu_executor)
1308 .Then(std::move(make_table));
1309}
1310
1311std::shared_ptr<RowGroupReader> FileReaderImpl::RowGroup(int row_group_index) {
1312 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