-
Notifications
You must be signed in to change notification settings - Fork 3k
Core: Implement FanoutPositionDeleteWriter #3377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
core/src/main/java/org/apache/iceberg/io/FanoutPositionDeleteWriter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /* | ||
| * 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.io; | ||
|
|
||
| import java.util.List; | ||
| import org.apache.iceberg.DeleteFile; | ||
| import org.apache.iceberg.PartitionSpec; | ||
| import org.apache.iceberg.StructLike; | ||
| import org.apache.iceberg.deletes.PositionDelete; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.Lists; | ||
| import org.apache.iceberg.util.CharSequenceSet; | ||
|
|
||
| /** | ||
| * A position delete writer capable of writing to multiple specs and partitions that keeps position delete writers | ||
| * for each seen spec/partition pair open until this writer is closed. | ||
| */ | ||
| public class FanoutPositionDeleteWriter<T> extends FanoutWriter<PositionDelete<T>, DeleteWriteResult> { | ||
|
|
||
| private final FileWriterFactory<T> writerFactory; | ||
| private final OutputFileFactory fileFactory; | ||
| private final FileIO io; | ||
| private final long targetFileSizeInBytes; | ||
| private final List<DeleteFile> deleteFiles; | ||
| private final CharSequenceSet referencedDataFiles; | ||
|
|
||
| public FanoutPositionDeleteWriter(FileWriterFactory<T> writerFactory, OutputFileFactory fileFactory, | ||
| FileIO io, long targetFileSizeInBytes) { | ||
| this.writerFactory = writerFactory; | ||
| this.fileFactory = fileFactory; | ||
| this.io = io; | ||
| this.targetFileSizeInBytes = targetFileSizeInBytes; | ||
| this.deleteFiles = Lists.newArrayList(); | ||
| this.referencedDataFiles = CharSequenceSet.empty(); | ||
| } | ||
|
|
||
| @Override | ||
| protected FileWriter<PositionDelete<T>, DeleteWriteResult> newWriter(PartitionSpec spec, StructLike partition) { | ||
| return new RollingPositionDeleteWriter<>(writerFactory, fileFactory, io, targetFileSizeInBytes, spec, partition); | ||
| } | ||
|
|
||
| @Override | ||
| protected void addResult(DeleteWriteResult result) { | ||
| deleteFiles.addAll(result.deleteFiles()); | ||
| referencedDataFiles.addAll(result.referencedDataFiles()); | ||
| } | ||
|
|
||
| @Override | ||
| protected DeleteWriteResult aggregatedResult() { | ||
| return new DeleteWriteResult(deleteFiles, referencedDataFiles); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we support rolling ORC writers? Other writers such as
ClusteredPositionDeleteWriterhave a check here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it does not fail right now as we disable ORC tests in
TestPartitioningWriters. We can enable them now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it seems that some of these tests can be re-enabled for ORC now, whereas previously they has an initial
Assumeto not run against ORC.As an example:
iceberg/data/src/test/java/org/apache/iceberg/io/TestPartitioningWriters.java
Line 161 in 31efe35
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think since
ORC: Add DeleteWriteBuilder for format v2 (#3250)went in, we don't need any special treatment for ORC format in the DeleteWriters. That means we could remove theAssume.assumeFalse()checks as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about enabling them in a separate PR?