| 56 | } |
| 57 | |
| 58 | void CheckResults() { |
| 59 | std::vector<int32_t> vresult(num_values_, -1); |
| 60 | std::vector<int16_t> dresult(num_levels_, -1); |
| 61 | std::vector<int16_t> rresult(num_levels_, -1); |
| 62 | int64_t values_read = 0; |
| 63 | int total_values_read = 0; |
| 64 | int batch_actual = 0; |
| 65 | |
| 66 | Int32Reader* reader = static_cast<Int32Reader*>(reader_.get()); |
| 67 | int32_t batch_size = 8; |
| 68 | int batch = 0; |
| 69 | // This will cover both the cases |
| 70 | // 1) batch_size < page_size (multiple ReadBatch from a single page) |
| 71 | // 2) batch_size > page_size (BatchRead limits to a single page) |
| 72 | do { |
| 73 | batch = static_cast<int>(reader->ReadBatch( |
| 74 | batch_size, &dresult[0] + batch_actual, &rresult[0] + batch_actual, |
| 75 | &vresult[0] + total_values_read, &values_read)); |
| 76 | total_values_read += static_cast<int>(values_read); |
| 77 | batch_actual += batch; |
| 78 | batch_size = std::min(1 << 24, std::max(batch_size * 2, 4096)); |
| 79 | } while (batch > 0); |
| 80 | |
| 81 | ASSERT_EQ(num_levels_, batch_actual); |
| 82 | ASSERT_EQ(num_values_, total_values_read); |
| 83 | ASSERT_TRUE(vector_equal(values_, vresult)); |
| 84 | if (max_def_level_ > 0) { |
| 85 | ASSERT_TRUE(vector_equal(def_levels_, dresult)); |
| 86 | } |
| 87 | if (max_rep_level_ > 0) { |
| 88 | ASSERT_TRUE(vector_equal(rep_levels_, rresult)); |
| 89 | } |
| 90 | // catch improper writes at EOS |
| 91 | batch_actual = |
| 92 | static_cast<int>(reader->ReadBatch(5, nullptr, nullptr, nullptr, &values_read)); |
| 93 | ASSERT_EQ(0, batch_actual); |
| 94 | ASSERT_EQ(0, values_read); |
| 95 | } |
| 96 | |
| 97 | void Clear() { |
| 98 | values_.clear(); |
nothing calls this directly
no test coverage detected