MCPcopy Create free account
hub / github.com/apache/arrow / TestStraddling

Function TestStraddling

cpp/src/arrow/csv/reader_test.cc:111–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111void TestStraddling(TableReaderFactory reader_factory) {
112 // The largest line is 25 bytes, it is surrounded by many valid lines
113 constexpr std::string_view kData =
114 "a,b\n1,2\n3,4\n5,6\n7,8\n111111111111,22222222222\n1,2\n3,4\n5,6\n7,8\n";
115 constexpr int kHeaderLineLen = 4;
116 constexpr int kLargestLineLen = 25;
117
118 auto data = std::make_shared<Buffer>(kData);
119 auto input = std::make_shared<io::BufferReader>(data);
120 // Sanity check that a large enough block size reads the data successfully
121 ASSERT_OK_AND_ASSIGN(
122 auto reader, reader_factory(input, ParseOptions::Defaults(), /*block_size=*/{}));
123 ASSERT_FINISHES_OK(reader->ReadAsync());
124
125 for (int block_size = kHeaderLineLen; block_size < kLargestLineLen / 2; ++block_size) {
126 input = std::make_shared<io::BufferReader>(data);
127 ASSERT_OK_AND_ASSIGN(auto reader,
128 reader_factory(input, ParseOptions::Defaults(), block_size));
129 ASSERT_FINISHES_AND_RAISES(Invalid, reader->ReadAsync());
130 reader.reset();
131 }
132 // This could deadlock in the TableReader destructor if it is not able to recover
133 // gracefully after an error (GH-48741). Alternatively, the destructor could
134 // deadlock at process shutdown when the thread pool is reaped.
135 internal::GetCpuThreadPool()->WaitForIdle();
136}
137
138void StressTableReader(TableReaderFactory reader_factory) {
139#ifdef ARROW_VALGRIND

Callers 1

TESTFunction · 0.85

Calls 4

GetCpuThreadPoolFunction · 0.85
WaitForIdleMethod · 0.80
ReadAsyncMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected