| 102 | |
| 103 | template <typename TYPE> |
| 104 | Result<std::shared_ptr<typename TypeTraits<TYPE>::ArrayType>> ListArrayFromArrays( |
| 105 | std::shared_ptr<DataType> type, const Array& offsets, const Array& values, |
| 106 | MemoryPool* pool, std::shared_ptr<Buffer> null_bitmap = NULLPTR, |
| 107 | int64_t null_count = kUnknownNullCount) { |
| 108 | using offset_type = typename TYPE::offset_type; |
| 109 | using ArrayType = typename TypeTraits<TYPE>::ArrayType; |
| 110 | using OffsetArrowType = typename CTypeTraits<offset_type>::ArrowType; |
| 111 | |
| 112 | if (offsets.length() == 0) { |
| 113 | return Status::Invalid("List offsets must have non-zero length"); |
| 114 | } |
| 115 | |
| 116 | if (offsets.type_id() != OffsetArrowType::type_id) { |
| 117 | return Status::TypeError("List offsets must be ", OffsetArrowType::type_name()); |
| 118 | } |
| 119 | |
| 120 | if (null_bitmap != nullptr && offsets.data()->GetNullCount() != 0) { |
| 121 | return Status::Invalid( |
| 122 | "Ambiguous to specify both validity map and offsets with nulls"); |
| 123 | } |
| 124 | |
| 125 | if (null_bitmap != nullptr && offsets.offset() != 0) { |
| 126 | return Status::NotImplemented("Null bitmap with offsets slice not supported."); |
| 127 | } |
| 128 | |
| 129 | // Clean the offsets if they contain nulls. |
| 130 | if (offsets.null_count() > 0) { |
| 131 | ARROW_ASSIGN_OR_RAISE(auto buffers, |
| 132 | CleanListOffsets<TYPE>(null_bitmap, offsets, pool)); |
| 133 | auto data = ArrayData::Make(type, offsets.length() - 1, std::move(buffers), |
| 134 | {values.data()}, offsets.null_count(), /*offset=*/0); |
| 135 | return std::make_shared<ArrayType>(std::move(data)); |
| 136 | } |
| 137 | |
| 138 | using OffsetArrayType = typename TypeTraits<OffsetArrowType>::ArrayType; |
| 139 | const auto& typed_offsets = checked_cast<const OffsetArrayType&>(offsets); |
| 140 | auto buffers = BufferVector({std::move(null_bitmap), typed_offsets.values()}); |
| 141 | auto data = ArrayData::Make(type, offsets.length() - 1, std::move(buffers), |
| 142 | {values.data()}, null_count, offsets.offset()); |
| 143 | return std::make_shared<ArrayType>(std::move(data)); |
| 144 | } |
| 145 | |
| 146 | template <typename TYPE> |
| 147 | Result<std::shared_ptr<typename TypeTraits<TYPE>::ArrayType>> ListViewArrayFromArrays( |
nothing calls this directly
no test coverage detected