| 87 | }; |
| 88 | |
| 89 | TEST_F(TestTensorRoundTrip, BasicRoundtrip) { |
| 90 | std::string path = "test-write-tensor"; |
| 91 | constexpr int64_t kBufferSize = 1 << 20; |
| 92 | ASSERT_OK_AND_ASSIGN(mmap_, io::MemoryMapFixture::InitMemoryMap(kBufferSize, path)); |
| 93 | |
| 94 | std::vector<int64_t> shape = {4, 6}; |
| 95 | std::vector<int64_t> strides = {48, 8}; |
| 96 | std::vector<std::string> dim_names = {"foo", "bar"}; |
| 97 | int64_t size = 24; |
| 98 | |
| 99 | std::vector<int64_t> values; |
| 100 | randint(size, 0, 100, &values); |
| 101 | |
| 102 | auto data = Buffer::Wrap(values); |
| 103 | |
| 104 | Tensor t0(int64(), data, shape, strides, dim_names); |
| 105 | Tensor t_no_dims(int64(), data, {}, {}, {}); |
| 106 | Tensor t_zero_length_dim(int64(), data, {0}, {8}, {"foo"}); |
| 107 | |
| 108 | CheckTensorRoundTrip(t0); |
| 109 | CheckTensorRoundTrip(t_no_dims); |
| 110 | CheckTensorRoundTrip(t_zero_length_dim); |
| 111 | |
| 112 | int64_t serialized_size; |
| 113 | ASSERT_OK(GetTensorSize(t0, &serialized_size)); |
| 114 | ASSERT_TRUE(serialized_size > static_cast<int64_t>(size * sizeof(int64_t))); |
| 115 | |
| 116 | // ARROW-2840: Check that padding/alignment minded |
| 117 | std::vector<int64_t> shape_2 = {1, 1}; |
| 118 | std::vector<int64_t> strides_2 = {8, 8}; |
| 119 | Tensor t0_not_multiple_64(int64(), data, shape_2, strides_2, dim_names); |
| 120 | CheckTensorRoundTrip(t0_not_multiple_64); |
| 121 | } |
| 122 | |
| 123 | TEST_F(TestTensorRoundTrip, NonContiguous) { |
| 124 | std::string path = "test-write-tensor-strided"; |
nothing calls this directly
no test coverage detected