xx789633 commented on code in PR #1555: URL: https://github.com/apache/fluss/pull/1555#discussion_r2282593501
########## fluss-lake/fluss-lake-iceberg/src/main/java/com/alibaba/fluss/lake/iceberg/tiering/writer/GenericTaskDeltaWriter.java: ########## @@ -0,0 +1,85 @@ +/* + * 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 com.alibaba.fluss.lake.iceberg.tiering.writer; + +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.data.Record; +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 java.io.IOException; + +/** A generic task equality delta writer. * */ +class GenericTaskDeltaWriter extends BaseTaskWriter<Record> { + private final GenericEqualityDeltaWriter deltaWriter; + + public GenericTaskDeltaWriter( + Schema schema, + Schema deleteSchema, + PartitionSpec spec, + FileFormat format, + FileAppenderFactory<Record> appenderFactory, + OutputFileFactory fileFactory, + FileIO io, + long targetFileSize) { + super(spec, format, appenderFactory, fileFactory, io, targetFileSize); + this.deltaWriter = new GenericEqualityDeltaWriter(null, schema, deleteSchema); + } + + @Override + public void write(Record row) throws IOException { + deltaWriter.write(row); + } + + public void delete(Record row) throws IOException { + deltaWriter.delete(row); + } + + // The caller of this function is responsible for passing in a record with only the key fields + public void deleteKey(Record key) throws IOException { + deltaWriter.deleteKey(key); + } + + @Override + public void close() throws IOException { + deltaWriter.close(); + } + + private class GenericEqualityDeltaWriter extends BaseEqualityDeltaWriter { + private GenericEqualityDeltaWriter( + PartitionKey partition, Schema schema, Schema eqDeleteSchema) { + super(partition, schema, eqDeleteSchema); + } + + @Override + protected StructLike asStructLike(Record row) { + return row; + } + + @Override + protected StructLike asStructLikeKey(Record data) { Review Comment: Fixed. ########## fluss-lake/fluss-lake-iceberg/src/main/java/com/alibaba/fluss/lake/iceberg/tiering/writer/GenericTaskDeltaWriter.java: ########## @@ -0,0 +1,85 @@ +/* + * 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 com.alibaba.fluss.lake.iceberg.tiering.writer; + +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.data.Record; +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 java.io.IOException; + +/** A generic task equality delta writer. * */ +class GenericTaskDeltaWriter extends BaseTaskWriter<Record> { + private final GenericEqualityDeltaWriter deltaWriter; + + public GenericTaskDeltaWriter( + Schema schema, + Schema deleteSchema, + PartitionSpec spec, + FileFormat format, + FileAppenderFactory<Record> appenderFactory, + OutputFileFactory fileFactory, + FileIO io, + long targetFileSize) { + super(spec, format, appenderFactory, fileFactory, io, targetFileSize); + this.deltaWriter = new GenericEqualityDeltaWriter(null, schema, deleteSchema); + } + + @Override + public void write(Record row) throws IOException { + deltaWriter.write(row); + } + + public void delete(Record row) throws IOException { + deltaWriter.delete(row); + } + + // The caller of this function is responsible for passing in a record with only the key fields + public void deleteKey(Record key) throws IOException { + deltaWriter.deleteKey(key); + } + + @Override + public void close() throws IOException { + deltaWriter.close(); + } + + private class GenericEqualityDeltaWriter extends BaseEqualityDeltaWriter { + private GenericEqualityDeltaWriter( + PartitionKey partition, Schema schema, Schema eqDeleteSchema) { + super(partition, schema, eqDeleteSchema); + } + + @Override + protected StructLike asStructLike(Record row) { Review Comment: Fixed. -- 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]
