MCPcopy Create free account
hub / github.com/apache/arrow / VisitArray

Method VisitArray

cpp/src/arrow/ipc/writer.cc:146–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 13

CapacityErrorFunction · 0.85
GetTruncatedBitmapFunction · 0.85
push_backMethod · 0.80
emplace_backMethod · 0.80
HasValidityBitmapFunction · 0.70
InvalidFunction · 0.50
NotImplementedFunction · 0.50
VisitTypeFunction · 0.50
lengthMethod · 0.45
offsetMethod · 0.45
device_typeMethod · 0.45
null_countMethod · 0.45

Tested by

no test coverage detected