| 144 | virtual ~RecordBatchSerializer() = default; |
| 145 | |
| 146 | Status VisitArray(const Array& arr) { |
| 147 | static std::shared_ptr<Buffer> kNullBuffer = std::make_shared<Buffer>(nullptr, 0); |
| 148 | |
| 149 | if (max_recursion_depth_ <= 0) { |
| 150 | return Status::Invalid("Max recursion depth reached"); |
| 151 | } |
| 152 | |
| 153 | if (!options_.allow_64bit && arr.length() > std::numeric_limits<int32_t>::max()) { |
| 154 | return Status::CapacityError("Cannot write arrays larger than 2^31 - 1 in length"); |
| 155 | } |
| 156 | |
| 157 | if (arr.offset() != 0 && arr.device_type() != DeviceAllocationType::kCPU) { |
| 158 | // https://github.com/apache/arrow/issues/43029 |
| 159 | return Status::NotImplemented("Cannot compute null count for non-cpu sliced array"); |
| 160 | } |
| 161 | |
| 162 | // push back all common elements |
| 163 | field_nodes_.push_back({arr.length(), arr.null_count(), 0}); |
| 164 | |
| 165 | // In V4, null types have no validity bitmap |
| 166 | // In V5 and later, null and union types have no validity bitmap |
| 167 | if (internal::HasValidityBitmap(arr.type_id(), options_.metadata_version)) { |
| 168 | if (arr.null_count() > 0) { |
| 169 | std::shared_ptr<Buffer> bitmap; |
| 170 | RETURN_NOT_OK(GetTruncatedBitmap(arr.offset(), arr.length(), arr.null_bitmap(), |
| 171 | options_.memory_pool, &bitmap)); |
| 172 | out_->body_buffers.emplace_back(std::move(bitmap)); |
| 173 | } else { |
| 174 | // Push a dummy zero-length buffer, not to be copied |
| 175 | out_->body_buffers.emplace_back(kNullBuffer); |
| 176 | } |
| 177 | } |
| 178 | return VisitType(arr); |
| 179 | } |
| 180 | |
| 181 | // Override this for writing dictionary metadata |
| 182 | virtual Status SerializeMetadata(int64_t num_rows) { |
nothing calls this directly
no test coverage detected