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

Method TestAddAndGetZeroSizedRows

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

Source from the content-addressed store, hash-verified

2295}
2296
2297void StreamStateTest::TestAddAndGetZeroSizedRows() {
2298 Init(BUFFER_POOL_LIMIT);
2299 BufferedTupleStream stream(
2300 runtime_state_, zero_sized_row_desc_, &client_, PAGE_LEN, PAGE_LEN);
2301 ASSERT_OK(stream.Init("StreamStateTest::TestAddAndGetZeroSizedRows", false));
2302 bool got_reservation = false;
2303 ASSERT_OK(stream.PrepareForReadWrite(true, &got_reservation));
2304 ASSERT_TRUE(got_reservation);
2305
2306 RowBatch write_batch(zero_sized_row_desc_, 1, &tracker_);
2307 write_batch.CommitRows(1);
2308
2309 // Adding 1 row to initialize the row counters
2310 TestAddOneZeroSizedRow(stream, write_batch);
2311
2312 // Set the row counters to mock a stream with INT_MAX rows
2313 stream.num_rows_ = INT_MAX;
2314 stream.write_page_->num_rows = INT_MAX;
2315
2316 // Test if the stream can hold more than INT_MAX rows.
2317 TestAddOneZeroSizedRow(stream, write_batch);
2318
2319 // Set the row counters to mock a stream with UINT_MAX rows
2320 stream.num_rows_ = UINT_MAX;
2321 stream.write_page_->num_rows = UINT_MAX;
2322
2323 // Test if the stream can hold more than UINT_MAX rows.
2324 TestAddOneZeroSizedRow(stream, write_batch);
2325
2326 stream.DoneWriting();
2327
2328 // Test if we can get 1 row after getting 0 rows.
2329 TestGetOneZeroSizedRow(stream);
2330
2331 // Test if we can get 1 row after getting INT_MAX rows.
2332 stream.read_it_.IncrRowsReturned(INT_MAX - 1);
2333 ASSERT_EQ(stream.read_it_.read_page_rows_returned_, INT_MAX);
2334 TestGetOneZeroSizedRow(stream);
2335
2336 // Test if we can get 1 row after getting UINT_MAX rows.
2337 stream.read_it_.IncrRowsReturned(UINT_MAX - INT_MAX - 1);
2338 ASSERT_EQ(stream.read_it_.read_page_rows_returned_, UINT_MAX);
2339 TestGetOneZeroSizedRow(stream);
2340
2341 ASSERT_EQ(stream.read_it_.GetRowsLeftInPage(), 0);
2342 stream.Close(nullptr, RowBatch::FlushMode::NO_FLUSH_RESOURCES);
2343}
2344
2345TEST_F(StreamStateTest, AddAndGetZeroSizedRows) {
2346 TestAddAndGetZeroSizedRows();

Callers

nothing calls this directly

Calls 7

PrepareForReadWriteMethod · 0.80
DoneWritingMethod · 0.80
IncrRowsReturnedMethod · 0.80
GetRowsLeftInPageMethod · 0.80
InitMethod · 0.45
CommitRowsMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected