zhaoxuan1994 commented on code in PR #588: URL: https://github.com/apache/iceberg-cpp/pull/588#discussion_r2929645632
########## src/iceberg/puffin/puffin_compression_codec.cc: ########## @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "iceberg/puffin/puffin_compression_codec.h" + +#include <format> +#include <utility> + +namespace iceberg::puffin { + +namespace { +constexpr std::string_view kLz4CodecName = "lz4"; +constexpr std::string_view kZstdCodecName = "zstd"; +} // namespace + +std::optional<std::string_view> CodecName(PuffinCompressionCodec codec) { + switch (codec) { + case PuffinCompressionCodec::kNone: + return std::nullopt; + case PuffinCompressionCodec::kLz4: + return kLz4CodecName; + case PuffinCompressionCodec::kZstd: + return kZstdCodecName; + } + std::unreachable(); Review Comment: std::unreachable() here isn't actually throwing — it's a C++23 compile-time hint that this code path is impossible, since the switch already covers all enum values. This is a common pattern in the codebase (e.g., transform.cc, type.cc, expression.cc, etc.). Returning Result<> would require callers to handle an error that can't happen in practice. That said, PuffinCompressionCodecFromName does return Result<> since its string input can genuinely be invalid — so the two functions intentionally use different strategies based on their input types. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
