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

Function CastBuffer

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

Source from the content-addressed store, hash-verified

349namespace {
350
351Status CastBuffer(const std::shared_ptr<DataType>& in_type,
352 const std::shared_ptr<Buffer>& input, const int64_t length,
353 const std::shared_ptr<Buffer>& valid_bitmap, const int64_t null_count,
354 const std::shared_ptr<DataType>& out_type,
355 const compute::CastOptions& cast_options, MemoryPool* pool,
356 std::shared_ptr<Buffer>* out) {
357 // Must cast
358 auto tmp_data = ArrayData::Make(in_type, length, {valid_bitmap, input}, null_count);
359 compute::ExecContext context(pool);
360 ARROW_ASSIGN_OR_RAISE(
361 std::shared_ptr<Array> casted_array,
362 compute::Cast(*MakeArray(tmp_data), out_type, cast_options, &context));
363 *out = casted_array->data()->buffers[1];
364 return Status::OK();
365}
366
367template <typename FromType, typename ToType>
368Status 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