wgtmac commented on code in PR #108:
URL: https://github.com/apache/iceberg-cpp/pull/108#discussion_r2108002007


##########
src/iceberg/util/gzip_internal.cc:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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/util/gzip_internal.h"
+
+#include <zlib.h>
+
+#include <cstring>
+
+#include "iceberg/util/macros.h"
+
+namespace iceberg {
+
+class ZlibImpl {
+ public:
+  ZlibImpl() { memset(&stream_, 0, sizeof(stream_)); }
+
+  ~ZlibImpl() {
+    if (initialized_) {
+      inflateEnd(&stream_);
+    }
+  }
+
+  Status Init() {
+    // Maximum window size
+    static int kWindowBits = 15;

Review Comment:
   ```suggestion
       constexpr int kWindowBits = 15;
   ```



##########
src/iceberg/util/gzip_internal.cc:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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/util/gzip_internal.h"
+
+#include <zlib.h>
+
+#include <cstring>
+
+#include "iceberg/util/macros.h"
+
+namespace iceberg {
+
+class ZlibImpl {

Review Comment:
   Perhaps we can define a nesting class in that function and the dtor will be 
called when the function exists. I think @yingcai-cy's point is that we can 
simply declare `Result<std::string> Decompress(std::string_view input)` in the 
header file to make it easy to use.



##########
src/iceberg/result.h:
##########
@@ -38,6 +38,7 @@ enum class ErrorKind {
   kJsonParseError,
   kNoSuchNamespace,
   kNoSuchTable,
+  kDecompressError,

Review Comment:
   nit: sort alphabetically



##########
src/iceberg/result.h:
##########
@@ -80,6 +81,7 @@ DEFINE_ERROR_FUNCTION(IOError)
 DEFINE_ERROR_FUNCTION(JsonParseError)
 DEFINE_ERROR_FUNCTION(NoSuchNamespace)
 DEFINE_ERROR_FUNCTION(NoSuchTable)
+DEFINE_ERROR_FUNCTION(DecompressError)

Review Comment:
   nit: sort alphabetically



##########
src/iceberg/util/gzip_internal.cc:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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/util/gzip_internal.h"
+
+#include <zlib.h>
+
+#include <cstring>
+
+#include "iceberg/util/macros.h"
+
+namespace iceberg {
+
+class ZlibImpl {
+ public:
+  ZlibImpl() { memset(&stream_, 0, sizeof(stream_)); }
+
+  ~ZlibImpl() {
+    if (initialized_) {
+      inflateEnd(&stream_);
+    }
+  }
+
+  Status Init() {
+    // Maximum window size
+    static int kWindowBits = 15;
+    // Determine if this is libz or gzip from header.
+    static int kDetectCodec = 32;

Review Comment:
   ```suggestion
       constexpr int kDetectCodec = 32;
   ```



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to