| 766 | } |
| 767 | |
| 768 | Status WriteMapBatch(const Array& array, int64_t orc_offset, |
| 769 | liborc::ColumnVectorBatch* column_vector_batch) { |
| 770 | const MapArray& map_array(checked_cast<const MapArray&>(array)); |
| 771 | auto batch = checked_cast<liborc::MapVectorBatch*>(column_vector_batch); |
| 772 | liborc::ColumnVectorBatch* key_batch = (batch->keys).get(); |
| 773 | liborc::ColumnVectorBatch* element_batch = (batch->elements).get(); |
| 774 | std::shared_ptr<Array> key_array = map_array.keys(); |
| 775 | std::shared_ptr<Array> element_array = map_array.items(); |
| 776 | int64_t arrow_length = array.length(); |
| 777 | int64_t running_arrow_offset = 0, running_orc_offset = orc_offset; |
| 778 | if (orc_offset == 0) { |
| 779 | batch->offsets[0] = 0; |
| 780 | } |
| 781 | if (array.null_count()) { |
| 782 | batch->hasNulls = true; |
| 783 | } |
| 784 | for (; running_arrow_offset < arrow_length; |
| 785 | running_orc_offset++, running_arrow_offset++) { |
| 786 | if (array.IsNull(running_arrow_offset)) { |
| 787 | batch->notNull[running_orc_offset] = false; |
| 788 | batch->offsets[running_orc_offset + 1] = batch->offsets[running_orc_offset]; |
| 789 | } else { |
| 790 | batch->notNull[running_orc_offset] = true; |
| 791 | batch->offsets[running_orc_offset + 1] = |
| 792 | batch->offsets[running_orc_offset] + |
| 793 | map_array.value_offset(running_arrow_offset + 1) - |
| 794 | map_array.value_offset(running_arrow_offset); |
| 795 | int64_t subarray_arrow_offset = map_array.value_offset(running_arrow_offset), |
| 796 | subarray_orc_offset = batch->offsets[running_orc_offset], |
| 797 | new_subarray_orc_offset = batch->offsets[running_orc_offset + 1], |
| 798 | subarray_orc_length = new_subarray_orc_offset - subarray_orc_offset; |
| 799 | key_batch->resize(new_subarray_orc_offset); |
| 800 | element_batch->resize(new_subarray_orc_offset); |
| 801 | RETURN_NOT_OK( |
| 802 | WriteBatch(*(key_array->Slice(subarray_arrow_offset, subarray_orc_length)), |
| 803 | subarray_orc_offset, key_batch)); |
| 804 | RETURN_NOT_OK( |
| 805 | WriteBatch(*(element_array->Slice(subarray_arrow_offset, subarray_orc_length)), |
| 806 | subarray_orc_offset, element_batch)); |
| 807 | } |
| 808 | } |
| 809 | return Status::OK(); |
| 810 | } |
| 811 | |
| 812 | template <typename UnionArrayType> |
| 813 | Status WriteUnionBatch(const Array& array, int64_t orc_offset, |
no test coverage detected