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


##########
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 {
+ public:
+  ZlibImpl() { memset(&stream_, 0, sizeof(stream_)); }
+
+  ~ZlibImpl() {
+    if (initialized_) {
+      inflateEnd(&stream_);
+    }
+  }
+
+  Status Init() {
+    // Maximum window size
+    static int WINDOW_BITS = 15;
+    // Determine if this is libz or gzip from header.
+    static int DETECT_CODEC = 32;
+
+    int ret = inflateInit2(&stream_, WINDOW_BITS | DETECT_CODEC);

Review Comment:
   ```suggestion
       int ret = inflateInit2(&stream_, kWindowBits | kDetectCodec);
   ```



##########
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 {
+ public:
+  ZlibImpl() { memset(&stream_, 0, sizeof(stream_)); }
+
+  ~ZlibImpl() {
+    if (initialized_) {
+      inflateEnd(&stream_);
+    }
+  }
+
+  Status Init() {
+    // Maximum window size
+    static int WINDOW_BITS = 15;
+    // Determine if this is libz or gzip from header.
+    static int DETECT_CODEC = 32;

Review Comment:
   ```suggestion
       static int kWindowBits = 15;
       // Determine if this is libz or gzip from header.
       static int kDetectCodec = 32;
   ```



##########
src/iceberg/util/gzip_internal.h:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <memory>
+#include <string>
+
+#include "iceberg/result.h"
+
+namespace iceberg {
+
+class ZlibImpl;
+
+class GZipDecompressor {
+ public:
+  GZipDecompressor();
+
+  ~GZipDecompressor();
+
+  Status Init();
+
+  Result<std::string> Decompress(const std::string& compressed_data);
+
+ private:
+  std::shared_ptr<ZlibImpl> zlib_impl_;

Review Comment:
   ```suggestion
     std::unique_ptr<ZlibImpl> zlib_impl_;
   ```



-- 
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