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