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

Function CopyBufferFromVector

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

Source from the content-addressed store, hash-verified

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