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

Function CastBuffer

python/pyarrow/src/arrow/python/numpy_to_arrow.cc:360–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358namespace {
359
360Status CastBuffer(const std::shared_ptr<DataType>& in_type,
361 const std::shared_ptr<Buffer>& input, const int64_t length,
362 const std::shared_ptr<Buffer>& valid_bitmap, const int64_t null_count,
363 const std::shared_ptr<DataType>& out_type,
364 const compute::CastOptions& cast_options, MemoryPool* pool,
365 std::shared_ptr<Buffer>* out) {
366 // Must cast
367 auto tmp_data = ArrayData::Make(in_type, length, {valid_bitmap, input}, null_count);
368 compute::ExecContext context(pool);
369 ARROW_ASSIGN_OR_RAISE(
370 std::shared_ptr<Array> casted_array,
371 compute::Cast(*MakeArray(tmp_data), out_type, cast_options, &context));
372 *out = casted_array->data()->buffers[1];
373 return Status::OK();
374}
375
376template <typename FromType, typename ToType>
377Status StaticCastBuffer(const Buffer& input, const int64_t length, MemoryPool* pool,

Callers 3

ConvertDataMethod · 0.85

Calls 6

CastFunction · 0.85
MakeFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
MakeArrayFunction · 0.50
OKFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected