| 88 | } |
| 89 | |
| 90 | void CheckResults() { |
| 91 | std::vector<int32_t> vresult(num_values_, -1); |
| 92 | std::vector<int16_t> dresult(num_levels_, -1); |
| 93 | std::vector<int16_t> rresult(num_levels_, -1); |
| 94 | int64_t values_read = 0; |
| 95 | int total_values_read = 0; |
| 96 | int batch_actual = 0; |
| 97 | |
| 98 | Int32Reader* reader = static_cast<Int32Reader*>(reader_.get()); |
| 99 | int32_t batch_size = 8; |
| 100 | int batch = 0; |
| 101 | // This will cover both the cases |
| 102 | // 1) batch_size < page_size (multiple ReadBatch from a single page) |
| 103 | // 2) batch_size > page_size (BatchRead limits to a single page) |
| 104 | do { |
| 105 | batch = static_cast<int>(reader->ReadBatch( |
| 106 | batch_size, &dresult[0] + batch_actual, &rresult[0] + batch_actual, |
| 107 | &vresult[0] + total_values_read, &values_read)); |
| 108 | total_values_read += static_cast<int>(values_read); |
| 109 | batch_actual += batch; |
| 110 | batch_size = std::min(1 << 24, std::max(batch_size * 2, 4096)); |
| 111 | } while (batch > 0); |
| 112 | |
| 113 | ASSERT_EQ(num_levels_, batch_actual); |
| 114 | ASSERT_EQ(num_values_, total_values_read); |
| 115 | ASSERT_TRUE(vector_equal(values_, vresult)); |
| 116 | if (max_def_level_ > 0) { |
| 117 | ASSERT_TRUE(vector_equal(def_levels_, dresult)); |
| 118 | } |
| 119 | if (max_rep_level_ > 0) { |
| 120 | ASSERT_TRUE(vector_equal(rep_levels_, rresult)); |
| 121 | } |
| 122 | // catch improper writes at EOS |
| 123 | batch_actual = |
| 124 | static_cast<int>(reader->ReadBatch(5, nullptr, nullptr, nullptr, &values_read)); |
| 125 | ASSERT_EQ(0, batch_actual); |
| 126 | ASSERT_EQ(0, values_read); |
| 127 | } |
| 128 | |
| 129 | void Clear() { |
| 130 | values_.clear(); |
nothing calls this directly
no test coverage detected