Skip to content

Commit 91ad54b

Browse files
author
Rafał Hibner
committed
Merge branch 'writer_test' into combined2
2 parents 15efb04 + 4ff1bd4 commit 91ad54b

2 files changed

Lines changed: 15 additions & 18 deletions

File tree

cpp/src/arrow/dataset/dataset_writer.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <mutex>
2323
#include <unordered_map>
2424
#include <unordered_set>
25-
#include <iostream>
2625

2726
#include "arrow/filesystem/path_util.h"
2827
#include "arrow/record_batch.h"

cpp/src/arrow/dataset/dataset_writer_test.cc

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
#include <chrono>
2121
#include <mutex>
2222
#include <optional>
23-
#include <vector>
24-
#include <random>
2523
#include <thread>
24+
#include <vector>
2625

2726
#include "arrow/array/builder_primitive.h"
2827
#include "arrow/dataset/file_ipc.h"
@@ -277,38 +276,37 @@ TEST_F(DatasetWriterTestFixture, BatchGreaterThanMaxRowsQueued) {
277276
ASSERT_EQ(paused_, false);
278277
}
279278

280-
#pragma GCC push_options
281-
#pragma GCC optimize ("O0")
282279
TEST_F(DatasetWriterTestFixture, BatchWriteConcurrent) {
283280
auto dataset_writer = MakeDatasetWriter(/*max_rows=*/5);
284281

285-
286-
for(int threads=1;threads<5;threads++){
287-
for(int iter=2;iter<=256;iter*=2){
288-
for(int batch=2;batch<=64;batch*=2){
282+
for (int threads = 1; threads < 5; threads++) {
283+
for (int iter = 2; iter <= 256; iter *= 2) {
284+
for (int batch = 2; batch <= 64; batch *= 2) {
289285
std::vector<std::thread> workers;
290-
for(int i=0;i<threads;++i){
291-
workers.push_back(std::thread(
292-
[&,i=i](){
293-
for(int j=0;j<iter;++j){
294-
while(paused_){SleepABit();};
295-
dataset_writer->WriteRecordBatch(MakeBatch(batch+i+10*j), "");
286+
for (int i = 0; i < threads; ++i) {
287+
workers.push_back(std::thread([&, i = i]() {
288+
for (int j = 0; j < iter; ++j) {
289+
while (paused_) {
290+
SleepABit();
291+
}
292+
dataset_writer->WriteRecordBatch(MakeBatch(batch + i + 10 * j), "");
296293
}
297294
}));
298295
}
299-
for (std::thread &t: workers) {
296+
for (std::thread& t : workers) {
300297
if (t.joinable()) {
301298
t.join();
302299
}
303-
while(paused_){SleepABit();};
300+
while (paused_) {
301+
SleepABit();
302+
}
304303
}
305304
}
306305
}
307306
}
308307
EndWriterChecked(dataset_writer.get());
309308
ASSERT_EQ(paused_, false);
310309
}
311-
#pragma GCC pop_options
312310

313311
TEST_F(DatasetWriterTestFixture, MaxRowsOneWrite) {
314312
write_options_.max_rows_per_file = 10;

0 commit comments

Comments
 (0)