Skip to content

Commit 8074496

Browse files
authored
ARROW-18206: [C++][CI] Add a nightly build for C++20 compilation (apache#14571)
Fix a couple compilation issues (implicit this-capturing with "=" in lambdas is deprecated in C++20). Authored-by: Antoine Pitrou <antoine@python.org> Signed-off-by: Antoine Pitrou <antoine@python.org>
1 parent 5e53978 commit 8074496

18 files changed

Lines changed: 71 additions & 61 deletions

ci/docker/alpine-linux-3.16-cpp.dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ ENV ARROW_BUILD_TESTS=ON \
9595
ARROW_WITH_ZLIB=ON \
9696
ARROW_WITH_ZSTD=ON \
9797
AWSSDK_SOURCE=BUNDLED \
98-
CMAKE_CXX_STANDARD=17 \
9998
google_cloud_cpp_storage_SOURCE=BUNDLED \
10099
ORC_SOURCE=BUNDLED \
101100
PATH=/usr/lib/ccache/:$PATH \

ci/docker/conda-cpp.dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ ENV ARROW_BUILD_TESTS=ON \
6767
ARROW_WITH_SNAPPY=ON \
6868
ARROW_WITH_ZLIB=ON \
6969
ARROW_WITH_ZSTD=ON \
70-
CMAKE_CXX_STANDARD=17 \
7170
GTest_SOURCE=BUNDLED \
7271
PARQUET_BUILD_EXAMPLES=ON \
7372
PARQUET_BUILD_EXECUTABLES=ON \

cpp/src/arrow/compute/exec/source_node.cc

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct SourceNode : ExecNode {
112112
lock.unlock();
113113

114114
return generator_().Then(
115-
[=](const std::optional<ExecBatch>& maybe_morsel)
115+
[this](const std::optional<ExecBatch>& maybe_morsel)
116116
-> Future<ControlFlow<int>> {
117117
std::unique_lock<std::mutex> lock(mutex_);
118118
if (IsIterationEnd(maybe_morsel) || stop_requested_) {
@@ -131,22 +131,23 @@ struct SourceNode : ExecNode {
131131
bit_util::CeilDiv(morsel_length, ExecPlan::kMaxBatchSize));
132132
batch_count_ += num_batches;
133133
}
134-
RETURN_NOT_OK(plan_->ScheduleTask([=]() {
135-
int64_t offset = 0;
136-
do {
137-
int64_t batch_size = std::min<int64_t>(
138-
morsel_length - offset, ExecPlan::kMaxBatchSize);
139-
// In order for the legacy batching model to work we must
140-
// not slice batches from the source
141-
if (use_legacy_batching) {
142-
batch_size = morsel_length;
143-
}
144-
ExecBatch batch = morsel.Slice(offset, batch_size);
145-
offset += batch_size;
146-
outputs_[0]->InputReceived(this, std::move(batch));
147-
} while (offset < morsel.length);
148-
return Status::OK();
149-
}));
134+
RETURN_NOT_OK(plan_->ScheduleTask(
135+
[this, use_legacy_batching, morsel, morsel_length]() {
136+
int64_t offset = 0;
137+
do {
138+
int64_t batch_size = std::min<int64_t>(
139+
morsel_length - offset, ExecPlan::kMaxBatchSize);
140+
// In order for the legacy batching model to work we must
141+
// not slice batches from the source
142+
if (use_legacy_batching) {
143+
batch_size = morsel_length;
144+
}
145+
ExecBatch batch = morsel.Slice(offset, batch_size);
146+
offset += batch_size;
147+
outputs_[0]->InputReceived(this, std::move(batch));
148+
} while (offset < morsel.length);
149+
return Status::OK();
150+
}));
150151
lock.lock();
151152
if (!backpressure_future_.is_finished()) {
152153
EVENT(span_, "Source paused due to backpressure");
@@ -155,7 +156,7 @@ struct SourceNode : ExecNode {
155156
}
156157
return Future<ControlFlow<int>>::MakeFinished(Continue());
157158
},
158-
[=](const Status& error) -> ControlFlow<int> {
159+
[this](const Status& error) -> ControlFlow<int> {
159160
outputs_[0]->ErrorReceived(this, error);
160161
return Break(batch_count_);
161162
},

cpp/src/arrow/compute/light_array.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ KeyColumnArray::KeyColumnArray(const KeyColumnMetadata& metadata, int64_t length
2929
const uint8_t* fixed_length_buffer,
3030
const uint8_t* var_length_buffer, int bit_offset_validity,
3131
int bit_offset_fixed) {
32-
static_assert(std::is_pod<KeyColumnArray>::value,
33-
"This class was intended to be a POD type");
32+
static_assert(
33+
std::is_trivial_v<KeyColumnArray> && std::is_standard_layout_v<KeyColumnArray>,
34+
"This class was intended to be a POD type");
3435
metadata_ = metadata;
3536
length_ = length;
3637
buffers_[kValidityBuffer] = validity_buffer;

cpp/src/arrow/csv/column_builder.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void NullColumnBuilder::Insert(int64_t block_index,
151151
const int32_t num_rows = parser->num_rows();
152152
DCHECK_GE(num_rows, 0);
153153

154-
task_group_->Append([=]() -> Status {
154+
task_group_->Append([this, block_index, num_rows]() -> Status {
155155
std::unique_ptr<ArrayBuilder> builder;
156156
RETURN_NOT_OK(MakeBuilder(pool_, type_, &builder));
157157
std::shared_ptr<Array> res;
@@ -201,7 +201,7 @@ void TypedColumnBuilder::Insert(int64_t block_index,
201201
ReserveChunks(block_index);
202202

203203
// We're careful that all references in the closure outlive the Append() call
204-
task_group_->Append([=]() -> Status {
204+
task_group_->Append([this, parser, block_index]() -> Status {
205205
return SetChunk(block_index, converter_->Convert(*parser, col_index_));
206206
});
207207
}
@@ -252,7 +252,7 @@ Status InferringColumnBuilder::UpdateType() {
252252
}
253253

254254
void InferringColumnBuilder::ScheduleConvertChunk(int64_t chunk_index) {
255-
task_group_->Append([=]() { return TryConvertChunk(chunk_index); });
255+
task_group_->Append([this, chunk_index]() { return TryConvertChunk(chunk_index); });
256256
}
257257

258258
Status InferringColumnBuilder::TryConvertChunk(int64_t chunk_index) {

cpp/src/arrow/dataset/file_parquet.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,10 @@ Result<RecordBatchGenerator> ParquetFileFormat::ScanBatchesAsync(
445445
pre_filtered = true;
446446
if (row_groups.empty()) return MakeEmptyGenerator<std::shared_ptr<RecordBatch>>();
447447
}
448-
int64_t batch_size = options->batch_size;
449448
// Open the reader and pay the real IO cost.
450449
auto make_generator =
451-
[=](const std::shared_ptr<parquet::arrow::FileReader>& reader) mutable
450+
[this, options, parquet_fragment, pre_filtered,
451+
row_groups](const std::shared_ptr<parquet::arrow::FileReader>& reader) mutable
452452
-> Result<RecordBatchGenerator> {
453453
// Ensure that parquet_fragment has FileMetaData
454454
RETURN_NOT_OK(parquet_fragment->EnsureCompleteMetadata(reader.get()));
@@ -465,12 +465,13 @@ Result<RecordBatchGenerator> ParquetFileFormat::ScanBatchesAsync(
465465
GetFragmentScanOptions<ParquetFragmentScanOptions>(
466466
kParquetTypeName, options.get(), default_fragment_scan_options));
467467
int batch_readahead = options->batch_readahead;
468-
int64_t rows_to_readahead = batch_readahead * batch_size;
468+
int64_t rows_to_readahead = batch_readahead * options->batch_size;
469469
ARROW_ASSIGN_OR_RAISE(auto generator,
470470
reader->GetRecordBatchGenerator(
471471
reader, row_groups, column_projection,
472472
::arrow::internal::GetCpuThreadPool(), rows_to_readahead));
473-
RecordBatchGenerator sliced = SlicingGenerator(std::move(generator), batch_size);
473+
RecordBatchGenerator sliced =
474+
SlicingGenerator(std::move(generator), options->batch_size);
474475
RecordBatchGenerator sliced_readahead =
475476
MakeSerialReadaheadGenerator(std::move(sliced), batch_readahead);
476477
return sliced_readahead;

cpp/src/arrow/testing/gtest_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ void TestInitialized(const ArrayData& array) {
679679
// entire buffer data). If not all bits are well-defined, Valgrind will
680680
// error with "Conditional jump or move depends on uninitialised value(s)".
681681
if (total_bit == 0) {
682-
++throw_away;
682+
throw_away = throw_away + 1;
683683
}
684684
for (const auto& child : array.child_data) {
685685
TestInitialized(*child);

cpp/src/arrow/util/future_test.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,16 @@ class SimpleExecutor {
128128

129129
void SetFinishedDeferred(std::vector<std::pair<int, bool>> pairs) {
130130
std::this_thread::sleep_for(kYieldDuration);
131-
ABORT_NOT_OK(pool_->Spawn([=]() { SetFinished(pairs); }));
131+
ABORT_NOT_OK(
132+
pool_->Spawn([this, pairs = std::move(pairs)]() { SetFinished(pairs); }));
132133
}
133134

134135
// Mark future successful
135136
void SetFinished(int fut_index) { futures_[fut_index].MarkFinished(T(fut_index)); }
136137

137138
void SetFinishedDeferred(int fut_index) {
138139
std::this_thread::sleep_for(kYieldDuration);
139-
ABORT_NOT_OK(pool_->Spawn([=]() { SetFinished(fut_index); }));
140+
ABORT_NOT_OK(pool_->Spawn([this, fut_index]() { SetFinished(fut_index); }));
140141
}
141142

142143
// Mark all futures in [start, stop) successful
@@ -148,7 +149,7 @@ class SimpleExecutor {
148149

149150
void SetFinishedDeferred(int start, int stop) {
150151
std::this_thread::sleep_for(kYieldDuration);
151-
ABORT_NOT_OK(pool_->Spawn([=]() { SetFinished(start, stop); }));
152+
ABORT_NOT_OK(pool_->Spawn([this, start, stop]() { SetFinished(start, stop); }));
152153
}
153154

154155
protected:

cpp/src/arrow/util/hashing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ class BinaryMemoTable : public MemoTable {
840840

841841
std::pair<const HashTableEntry*, bool> Lookup(hash_t h, const void* data,
842842
builder_offset_type length) const {
843-
auto cmp_func = [=](const Payload* payload) {
843+
auto cmp_func = [&](const Payload* payload) {
844844
std::string_view lhs = binary_builder_.GetView(payload->memo_index);
845845
std::string_view rhs(static_cast<const char*>(data), length);
846846
return lhs == rhs;

cpp/src/arrow/util/thread_pool_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ class AddTester {
100100

101101
void SpawnTasks(ThreadPool* pool, AddTaskFunc add_func) {
102102
for (int i = 0; i < nadds_; ++i) {
103-
ASSERT_OK(pool->Spawn([=] { add_func(xs_[i], ys_[i], &outs_[i]); }, stop_token_));
103+
ASSERT_OK(pool->Spawn([this, add_func, i] { add_func(xs_[i], ys_[i], &outs_[i]); },
104+
stop_token_));
104105
}
105106
}
106107

0 commit comments

Comments
 (0)