| 985 | } |
| 986 | |
| 987 | void SimpleTupleStreamTest::AppendToReadWriteStream(int64_t append_batch_size, |
| 988 | int64_t buffer_size, int* num_buffers_attached, BufferedTupleStream* stream) { |
| 989 | RowBatch* in_batch = CreateIntBatch(0, BATCH_SIZE, false); |
| 990 | |
| 991 | /// Accumulate row batches until we see a flush. The contents of the batches should |
| 992 | /// remain valid until reset or delete trailing batches. |
| 993 | vector<unique_ptr<RowBatch>> out_batches; |
| 994 | // The start row index of each batch in 'out_batches'. |
| 995 | vector<int64_t> out_batch_start_indices; |
| 996 | // Iterate over at least 10 pages. |
| 997 | int64_t start_byte_size = stream->byte_size(); |
| 998 | while (stream->byte_size() - start_byte_size < 10 * buffer_size) { |
| 999 | Status status; |
| 1000 | for (int i = 0; i < append_batch_size; ++i) { |
| 1001 | bool ret = stream->AddRow( |
| 1002 | in_batch->GetRow(stream->num_rows() % in_batch->num_rows()), &status); |
| 1003 | EXPECT_TRUE(ret); |
| 1004 | ASSERT_OK(status); |
| 1005 | } |
| 1006 | int64_t rows_read = 0; |
| 1007 | bool eos; |
| 1008 | while (rows_read < append_batch_size) { |
| 1009 | out_batches.emplace_back(new RowBatch(int_desc_, BATCH_SIZE, &tracker_)); |
| 1010 | out_batch_start_indices.push_back(stream->rows_returned()); |
| 1011 | ASSERT_OK(stream->GetNext(out_batches.back().get(), &eos)); |
| 1012 | // Verify the contents of all valid batches to make sure that they haven't become |
| 1013 | // invalid. |
| 1014 | LOG(INFO) << "Verifying " << out_batches.size() << " batches"; |
| 1015 | for (int i = 0; i < out_batches.size(); ++i) { |
| 1016 | VerifyReadWriteBatch(in_batch, out_batches[i].get(), out_batch_start_indices[i]); |
| 1017 | } |
| 1018 | *num_buffers_attached += out_batches.back()->num_buffers(); |
| 1019 | rows_read += out_batches.back()->num_rows(); |
| 1020 | EXPECT_EQ(rows_read == append_batch_size, eos); |
| 1021 | if (out_batches.back().get()->flush_mode() |
| 1022 | == RowBatch::FlushMode::FLUSH_RESOURCES) { |
| 1023 | out_batches.clear(); |
| 1024 | out_batch_start_indices.clear(); |
| 1025 | } |
| 1026 | } |
| 1027 | EXPECT_EQ(append_batch_size, rows_read); |
| 1028 | EXPECT_EQ(true, eos); |
| 1029 | } |
| 1030 | in_batch->Reset(); |
| 1031 | } |
| 1032 | |
| 1033 | void SimpleTupleStreamTest::VerifyReadWriteBatch( |
| 1034 | RowBatch* in_batch, RowBatch* out_batch, int64_t start_index) { |
nothing calls this directly
no test coverage detected