Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions src/iceberg/catalog/memory/in_memory_catalog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,23 +384,25 @@ Result<std::vector<TableIdentifier>> InMemoryCatalog::ListTables(
}

Result<std::unique_ptr<Table>> InMemoryCatalog::CreateTable(
const TableIdentifier& identifier, const Schema& schema, const PartitionSpec& spec,
const std::string& location,
const std::unordered_map<std::string, std::string>& properties) {
[[maybe_unused]] const TableIdentifier& identifier,
[[maybe_unused]] const Schema& schema, [[maybe_unused]] const PartitionSpec& spec,
[[maybe_unused]] const std::string& location,
[[maybe_unused]] const std::unordered_map<std::string, std::string>& properties) {
return NotImplemented("create table");
}

Result<std::unique_ptr<Table>> InMemoryCatalog::UpdateTable(
const TableIdentifier& identifier,
const std::vector<std::unique_ptr<TableRequirement>>& requirements,
const std::vector<std::unique_ptr<TableUpdate>>& updates) {
[[maybe_unused]] const TableIdentifier& identifier,
[[maybe_unused]] const std::vector<std::unique_ptr<TableRequirement>>& requirements,
[[maybe_unused]] const std::vector<std::unique_ptr<TableUpdate>>& updates) {
return NotImplemented("update table");
}

Result<std::shared_ptr<Transaction>> InMemoryCatalog::StageCreateTable(
const TableIdentifier& identifier, const Schema& schema, const PartitionSpec& spec,
const std::string& location,
const std::unordered_map<std::string, std::string>& properties) {
[[maybe_unused]] const TableIdentifier& identifier,
[[maybe_unused]] const Schema& schema, [[maybe_unused]] const PartitionSpec& spec,
[[maybe_unused]] const std::string& location,
[[maybe_unused]] const std::unordered_map<std::string, std::string>& properties) {
return NotImplemented("stage create table");
}

Expand All @@ -409,14 +411,15 @@ Result<bool> InMemoryCatalog::TableExists(const TableIdentifier& identifier) con
return root_namespace_->TableExists(identifier);
}

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

