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

Function CheckToTensor

cpp/src/arrow/array/array_list_test.cc:1875–1894  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1873
1874template <typename T>
1875void CheckToTensor(const std::shared_ptr<Array>& array, const std::vector<int64_t>& shape,
1876 std::initializer_list<T> values) {
1877 const auto value_type = CTypeTraits<T>::type_singleton();
1878 ASSERT_OK_AND_ASSIGN(
1879 auto expected,
1880 Tensor::Make(value_type, Buffer::Wrap(values.begin(), values.size()), shape));
1881
1882 ASSERT_OK_AND_ASSIGN(auto tensor, array->ToTensor());
1883 ASSERT_OK(tensor->Validate());
1884
1885 AssertTypeEqual(*value_type, *tensor->type());
1886 ASSERT_EQ(shape, tensor->shape());
1887 ASSERT_TRUE(tensor->is_row_major());
1888 ASSERT_TRUE(tensor->Equals(*expected));
1889
1890 // The tensor shares the values buffer, it does not copy
1891 const auto leaf = LeafValues(array);
1892 ASSERT_EQ(leaf->data()->buffers[1]->data() + leaf->offset() * sizeof(T),
1893 tensor->data()->data());
1894}
1895
1896} // namespace
1897

Callers

nothing calls this directly

Calls 9

LeafValuesFunction · 0.85
is_row_majorMethod · 0.80
type_singletonFunction · 0.50
ValidateMethod · 0.45
typeMethod · 0.45
shapeMethod · 0.45
EqualsMethod · 0.45
dataMethod · 0.45
offsetMethod · 0.45

Tested by

no test coverage detected