Skip to content

Commit

Permalink
iceberg: switch to string_view
Browse files Browse the repository at this point in the history
Switches serialization interfaces to use std::string_view instead of
const sstring&, as it's more generic.
  • Loading branch information
andrwng committed Oct 1, 2024
1 parent 45ded74 commit f673442
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/v/iceberg/manifest_avro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
namespace iceberg {

namespace {
schema schema_from_str(const std::string& s) {
schema schema_from_str(std::string_view s) {
json::Document parsed_schema;
parsed_schema.Parse(s);
parsed_schema.Parse(s.data(), s.size());
return parse_schema(parsed_schema);
}

Expand Down
4 changes: 2 additions & 2 deletions src/v/iceberg/schema_avro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ avro::Schema field_to_avro(const nested_field& field) {
}

avro::Schema
struct_type_to_avro(const struct_type& type, const ss::sstring& name) {
avro::RecordSchema avro_schema(name);
struct_type_to_avro(const struct_type& type, std::string_view name) {
avro::RecordSchema avro_schema(std::string{name});
const auto& fields = type.fields;
for (const auto& field_ptr : fields) {
const auto child_schema = field_to_avro(*field_ptr);
Expand Down
2 changes: 1 addition & 1 deletion src/v/iceberg/schema_avro.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace iceberg {
// The resulting schema is annotated with Iceberg attributes (e.g. 'field-id',
// 'element-id').
avro::Schema field_to_avro(const nested_field& field);
avro::Schema struct_type_to_avro(const struct_type&, const ss::sstring& name);
avro::Schema struct_type_to_avro(const struct_type&, std::string_view name);

// Translates the given Avro schema into its corresponding field/type, throwing
// an exception if the schema is not a valid Iceberg schema (e.g. missing
Expand Down
4 changes: 2 additions & 2 deletions src/v/iceberg/snapshot_json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ constexpr std::string_view operation_to_str(snapshot_operation o) {
}
}

snapshot_operation operation_from_str(const ss::sstring& operation_str) {
snapshot_operation operation_from_str(std::string_view operation_str) {
using enum snapshot_operation;
return string_switch<snapshot_operation>(operation_str)
.match(operation_to_str(append), append)
Expand All @@ -53,7 +53,7 @@ constexpr std::string_view ref_type_to_str(snapshot_ref_type t) {
}
}

snapshot_ref_type ref_type_from_str(const ss::sstring& ref_type_str) {
snapshot_ref_type ref_type_from_str(std::string_view ref_type_str) {
using enum snapshot_ref_type;
return string_switch<snapshot_ref_type>(ref_type_str)
.match(ref_type_to_str(tag), tag)
Expand Down
2 changes: 1 addition & 1 deletion src/v/iceberg/transform_json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ss::sstring transform_to_str(const transform& t) {
return std::visit(transform_str_visitor{}, t);
}

transform transform_from_str(const ss::sstring& s) {
transform transform_from_str(std::string_view s) {
if (s.starts_with("bucket")) {
auto n_str = extract_between('[', ']', s);
auto n = std::stoul(ss::sstring(n_str));
Expand Down
2 changes: 1 addition & 1 deletion src/v/iceberg/transform_json.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ namespace iceberg {
// NOTE: while there are no complex JSON types here, the transforms are
// expected to be serialized as a part of JSON files (e.g. table metadata).
ss::sstring transform_to_str(const transform&);
transform transform_from_str(const ss::sstring&);
transform transform_from_str(std::string_view);

} // namespace iceberg

0 comments on commit f673442

Please sign in to comment.