MCPcopy Create free account
hub / github.com/apache/impala / AppendToReadWriteStream

Method AppendToReadWriteStream

be/src/runtime/buffered-tuple-stream-test.cc:987–1031  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

985}
986
987void 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
1033void SimpleTupleStreamTest::VerifyReadWriteBatch(
1034 RowBatch* in_batch, RowBatch* out_batch, int64_t start_index) {

Callers

nothing calls this directly

Calls 13

push_backMethod · 0.80
num_buffersMethod · 0.80
flush_modeMethod · 0.80
getMethod · 0.65
clearMethod · 0.65
byte_sizeMethod · 0.45
AddRowMethod · 0.45
GetRowMethod · 0.45
num_rowsMethod · 0.45
rows_returnedMethod · 0.45
GetNextMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected