leaves12138 commented on code in PR #7917:
URL: https://github.com/apache/paimon/pull/7917#discussion_r3278436360


##########
paimon-mosaic/src/main/java/org/apache/paimon/format/mosaic/MosaicWriterFactory.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.paimon.format.mosaic;
+
+import org.apache.paimon.format.FileFormatFactory;
+import org.apache.paimon.format.FormatWriter;
+import org.apache.paimon.format.FormatWriterFactory;
+import org.apache.paimon.fs.PositionOutputStream;
+import org.apache.paimon.types.RowType;
+
+import javax.annotation.Nullable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** A factory to create Mosaic {@link FormatWriter}. */
+public class MosaicWriterFactory implements FormatWriterFactory {
+
+    private final RowType rowType;
+    private final FileFormatFactory.FormatContext formatContext;
+    private final List<String> statsColumnNames;
+    private final @Nullable Integer numBuckets;
+
+    public MosaicWriterFactory(RowType rowType, 
FileFormatFactory.FormatContext formatContext) {
+        this.rowType = rowType;
+        this.formatContext = formatContext;
+        String statsColumnsValue = 
formatContext.options().get(MosaicFileFormat.STATS_COLUMNS);
+        if (statsColumnsValue == null || statsColumnsValue.trim().isEmpty()) {
+            this.statsColumnNames = new ArrayList<>();
+        } else {
+            this.statsColumnNames =
+                    Arrays.stream(statsColumnsValue.split(","))
+                            .map(String::trim)
+                            .filter(s -> !s.isEmpty())
+                            .collect(Collectors.toList());
+        }
+        this.numBuckets = 
formatContext.options().get(MosaicFileFormat.NUM_BUCKETS);
+    }
+
+    @Override
+    public FormatWriter create(PositionOutputStream out, String compression) {
+        // only support zstd, ignore compression

Review Comment:
   If Mosaic only supports ZSTD for now, silently ignoring this argument is 
still not safe. Users can configure `file.compression = none/lz4/snappy/...`, 
and Paimon may also put the configured compression into file names when 
`file.suffix.include.compression` is enabled, while the actual Mosaic footer 
remains ZSTD. Please fail fast unless the value is null or `zstd` 
(case-insensitive), or wait for the Mosaic Java API to expose and wire other 
supported compression constants explicitly.



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

Reply via email to