rdblue commented on code in PR #4537:
URL: https://github.com/apache/iceberg/pull/4537#discussion_r870914062


##########
core/src/main/java/org/apache/iceberg/stats/StatsWriter.java:
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.
+ */
+
+package org.apache.iceberg.stats;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import javax.annotation.Nullable;
+import org.apache.iceberg.io.OutputFile;
+import org.apache.iceberg.io.PositionOutputStream;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+public class StatsWriter implements Closeable {
+
+  private final PositionOutputStream outputStream;
+
+  private final Map<String, String> properties = Maps.newHashMap();
+  private final List<BlobMetadata> blobs = Lists.newArrayList();
+  private boolean compressFooter = false; // TODO compress footer by default 
when LZ4 support is added
+
+  private boolean headerWritten;
+  private boolean finished;
+  private Optional<Integer> footerSize = Optional.empty();
+
+  public StatsWriter(OutputFile outputFile) {
+    Preconditions.checkNotNull(outputFile, "outputFile is null");
+    this.outputStream = outputFile.create();
+  }
+
+  public void addFileProperty(String name, String value) {
+    Preconditions.checkNotNull(name, "name is null");
+    Preconditions.checkNotNull(value, "value is null");
+
+    if (properties.putIfAbsent(name, value) != null) {
+      throw new IllegalStateException(String.format("Property '%s' already 
set", name));
+    }
+  }
+  public void append(
+      String type,
+      Set<Integer> columnsCovered,
+      ByteBuffer blobData,
+      Optional<StatsCompressionCodec> compression) throws IOException {
+    checkNotFinished();
+    writeHeaderIfNeeded();
+
+    Preconditions.checkNotNull(type, "type is null");
+    long fileOffset = outputStream.getPos();
+    ByteBuffer data;

Review Comment:
   It doesn't look like you need a separate declaration anymore.



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

Reply via email to