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

Function CopyBufferFromVector

cpp/src/arrow/testing/util.h:42–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40
41template <typename T>
42Status CopyBufferFromVector(const std::vector<T>& values, MemoryPool* pool,
43 std::shared_ptr<Buffer>* result) {
44 int64_t nbytes = static_cast<int>(values.size()) * sizeof(T);
45
46 ARROW_ASSIGN_OR_RAISE(auto buffer, AllocateBuffer(nbytes, pool));
47 auto immutable_data = reinterpret_cast<const uint8_t*>(values.data());
48 std::copy(immutable_data, immutable_data + nbytes, buffer->mutable_data());
49 memset(buffer->mutable_data() + nbytes, 0,
50 static_cast<size_t>(buffer->capacity() - nbytes));
51
52 *result = std::move(buffer);
53 return Status::OK();
54}
55
56// Sets approximately pct_null of the first n bytes in null_bytes to zero
57// and the rest to non-zero (true) values.

Callers 2

MakeUnionFunction · 0.85
TEST_FFunction · 0.85

Calls 5

OKFunction · 0.50
sizeMethod · 0.45
dataMethod · 0.45
mutable_dataMethod · 0.45
capacityMethod · 0.45

Tested by 2

MakeUnionFunction · 0.68
TEST_FFunction · 0.68