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

Method Convert

cpp/src/arrow/csv/converter.cc:613–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611 }
612
613 Result<std::shared_ptr<Array>> Convert(const BlockParser& parser,
614 int32_t col_index) override {
615 // We use a fixed index width so that all column chunks get the same index type
616 using BuilderType = Dictionary32Builder<T>;
617 using value_type = typename ValueDecoderType::value_type;
618
619 BuilderType builder(value_type_, pool_);
620 RETURN_NOT_OK(PresizeBuilder(parser, &builder));
621
622 auto visit = [&](const uint8_t* data, uint32_t size, bool quoted,
623 bool missing) -> Status {
624 if (missing || decoder_.IsNull(data, size, quoted /* quoted */)) {
625 return builder.AppendNull();
626 }
627 if (ARROW_PREDICT_FALSE(builder.dictionary_length() > max_cardinality_)) {
628 return Status::IndexError("Dictionary length exceeded max cardinality");
629 }
630 value_type value{};
631 RETURN_NOT_OK(decoder_.Decode(data, size, quoted, &value));
632 return builder.Append(value);
633 };
634 RETURN_NOT_OK(parser.VisitColumn(col_index, visit));
635
636 std::shared_ptr<Array> res;
637 RETURN_NOT_OK(builder.Finish(&res));
638 return res;
639 }
640
641 void SetMaxCardinality(int32_t max_length) override { max_cardinality_ = max_length; }
642

Callers

nothing calls this directly

Calls 8

PresizeBuilderFunction · 0.85
IndexErrorFunction · 0.85
dictionary_lengthMethod · 0.80
IsNullMethod · 0.45
AppendNullMethod · 0.45
DecodeMethod · 0.45
AppendMethod · 0.45
FinishMethod · 0.45

Tested by

no test coverage detected