Skip to content

Commit fc5b2fd

Browse files
committed
refactor: fix compiler warnings
1 parent 4db7c67 commit fc5b2fd

62 files changed

Lines changed: 254 additions & 207 deletions

Some content is hidden

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

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,12 @@
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+
endif()
25+
1826
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/data/data_writer.cc

Lines changed: 1 addition & 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

src/iceberg/data/position_delete_writer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class PositionDeleteWriter::Impl {
7272
buffered_positions_.push_back(pos);
7373
referenced_paths_.emplace(file_path);
7474

75-
if (buffered_paths_.size() >= options_.flush_threshold) {
75+
if (std::cmp_greater_equal(buffered_paths_.size(), options_.flush_threshold)) {
7676
return FlushBuffer();
7777
}
7878
return {};

src/iceberg/expression/binder.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,23 @@ Result<bool> IsBoundVisitor::Or(bool left_result, bool right_result) {
103103
return left_result && right_result;
104104
}
105105

106-
Result<bool> IsBoundVisitor::Predicate(const std::shared_ptr<BoundPredicate>& pred) {
106+
Result<bool> IsBoundVisitor::Predicate(
107+
[[maybe_unused]] const std::shared_ptr<BoundPredicate>& pred) {
107108
return true;
108109
}
109110

110-
Result<bool> IsBoundVisitor::Predicate(const std::shared_ptr<UnboundPredicate>& pred) {
111+
Result<bool> IsBoundVisitor::Predicate(
112+
[[maybe_unused]] const std::shared_ptr<UnboundPredicate>& pred) {
111113
return false;
112114
}
113115

114-
Result<bool> IsBoundVisitor::Aggregate(const std::shared_ptr<BoundAggregate>& aggregate) {
116+
Result<bool> IsBoundVisitor::Aggregate(
117+
[[maybe_unused]] const std::shared_ptr<BoundAggregate>& aggregate) {
115118
return true;
116119
}
117120

118121
Result<bool> IsBoundVisitor::Aggregate(
119-
const std::shared_ptr<UnboundAggregate>& aggregate) {
122+
[[maybe_unused]] const std::shared_ptr<UnboundAggregate>& aggregate) {
120123
return false;
121124
}
122125

src/iceberg/expression/expression.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class ICEBERG_EXPORT Expression : public util::Formattable {
7777
/// \brief Returns whether this expression will accept the same values as another.
7878
/// \param other another expression
7979
/// \return true if the expressions are equivalent
80-
virtual bool Equals(const Expression& other) const {
80+
virtual bool Equals([[maybe_unused]] const Expression& other) const {
8181
// only bound predicates can be equivalent
8282
return false;
8383
}

0 commit comments

Comments
 (0)