| 687 | } |
| 688 | |
| 689 | Result<std::optional<KeyValuePartitioning::Key>> HivePartitioning::ParseKey( |
| 690 | const std::string& segment, const HivePartitioningOptions& options) { |
| 691 | auto name_end = string_view(segment).find_first_of('='); |
| 692 | // Not round-trippable |
| 693 | if (name_end == string_view::npos) { |
| 694 | return std::nullopt; |
| 695 | } |
| 696 | |
| 697 | // Static method, so we have no better place for it |
| 698 | util::InitializeUTF8(); |
| 699 | |
| 700 | std::string name; |
| 701 | std::string value; |
| 702 | switch (options.segment_encoding) { |
| 703 | case SegmentEncoding::None: { |
| 704 | name = segment.substr(0, name_end); |
| 705 | value = segment.substr(name_end + 1); |
| 706 | if (ARROW_PREDICT_FALSE(!util::ValidateUTF8(segment))) { |
| 707 | return Status::Invalid("Partition segment was not valid UTF-8: ", segment); |
| 708 | } |
| 709 | break; |
| 710 | } |
| 711 | case SegmentEncoding::Uri: { |
| 712 | auto raw_value = std::string_view(segment).substr(name_end + 1); |
| 713 | ARROW_ASSIGN_OR_RAISE(value, SafeUriUnescape(raw_value)); |
| 714 | auto raw_key = std::string_view(segment).substr(0, name_end); |
| 715 | ARROW_ASSIGN_OR_RAISE(name, SafeUriUnescape(raw_key)); |
| 716 | break; |
| 717 | } |
| 718 | default: |
| 719 | return Status::NotImplemented("Unknown segment encoding: ", |
| 720 | options.segment_encoding); |
| 721 | } |
| 722 | |
| 723 | if (value == options.null_fallback) { |
| 724 | return Key{std::move(name), std::nullopt}; |
| 725 | } |
| 726 | return Key{std::move(name), std::move(value)}; |
| 727 | } |
| 728 | |
| 729 | Result<std::vector<KeyValuePartitioning::Key>> HivePartitioning::ParseKeys( |
| 730 | const std::string& path) const { |
nothing calls this directly
no test coverage detected