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

Function TestStraddling

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

Source from the content-addressed store, hash-verified

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