rdblue commented on a change in pull request #1818: URL: https://github.com/apache/iceberg/pull/1818#discussion_r530032341
########## File path: flink/src/main/java/org/apache/iceberg/flink/sink/RowDataTaskWriter.java ########## @@ -0,0 +1,141 @@ +/* + * 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.flink.sink; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.util.List; +import java.util.Map; +import org.apache.flink.table.data.RowData; +import org.apache.flink.table.types.logical.RowType; +import org.apache.iceberg.FileFormat; +import org.apache.iceberg.PartitionKey; +import org.apache.iceberg.PartitionSpec; +import org.apache.iceberg.Schema; +import org.apache.iceberg.StructLike; +import org.apache.iceberg.flink.RowDataWrapper; +import org.apache.iceberg.io.BaseTaskWriter; +import org.apache.iceberg.io.FileAppenderFactory; +import org.apache.iceberg.io.FileIO; +import org.apache.iceberg.io.OutputFileFactory; +import org.apache.iceberg.relocated.com.google.common.collect.Maps; +import org.apache.iceberg.util.Tasks; + +public class RowDataTaskWriter extends BaseTaskWriter<RowData> { + + private static final PartitionKey UNPARTITIONED_KEY = new PartitionKey(PartitionSpec.unpartitioned(), null); + + private final Schema schema; + private final PartitionKey partitionKey; + private final RowDataWrapper rowDataWrapper; + private final List<Integer> equalityFieldIds; + + private final Map<PartitionKey, RowDataDeltaWriter> deltaWriterMap = Maps.newHashMap(); + + RowDataTaskWriter(PartitionSpec spec, + FileFormat format, + FileAppenderFactory<RowData> appenderFactory, + OutputFileFactory fileFactory, + FileIO io, + long targetFileSize, + Schema schema, + RowType flinkSchema, + List<Integer> equalityFieldIds) { + super(spec, format, appenderFactory, fileFactory, io, targetFileSize); + + this.schema = schema; + this.equalityFieldIds = equalityFieldIds; + + this.partitionKey = new PartitionKey(spec, schema); + this.rowDataWrapper = new RowDataWrapper(flinkSchema, schema.asStruct()); + } + + @Override + public void write(RowData row) throws IOException { + RowDataDeltaWriter deltaWriter; + + if (spec().fields().size() <= 0) { Review comment: You can use `spec.isUnpartitioned()`. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
