| 1009 | } |
| 1010 | |
| 1011 | Result<std::shared_ptr<StructArray>> Diff(const Array& base, const Array& target, |
| 1012 | MemoryPool* pool) { |
| 1013 | if (!base.type()->Equals(target.type())) { |
| 1014 | return Status::TypeError("only taking the diff of like-typed arrays is supported."); |
| 1015 | } |
| 1016 | |
| 1017 | if (base.type()->id() == Type::NA) { |
| 1018 | return NullDiff(base, target, pool); |
| 1019 | } else if (base.type()->id() == Type::EXTENSION) { |
| 1020 | auto base_storage = checked_cast<const ExtensionArray&>(base).storage(); |
| 1021 | auto target_storage = checked_cast<const ExtensionArray&>(target).storage(); |
| 1022 | return Diff(*base_storage, *target_storage, pool); |
| 1023 | } else if (base.type()->id() == Type::DICTIONARY) { |
| 1024 | return Status::NotImplemented("diffing arrays of type ", *base.type()); |
| 1025 | } else if (base.type()->id() == Type::LIST_VIEW || |
| 1026 | base.type()->id() == Type::LARGE_LIST_VIEW) { |
| 1027 | return Status::NotImplemented("diffing arrays of type ", *base.type()); |
| 1028 | } else { |
| 1029 | return QuadraticSpaceMyersDiff(base, target, pool).Diff(); |
| 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | } // namespace arrow |