Status InMemoryCatalog::RenameTable(const TableIdentifier& from,
const TableIdentifier& to) {
Status InMemoryCatalog::RenameTable([[maybe_unused]] const TableIdentifier& from,
[[maybe_unused]] const TableIdentifier& to) {
std::unique_lock lock(mutex_);
return NotImplemented("rename table");
}
Expand Down Expand Up @@ -455,7 +458,8 @@ Result<std::shared_ptr<Table>> InMemoryCatalog::RegisterTable(
}

std::unique_ptr<Catalog::TableBuilder> InMemoryCatalog::BuildTable(
const TableIdentifier& identifier, const Schema& schema) const {
[[maybe_unused]] const TableIdentifier& identifier,
[[maybe_unused]] const Schema& schema) const {
throw IcebergError("not implemented");
}

Expand Down
60 changes: 30 additions & 30 deletions src/iceberg/catalog/rest/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ namespace iceberg::rest {

/// \brief Server-provided configuration for the catalog.
struct ICEBERG_REST_EXPORT CatalogConfig {
std::unordered_map<std::string, std::string> defaults; // required
std::unordered_map<std::string, std::string> overrides; // required
std::vector<std::string> endpoints;
std::unordered_map<std::string, std::string> defaults{}; // required
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to add {} for everything, at least not for STL containers and std::string. Please try to minimize lines of change like this.

std::unordered_map<std::string, std::string> overrides{}; // required
std::vector<std::string> endpoints{};

/// \brief Validates the CatalogConfig.
Status Validate() const {
Expand All @@ -55,10 +55,10 @@ struct ICEBERG_REST_EXPORT CatalogConfig {

/// \brief JSON error payload returned in a response with further details on the error.
struct ICEBERG_REST_EXPORT ErrorModel {
std::string message; // required
std::string type; // required
uint32_t code; // required
std::vector<std::string> stack;
std::string message{}; // required
std::string type{}; // required
uint32_t code{}; // required
std::vector<std::string> stack{};

/// \brief Validates the ErrorModel.
Status Validate() const {
Expand All @@ -77,7 +77,7 @@ struct ICEBERG_REST_EXPORT ErrorModel {

/// \brief Error response body returned in a response.
struct ICEBERG_REST_EXPORT ErrorResponse {
ErrorModel error; // required
ErrorModel error{}; // required

/// \brief Validates the ErrorResponse.
// We don't validate the error field because ErrorModel::Validate has been called in the
Expand All @@ -87,17 +87,17 @@ struct ICEBERG_REST_EXPORT ErrorResponse {

/// \brief Request to create a namespace.
struct ICEBERG_REST_EXPORT CreateNamespaceRequest {
Namespace namespace_; // required
std::unordered_map<std::string, std::string> properties;
Namespace namespace_{}; // required
std::unordered_map<std::string, std::string> properties{};

/// \brief Validates the CreateNamespaceRequest.
Status Validate() const { return {}; }
};

/// \brief Update or delete namespace properties request.
struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesRequest {
std::vector<std::string> removals;
std::unordered_map<std::string, std::string> updates;
std::vector<std::string> removals{};
std::unordered_map<std::string, std::string> updates{};

/// \brief Validates the UpdateNamespacePropertiesRequest.
Status Validate() const {
Expand All @@ -112,8 +112,8 @@ struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesRequest {

/// \brief Request to register a table.
struct ICEBERG_REST_EXPORT RegisterTableRequest {
std::string name; // required
std::string metadata_location; // required
std::string name{}; // required
std::string metadata_location{}; // required
bool overwrite = false;

/// \brief Validates the RegisterTableRequest.
Expand All @@ -132,8 +132,8 @@ struct ICEBERG_REST_EXPORT RegisterTableRequest {

/// \brief Request to rename a table.
struct ICEBERG_REST_EXPORT RenameTableRequest {
TableIdentifier source; // required
TableIdentifier destination; // required
TableIdentifier source{}; // required
TableIdentifier destination{}; // required

/// \brief Validates the RenameTableRequest.
Status Validate() const {
Expand All @@ -148,9 +148,9 @@ using PageToken = std::string;

/// \brief Result body for table create/load/register APIs.
struct ICEBERG_REST_EXPORT LoadTableResult {
std::string metadata_location;
std::shared_ptr<TableMetadata> metadata; // required
std::unordered_map<std::string, std::string> config;
std::string metadata_location{};
std::shared_ptr<TableMetadata> metadata{}; // required
std::unordered_map<std::string, std::string> config{};
// TODO(Li Feiyang): Add std::shared_ptr<StorageCredential> storage_credential;

/// \brief Validates the LoadTableResult.
Expand All @@ -170,45 +170,45 @@ using LoadTableResponse = LoadTableResult;

/// \brief Response body for listing namespaces.
struct ICEBERG_REST_EXPORT ListNamespacesResponse {
PageToken next_page_token;
std::vector<Namespace> namespaces;
PageToken next_page_token{};
std::vector<Namespace> namespaces{};

/// \brief Validates the ListNamespacesResponse.
Status Validate() const { return {}; }
};

/// \brief Response body after creating a namespace.
struct ICEBERG_REST_EXPORT CreateNamespaceResponse {
Namespace namespace_; // required
std::unordered_map<std::string, std::string> properties;
Namespace namespace_{}; // required
std::unordered_map<std::string, std::string> properties{};

/// \brief Validates the CreateNamespaceResponse.
Status Validate() const { return {}; }
};

/// \brief Response body for loading namespace properties.
struct ICEBERG_REST_EXPORT GetNamespaceResponse {
Namespace namespace_; // required
std::unordered_map<std::string, std::string> properties;
Namespace namespace_{}; // required
std::unordered_map<std::string, std::string> properties{};

/// \brief Validates the GetNamespaceResponse.
Status Validate() const { return {}; }
};

/// \brief Response body after updating namespace properties.
struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesResponse {
std::vector<std::string> updated; // required
std::vector<std::string> removed; // required
std::vector<std::string> missing;
std::vector<std::string> updated{}; // required
std::vector<std::string> removed{}; // required
std::vector<std::string> missing{};

/// \brief Validates the UpdateNamespacePropertiesResponse.
Status Validate() const { return {}; }
};

/// \brief Response body for listing tables in a namespace.
struct ICEBERG_REST_EXPORT ListTablesResponse {
PageToken next_page_token;
std::vector<TableIdentifier> identifiers;
PageToken next_page_token{};
std::vector<TableIdentifier> identifiers{};

/// \brief Validates the ListTablesResponse.
Status Validate() const { return {}; }
Expand Down
6 changes: 4 additions & 2 deletions src/iceberg/expression/binder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ Result<bool> IsBoundVisitor::Or(bool left_result, bool right_result) {
return left_result && right_result;
}

Result<bool> IsBoundVisitor::Predicate(const std::shared_ptr<BoundPredicate>& pred) {
Result<bool> IsBoundVisitor::Predicate(
[[maybe_unused]] const std::shared_ptr<BoundPredicate>& pred) {
return true;
}

Result<bool> IsBoundVisitor::Predicate(const std::shared_ptr<UnboundPredicate>& pred) {
Result<bool> IsBoundVisitor::Predicate(
[[maybe_unused]] const std::shared_ptr<UnboundPredicate>& pred) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/expression/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ICEBERG_EXPORT Expression : public util::Formattable {
/// \brief Returns whether this expression will accept the same values as another.
/// \param other another expression
/// \return true if the expressions are equivalent
virtual bool Equals(const Expression& other) const {
virtual bool Equals([[maybe_unused]] const Expression& other) const {
// only bound predicates can be equivalent
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion src/iceberg/expression/expressions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ std::shared_ptr<NamedReference> Expressions::Ref(std::string name) {
return ref;
}

Literal Expressions::Lit(Literal::Value value, std::shared_ptr<PrimitiveType> type) {
Literal Expressions::Lit([[maybe_unused]] Literal::Value value,
[[maybe_unused]] std::shared_ptr<PrimitiveType> type) {
throw ExpressionError("Literal creation is not implemented");
}

Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/expression/literal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Result<Literal> LiteralCaster::CastFromBinary(
switch (target_type->type_id()) {
case TypeId::kFixed: {
auto target_fixed_type = internal::checked_pointer_cast<FixedType>(target_type);
if (binary_val.size() == target_fixed_type->length()) {
if (static_cast<int32_t>(binary_val.size()) == target_fixed_type->length()) {
return Literal::Fixed(std::move(binary_val));
}
return InvalidArgument("Failed to cast Binary with length {} to Fixed({})",
Expand Down
9 changes: 5 additions & 4 deletions src/iceberg/file_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class ICEBERG_EXPORT FileIO {
/// the length to read, e.g. S3 `GetObject` has a Range parameter.
/// \return The content of the file if the read succeeded, an error code if the read
/// failed.
virtual Result<std::string> ReadFile(const std::string& file_location,
std::optional<size_t> length) {
virtual Result<std::string> ReadFile([[maybe_unused]] const std::string& file_location,
[[maybe_unused]] std::optional<size_t> length) {
// We provide a default implementation to avoid Windows linker error LNK2019.
return NotImplemented("ReadFile not implemented");
}
Expand All @@ -62,15 +62,16 @@ class ICEBERG_EXPORT FileIO {
/// \param overwrite If true, overwrite the file if it exists. If false, fail if the
/// file exists.
/// \return void if the write succeeded, an error code if the write failed.
virtual Status WriteFile(const std::string& file_location, std::string_view content) {
virtual Status WriteFile([[maybe_unused]] const std::string& file_location,
[[maybe_unused]] std::string_view content) {
return NotImplemented("WriteFile not implemented");
}

/// \brief Delete a file at the given location.
///
/// \param file_location The location of the file to delete.
/// \return void if the delete succeeded, an error code if the delete failed.
virtual Status DeleteFile(const std::string& file_location) {
virtual Status DeleteFile([[maybe_unused]] const std::string& file_location) {
return NotImplemented("DeleteFile not implemented");
}
};
Expand Down
14 changes: 7 additions & 7 deletions src/iceberg/file_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,23 @@ class ReaderProperties : public ConfigBase<ReaderProperties> {
/// \brief Options for creating a reader.
struct ICEBERG_EXPORT ReaderOptions {
/// \brief The path to the file to read.
std::string path;
std::string path{};
/// \brief The total length of the file.
std::optional<size_t> length;
std::optional<size_t> length{};
/// \brief The split to read.
std::optional<Split> split;
std::optional<Split> split{};
/// \brief FileIO instance to open the file. Reader implementations should down cast it
/// to the specific FileIO implementation. By default, the `iceberg-bundle` library uses
/// `ArrowFileSystemFileIO` as the default implementation.
std::shared_ptr<class FileIO> io;
std::shared_ptr<class FileIO> io{};
/// \brief The projection schema to read from the file. This field is required.
std::shared_ptr<class Schema> projection;
std::shared_ptr<class Schema> projection{};
/// \brief The filter to apply to the data. Reader implementations may ignore this if
/// the file format does not support filtering.
std::shared_ptr<class Expression> filter;
std::shared_ptr<class Expression> filter{};
/// \brief Name mapping for schema evolution compatibility. Used when reading files
/// that may have different field names than the current schema.
std::shared_ptr<class NameMapping> name_mapping;
std::shared_ptr<class NameMapping> name_mapping{};
/// \brief Format-specific or implementation-specific properties.
std::shared_ptr<ReaderProperties> properties = ReaderProperties::default_properties();
};
Expand Down
7 changes: 4 additions & 3 deletions src/iceberg/manifest_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,14 @@ ManifestEntryAdapter::~ManifestEntryAdapter() {
Status ManifestEntryAdapter::AppendPartitionValues(
ArrowArray* array, const std::shared_ptr<StructType>& partition_type,
const std::vector<Literal>& partition_values) {
if (array->n_children != partition_type->fields().size()) [[unlikely]] {
auto fields = partition_type->fields();
auto num_fields = static_cast<int64_t>(fields.size());
if (array->n_children != num_fields) [[unlikely]] {
return InvalidArrowData("Arrow array of partition does not match partition type.");
}
if (partition_values.size() != partition_type->fields().size()) [[unlikely]] {
if (partition_values.size() != fields.size()) [[unlikely]] {
return InvalidArrowData("Literal list of partition does not match partition type.");
}
auto fields = partition_type->fields();

for (size_t i = 0; i < fields.size(); i++) {
const auto& partition_value = partition_values[i];
Expand Down
7 changes: 4 additions & 3 deletions src/iceberg/manifest_reader_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
return InvalidManifestList("Columns size not match between schema:{} and array:{}",
schema->n_children, array_in->n_children);
}
if (iceberg_schema.fields().size() != array_in->n_children) {
if (static_cast<int64_t>(iceberg_schema.fields().size()) != array_in->n_children) {

Check warning on line 199 in src/iceberg/manifest_reader_internal.cc

View workflow job for this annotation

GitHub Actions / cpp-linter

src/iceberg/manifest_reader_internal.cc:199:7 [modernize-use-integer-sign-comparison]

comparison between 'signed' and 'unsigned' integers
return InvalidManifestList("Columns size not match between schema:{} and array:{}",
iceberg_schema.fields().size(), array_in->n_children);
}
Expand Down Expand Up @@ -333,7 +333,8 @@
if (view_of_column->storage_type != ArrowType::NANOARROW_TYPE_STRUCT) {
return InvalidManifest("DataFile field should be a struct.");
}
if (view_of_column->n_children != data_file_schema->fields().size()) {
if (view_of_column->n_children !=

Check warning on line 336 in src/iceberg/manifest_reader_internal.cc

View workflow job for this annotation

GitHub Actions / cpp-linter

src/iceberg/manifest_reader_internal.cc:336:7 [modernize-use-integer-sign-comparison]

comparison between 'signed' and 'unsigned' integers
static_cast<int64_t>(data_file_schema->fields().size())) {
return InvalidManifest("DataFile schema size:{} not match with ArrayArray columns:{}",
data_file_schema->fields().size(), view_of_column->n_children);
}
Expand Down Expand Up @@ -459,7 +460,7 @@
return InvalidManifest("Columns size not match between schema:{} and array:{}",
schema->n_children, array_in->n_children);
}
if (iceberg_schema.fields().size() != array_in->n_children) {
if (static_cast<int64_t>(iceberg_schema.fields().size()) != array_in->n_children) {

Check warning on line 463 in src/iceberg/manifest_reader_internal.cc

View workflow job for this annotation

GitHub Actions / cpp-linter

src/iceberg/manifest_reader_internal.cc:463:7 [modernize-use-integer-sign-comparison]

comparison between 'signed' and 'unsigned' integers
return InvalidManifest("Columns size not match between schema:{} and array:{}",
iceberg_schema.fields().size(), array_in->n_children);
}
Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/name_mapping.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class CreateMappingVisitor {
}

template <typename T>
Result<std::unique_ptr<MappedFields>> Visit(const T& type) const {
Result<std::unique_ptr<MappedFields>> Visit([[maybe_unused]] const T& type) const {
return nullptr;
}

Expand Down
6 changes: 3 additions & 3 deletions src/iceberg/name_mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ namespace iceberg {
/// This class is trivial enough that we don't need any function.
struct ICEBERG_EXPORT MappedField {
/// \brief A required list of 0 or more names for a field.
std::unordered_set<std::string> names;
std::unordered_set<std::string> names{};
/// \brief An optional Iceberg field ID used when a field's name is present in `names`.
std::optional<int32_t> field_id;
std::optional<int32_t> field_id{};
/// \brief An optional list of field mappings for child field of structs, maps, and
/// lists.
std::shared_ptr<class MappedFields> nested_mapping;
std::shared_ptr<class MappedFields> nested_mapping{};

friend bool operator==(const MappedField& lhs, const MappedField& rhs);
};
Expand Down
Loading
Loading