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

Function MaybeConvertFieldRef

cpp/src/arrow/dataset/file_parquet.cc:284–302  ·  view source on GitHub ↗

Converts a field ref into a position-independent ref (containing only a sequence of names) based on the dataset schema. Returns `false` if no conversion was needed.

Source from the content-addressed store, hash-verified

282// Converts a field ref into a position-independent ref (containing only a sequence of
283// names) based on the dataset schema. Returns `false` if no conversion was needed.
284Result<FieldRef> MaybeConvertFieldRef(FieldRef ref, const Schema& dataset_schema) {
285 if (ARROW_PREDICT_TRUE(ref.IsNameSequence())) {
286 return ref;
287 }
288
289 ARROW_ASSIGN_OR_RAISE(auto path, ref.FindOne(dataset_schema));
290 std::vector<FieldRef> named_refs;
291 named_refs.reserve(path.indices().size());
292
293 const FieldVector* child_fields = &dataset_schema.fields();
294 for (auto index : path) {
295 const auto& child_field = *(*child_fields)[index];
296 named_refs.emplace_back(child_field.name());
297 child_fields = &child_field.type()->fields();
298 }
299
300 return named_refs.size() == 1 ? std::move(named_refs[0])
301 : FieldRef(std::move(named_refs));
302}
303
304// Compute the column projection based on the scan options
305Result<std::vector<int>> InferColumnProjection(const parquet::arrow::FileReader& reader,

Callers 1

InferColumnProjectionFunction · 0.85

Calls 8

indicesMethod · 0.80
emplace_backMethod · 0.80
FieldRefFunction · 0.50
reserveMethod · 0.45
sizeMethod · 0.45
fieldsMethod · 0.45
nameMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected