Skip to content

Commit 905314f

Browse files
committed
refactor: Fix compiler warnings
1 parent 4db7c67 commit 905314f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+576
-273
lines changed

cmake_modules/IcebergThirdpartyToolchain.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,19 @@ function(resolve_avro_dependency)
217217
if(NOT TARGET avro-cpp::avrocpp_static)
218218
add_library(avro-cpp::avrocpp_static INTERFACE IMPORTED)
219219
target_link_libraries(avro-cpp::avrocpp_static INTERFACE avrocpp_s)
220-
target_include_directories(avro-cpp::avrocpp_static
220+
target_include_directories(avro-cpp::avrocpp_static SYSTEM
221221
INTERFACE ${avro-cpp_BINARY_DIR}
222222
${avro-cpp_SOURCE_DIR}/lang/c++)
223223
endif()
224224

225225
set(AVRO_VENDORED TRUE)
226226
set_target_properties(avrocpp_s PROPERTIES OUTPUT_NAME "iceberg_vendored_avrocpp")
227227
set_target_properties(avrocpp_s PROPERTIES POSITION_INDEPENDENT_CODE ON)
228+
get_target_property(_avro_iface_dirs avrocpp_s INTERFACE_INCLUDE_DIRECTORIES)
229+
if(_avro_iface_dirs)
230+
set_target_properties(avrocpp_s PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
231+
"${_avro_iface_dirs}")
232+
endif()
228233
install(TARGETS avrocpp_s
229234
EXPORT iceberg_targets
230235
RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}"

src/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,13 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
19+
20+
if(MSVC)
21+
add_compile_options(/W4 /we4100)
22+
else()
23+
add_compile_options(-Wall -Wextra -Werror=unused-parameter
24+
-Werror=missing-field-initializers)
25+
endif()
26+
1827
add_subdirectory(iceberg)

src/iceberg/avro/avro_data_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ Status AppendPrimitiveValueToBuilder(const ::avro::NodePtr& avro_node,
344344
const auto& fixed = avro_datum.value<::avro::GenericFixed>();
345345
const auto& fixed_type = internal::checked_cast<const FixedType&>(projected_type);
346346

347-
if (static_cast<size_t>(fixed.value().size()) != fixed_type.length()) {
347+
if (std::cmp_not_equal(fixed.value().size(), fixed_type.length())) {
348348
return InvalidArgument("Expected Avro fixed[{}], got: {}", fixed_type.length(),
349349
ToString(avro_node));
350350
}

src/iceberg/avro/avro_schema_util.cc

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,27 +125,32 @@ std::string ToString(const ::avro::LogicalType::Type& logical_type) {
125125
return ToString(::avro::LogicalType(logical_type));
126126
}
127127

128-
Status ToAvroNodeVisitor::Visit(const BooleanType& type, ::avro::NodePtr* node) {
128+
Status ToAvroNodeVisitor::Visit([[maybe_unused]] const BooleanType& type,
129+
::avro::NodePtr* node) {
129130
*node = std::make_shared<::avro::NodePrimitive>(::avro::AVRO_BOOL);
130131
return {};
131132
}
132133

133-
Status ToAvroNodeVisitor::Visit(const IntType& type, ::avro::NodePtr* node) {
134+
Status ToAvroNodeVisitor::Visit([[maybe_unused]] const IntType& type,
135+
::avro::NodePtr* node) {
134136
*node = std::make_shared<::avro::NodePrimitive>(::avro::AVRO_INT);
135137
return {};
136138
}
137139

138-
Status ToAvroNodeVisitor::Visit(const LongType& type, ::avro::NodePtr* node) {
140+
Status ToAvroNodeVisitor::Visit([[maybe_unused]] const LongType& type,
141+
::avro::NodePtr* node) {
139142
*node = std::make_shared<::avro::NodePrimitive>(::avro::AVRO_LONG);
140143
return {};
141144
}
142145

143-
Status ToAvroNodeVisitor::Visit(const FloatType& type, ::avro::NodePtr* node) {
146+
Status ToAvroNodeVisitor::Visit([[maybe_unused]] const FloatType& type,
147+
::avro::NodePtr* node) {
144148
*node = std::make_shared<::avro::NodePrimitive>(::avro::AVRO_FLOAT);
145149
return {};
146150
}
147151

148-
Status ToAvroNodeVisitor::Visit(const DoubleType& type, ::avro::NodePtr* node) {
152+
Status ToAvroNodeVisitor::Visit([[maybe_unused]] const DoubleType& type,
153+
::avro::NodePtr* node) {
149154
*node = std::make_shared<::avro::NodePrimitive>(::avro::AVRO_DOUBLE);
150155
return {};
151156
}
@@ -164,19 +169,22 @@ Status ToAvroNodeVisitor::Visit(const DecimalType& type, ::avro::NodePtr* node)
164169
return {};
165170
}
166171

167-
Status ToAvroNodeVisitor::Visit(const DateType& type, ::avro::NodePtr* node) {
172+
Status ToAvroNodeVisitor::Visit([[maybe_unused]] const DateType& type,
173+
::avro::NodePtr* node) {
168174
*node = std::make_shared<::avro::NodePrimitive>(::avro::AVRO_INT);
169175
(*node)->setLogicalType(::avro::LogicalType{::avro::LogicalType::DATE});
170176
return {};
171177
}
172178

173-
Status ToAvroNodeVisitor::Visit(const TimeType& type, ::avro::NodePtr* node) {
179+
Status ToAvroNodeVisitor::Visit([[maybe_unused]] const TimeType& type,
180+
::avro::NodePtr* node) {
174181
*node = std::make_shared<::avro::NodePrimitive>(::avro::AVRO_LONG);
175182
(*node)->setLogicalType(::avro::LogicalType{::avro::LogicalType::TIME_MICROS});
176183
return {};
177184
}
178185

179-
Status ToAvroNodeVisitor::Visit(const TimestampType& type, ::avro::NodePtr* node) {
186+
Status ToAvroNodeVisitor::Visit([[maybe_unused]] const TimestampType& type,
187+
::avro::NodePtr* node) {
180188
*node = std::make_shared<::avro::NodePrimitive>(::avro::AVRO_LONG);
181189
(*node)->setLogicalType(::avro::LogicalType{::avro::LogicalType::TIMESTAMP_MICROS});
182190
::avro::CustomAttributes attributes;
@@ -185,7 +193,8 @@ Status ToAvroNodeVisitor::Visit(const TimestampType& type, ::avro::NodePtr* node
185193
return {};
186194
}
187195

188-
Status ToAvroNodeVisitor::Visit(const TimestampTzType& type, ::avro::NodePtr* node) {
196+
Status ToAvroNodeVisitor::Visit([[maybe_unused]] const TimestampTzType& type,
197+
::avro::NodePtr* node) {
189198
*node = std::make_shared<::avro::NodePrimitive>(::avro::AVRO_LONG);
190199
(*node)->setLogicalType(::avro::LogicalType{::avro::LogicalType::TIMESTAMP_MICROS});
191200
::avro::CustomAttributes attributes;
@@ -194,12 +203,14 @@ Status ToAvroNodeVisitor::Visit(const TimestampTzType& type, ::avro::NodePtr* no
194203
return {};
195204
}
196205

197-
Status ToAvroNodeVisitor::Visit(const StringType& type, ::avro::NodePtr* node) {
206+
Status ToAvroNodeVisitor::Visit([[maybe_unused]] const StringType& type,
207+
::avro::NodePtr* node) {
198208
*node = std::make_shared<::avro::NodePrimitive>(::avro::AVRO_STRING);
199209
return {};
200210
}
201211

202-
Status ToAvroNodeVisitor::Visit(const UuidType& type, ::avro::NodePtr* node) {
212+
Status ToAvroNodeVisitor::Visit([[maybe_unused]] const UuidType& type,
213+
::avro::NodePtr* node) {
203214
*node = std::make_shared<::avro::NodeFixed>();
204215
(*node)->setName(::avro::Name("uuid_fixed"));
205216
(*node)->setFixedSize(16);
@@ -214,7 +225,8 @@ Status ToAvroNodeVisitor::Visit(const FixedType& type, ::avro::NodePtr* node) {
214225
return {};
215226
}
216227

217-
Status ToAvroNodeVisitor::Visit(const BinaryType& type, ::avro::NodePtr* node) {
228+
Status ToAvroNodeVisitor::Visit([[maybe_unused]] const BinaryType& type,
229+
::avro::NodePtr* node) {
218230
*node = std::make_shared<::avro::NodePrimitive>(::avro::AVRO_BYTES);
219231
return {};
220232
}
@@ -573,8 +585,9 @@ Status ValidateAvroSchemaEvolution(const Type& expected_type,
573585
break;
574586
case TypeId::kFixed:
575587
if (avro_node->type() == ::avro::AVRO_FIXED &&
576-
avro_node->fixedSize() ==
577-
internal::checked_cast<const FixedType&>(expected_type).length()) {
588+
std::cmp_equal(
589+
avro_node->fixedSize(),
590+
internal::checked_cast<const FixedType&>(expected_type).length())) {
578591
return {};
579592
}
580593
break;

src/iceberg/avro/avro_stream_internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class AvroInputStream : public ::avro::SeekableInputStream {
5555

5656
private:
5757
std::shared_ptr<::arrow::io::RandomAccessFile> input_stream_;
58-
const int64_t buffer_size_;
59-
std::vector<uint8_t> buffer_;
58+
[[maybe_unused]] const int64_t buffer_size_;
59+
[[maybe_unused]] std::vector<uint8_t> buffer_;
6060
size_t byte_count_ = 0; // bytes read from the input stream
6161
size_t buffer_pos_ = 0; // next position to read in the buffer
6262
size_t available_bytes_ = 0; // bytes available in the buffer
@@ -91,7 +91,7 @@ class AvroOutputStream : public ::avro::OutputStream {
9191

9292
private:
9393
std::shared_ptr<::arrow::io::OutputStream> output_stream_;
94-
const int64_t buffer_size_;
94+
[[maybe_unused]] const int64_t buffer_size_;
9595
std::vector<uint8_t> buffer_;
9696
size_t buffer_pos_ = 0; // position in the buffer
9797
uint64_t flushed_bytes_ = 0; // bytes flushed to the output stream

src/iceberg/catalog/memory/in_memory_catalog.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,15 @@ Result<bool> InMemoryCatalog::TableExists(const TableIdentifier& identifier) con
508508
return root_namespace_->TableExists(identifier);
509509
}
510510

511-
Status InMemoryCatalog::DropTable(const TableIdentifier& identifier, bool purge) {
511+
Status InMemoryCatalog::DropTable(const TableIdentifier& identifier,
512+
[[maybe_unused]] bool purge) {
512513
std::unique_lock lock(mutex_);
513514
// TODO(Guotao): Delete all metadata files if purge is true.
514515
return root_namespace_->UnregisterTable(identifier);
515516
}
516517

517-
Status InMemoryCatalog::RenameTable(const TableIdentifier& from,
518-
const TableIdentifier& to) {
518+
Status InMemoryCatalog::RenameTable([[maybe_unused]] const TableIdentifier& from,
519+
[[maybe_unused]] const TableIdentifier& to) {
519520
std::unique_lock lock(mutex_);
520521
return NotImplemented("rename table");
521522
}

src/iceberg/catalog/rest/http_client.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ ErrorResponse BuildDefaultErrorResponse(const cpr::Response& response) {
106106
.type = std::string(kRestExceptionType),
107107
.message = !response.reason.empty() ? response.reason
108108
: GetStandardReasonPhrase(response.status_code),
109+
.stack = {},
109110
};
110111
}
111112

src/iceberg/catalog/rest/rest_catalog.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,11 @@ Result<std::shared_ptr<Table>> RestCatalog::UpdateTable(
365365
ICEBERG_ENDPOINT_CHECK(supported_endpoints_, Endpoint::UpdateTable());
366366
ICEBERG_ASSIGN_OR_RAISE(auto path, paths_->Table(identifier));
367367

368-
CommitTableRequest request{.identifier = identifier};
368+
CommitTableRequest request{
369+
.identifier = identifier,
370+
.requirements = {},
371+
.updates = {},
372+
};
369373
request.requirements.reserve(requirements.size());
370374
for (const auto& req : requirements) {
371375
request.requirements.push_back(req->Clone());

src/iceberg/data/data_writer.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class DataWriter::Impl {
3535
.path = options.path,
3636
.schema = options.schema,
3737
.io = options.io,
38+
.metadata = {},
3839
.properties = WriterProperties::FromMap(options.properties),
3940
};
4041

@@ -92,8 +93,14 @@ class DataWriter::Impl {
9293
metrics.nan_value_counts.end()},
9394
.lower_bounds = std::move(lower_bounds_map),
9495
.upper_bounds = std::move(upper_bounds_map),
96+
.key_metadata = {},
9597
.split_offsets = std::move(split_offsets),
98+
.equality_ids = {},
9699
.sort_order_id = options_.sort_order_id,
100+
.first_row_id = std::nullopt,
101+
.referenced_data_file = std::nullopt,
102+
.content_offset = std::nullopt,
103+
.content_size_in_bytes = std::nullopt,
97104
.partition_spec_id =
98105
options_.spec ? std::make_optional(options_.spec->spec_id()) : std::nullopt,
99106
});

src/iceberg/data/equality_delete_writer.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class EqualityDeleteWriter::Impl {
3535
.path = options.path,
3636
.schema = options.schema,
3737
.io = options.io,
38+
.metadata = {},
3839
.properties = WriterProperties::FromMap(options.properties),
3940
};
4041

@@ -92,9 +93,14 @@ class EqualityDeleteWriter::Impl {
9293
metrics.nan_value_counts.end()},
9394
.lower_bounds = std::move(lower_bounds_map),
9495
.upper_bounds = std::move(upper_bounds_map),
96+
.key_metadata = {},
9597
.split_offsets = std::move(split_offsets),
9698
.equality_ids = options_.equality_field_ids,
9799
.sort_order_id = options_.sort_order_id,
100+
.first_row_id = std::nullopt,
101+
.referenced_data_file = std::nullopt,
102+
.content_offset = std::nullopt,
103+
.content_size_in_bytes = std::nullopt,
98104
.partition_spec_id =
99105
options_.spec ? std::make_optional(options_.spec->spec_id()) : std::nullopt,
100106
});

0 commit comments

Comments
 (0)