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

Method LoadValues

cpp/src/arrow/ipc/feather.cc:270–311  ·  view source on GitHub ↗

Retrieve a primitive array from the data source @returns: a Buffer instance, the precise type will depend on the kind of input data source (which may or may not have memory-map like semantics)

Source from the content-addressed store, hash-verified

268 // @returns: a Buffer instance, the precise type will depend on the kind of
269 // input data source (which may or may not have memory-map like semantics)
270 Status LoadValues(std::shared_ptr<DataType> type, const fbs::PrimitiveArray* meta,
271 fbs::TypeMetadata metadata_type, const void* metadata,
272 std::shared_ptr<ArrayData>* out) {
273 std::vector<std::shared_ptr<Buffer>> buffers;
274
275 // Buffer data from the source (may or may not perform a copy depending on
276 // input source)
277 ARROW_ASSIGN_OR_RAISE(
278 auto buffer,
279 source_->ReadAt(meta->offset(), meta->total_bytes(), /*allow_short_read=*/false));
280
281 int64_t offset = 0;
282
283 if (type->id() == Type::DICTIONARY) {
284 // Load the index type values
285 type = checked_cast<const DictionaryType&>(*type).index_type();
286 }
287
288 // If there are nulls, the null bitmask is first
289 if (meta->null_count() > 0) {
290 int64_t null_bitmap_size = GetOutputLength(bit_util::BytesForBits(meta->length()));
291 buffers.push_back(SliceBuffer(buffer, offset, null_bitmap_size));
292 offset += null_bitmap_size;
293 } else {
294 buffers.push_back(nullptr);
295 }
296
297 if (is_binary_like(type->id())) {
298 int64_t offsets_size = GetOutputLength((meta->length() + 1) * sizeof(int32_t));
299 buffers.push_back(SliceBuffer(buffer, offset, offsets_size));
300 offset += offsets_size;
301 } else if (is_large_binary_like(type->id())) {
302 int64_t offsets_size = GetOutputLength((meta->length() + 1) * sizeof(int64_t));
303 buffers.push_back(SliceBuffer(buffer, offset, offsets_size));
304 offset += offsets_size;
305 }
306
307 buffers.push_back(SliceBuffer(buffer, offset, buffer->size() - offset));
308
309 *out = ArrayData::Make(type, meta->length(), std::move(buffers), meta->null_count());
310 return Status::OK();
311 }
312
313 int version() const override { return metadata_->version(); }
314 int64_t num_rows() const { return metadata_->num_rows(); }

Callers

nothing calls this directly

Calls 12

BytesForBitsFunction · 0.85
SliceBufferFunction · 0.85
is_binary_likeFunction · 0.85
is_large_binary_likeFunction · 0.85
index_typeMethod · 0.80
push_backMethod · 0.80
MakeFunction · 0.50
OKFunction · 0.50
idMethod · 0.45
null_countMethod · 0.45
lengthMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected