| 768 | |
| 769 | template <typename RunEndCType> |
| 770 | Status ValidateRunEndEncoded(const RunEndEncodedType& type) { |
| 771 | if (data.child_data.size() != 2) { |
| 772 | return Status::Invalid( |
| 773 | "Run end encoded array should have 2 children; this array has ", |
| 774 | data.child_data.size()); |
| 775 | } |
| 776 | |
| 777 | if (data.buffers.size() > 0 && data.buffers[0] != nullptr) { |
| 778 | return Status::Invalid("Run end encoded array should not have a null bitmap."); |
| 779 | } |
| 780 | |
| 781 | const auto& run_ends_data = data.child_data[0]; |
| 782 | const auto& values_data = data.child_data[1]; |
| 783 | |
| 784 | if (!run_ends_data) { |
| 785 | return Status::Invalid("Run ends array is null pointer"); |
| 786 | } |
| 787 | if (!values_data) { |
| 788 | return Status::Invalid("Values array is null pointer"); |
| 789 | } |
| 790 | // We must validate child array buffers are valid before making additional checks. |
| 791 | const Status run_ends_valid = RecurseInto(*run_ends_data); |
| 792 | if (!run_ends_valid.ok()) { |
| 793 | return Status::Invalid("Run ends array invalid: ", run_ends_valid.message()); |
| 794 | } |
| 795 | const Status values_valid = RecurseInto(*values_data); |
| 796 | if (!values_valid.ok()) { |
| 797 | return Status::Invalid("Values array invalid: ", values_valid.message()); |
| 798 | } |
| 799 | |
| 800 | RETURN_NOT_OK(ree_util::ValidateRunEndEncodedChildren( |
| 801 | type, data.length, run_ends_data, values_data, data.GetNullCount(), data.offset)); |
| 802 | |
| 803 | if (run_ends_data->length == 0) { |
| 804 | return Status::OK(); |
| 805 | } |
| 806 | |
| 807 | if (full_validation) { |
| 808 | ArraySpan span(data); |
| 809 | const auto* run_ends = ree_util::RunEnds<RunEndCType>(span); |
| 810 | const int64_t run_ends_length = ree_util::RunEndsArray(span).length; |
| 811 | if (run_ends[0] < 1) { |
| 812 | return Status::Invalid( |
| 813 | "All run ends must be greater than 0 but the first run end is ", run_ends[0]); |
| 814 | } |
| 815 | int64_t last_run_end = run_ends[0]; |
| 816 | for (int64_t index = 1; index < run_ends_length; index++) { |
| 817 | const int64_t run_end = run_ends[index]; |
| 818 | if (run_end <= last_run_end) { |
| 819 | return Status::Invalid( |
| 820 | "Every run end must be strictly greater than the previous run end, " |
| 821 | "but run_ends[", |
| 822 | index, "] is ", run_end, " and run_ends[", index - 1, "] is ", |
| 823 | last_run_end); |
| 824 | } |
| 825 | last_run_end = run_end; |
| 826 | } |
| 827 | } |
nothing calls this directly
no test coverage detected