Skip to content

Conversation

@jackye1995
Copy link
Contributor

Add an option min-deletes-per-file to allow rewriting files with certain number of deletes. This does not remove the deletes. It is used to solve the situation that a file is already of optimized size and never included in for bin packing, but deletes are associated with it so the deletes cannot be expired.

@jackye1995
Copy link
Contributor Author

posDeleteWriter.delete(dataFile.path(), 1);
posDeleteWriter.close();
rowDelta.addDeletes(posDeleteWriter.toDeleteFile());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know there are some repeated code here for generating deletes. So far I am still not sure what is the correct boundary to create util methods. I am planning to refactor after I add more tests for the RewriteDeleteStrategy

* <p>
* Defaults to Integer.MAX_VALUE, which means this feature is not enabled by default.
*/
public static final String MIN_DELETES_PER_FILE = "min-deletes-per-file";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What value is recommended to the user? Or how does the user compute the proper value? I'm thinking maybe adding an option to count filegroup valid if any file of it contains deletes. Because you don't know how many records match the equality delete, for example, delete a set of records in an area/province.

Nit: This is disabled by default but it is always comparing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to just do this based on the number of files since the read penalty is directly related to the number of files and less so to the amount of actual rows deleted.

No strong feeling on the default since we already have the amount of delete files in the task information so I don't think the check is very expensive

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do we need to have specific settings for equality delete and position delete separately? Since the read penalties are different.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is equivalent to setting this value to 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the exact value to set depends on the user's tolerance of read performance, because more deletes means worse read performance and potentially getting out of memory, so users can tune this value based on their system requirements.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is equivalent to setting this value to 0?

Hm, that's it.

Copy link
Member

@RussellSpitzer RussellSpitzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me based on our discussions of how the Binpack and Sort algorithms should be modified.

Copy link
Contributor

@kbendick kbendick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good!

A question for my own understanding, but overall +1. Thanks @jackye1995.

import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
import org.assertj.core.util.Lists;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question / Nit: Is there a reason to use Lists from assertj instead of Lists from the relocated google commons library?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nice catch, should not use that. We need to add it to checkstyle.


@Test
public void testBinPackWithDeletes() throws Exception {
Table table = createTablePartitioned(4, 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Would it be worth while to add inline comments to explain these parameters (like createTablePartitioned(4 /* ??? */, 2 /* ??? */)? Right now, it's hard to tell immediately what these arguments are, but I'll leave the choice to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not needed, because you can see the meaning of the parameters in Intellij

Copy link
Collaborator

@chenjunjiedada chenjunjiedada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@jackye1995
Copy link
Contributor Author

@aokolnychyi any additional comments? Otherwise I think this is mostly ready to be merged

@jackye1995
Copy link
Contributor Author

Looks like there are a few approvals here. Given that @RussellSpitzer who implemented this part of the code approved, I will wait until EOD today, if there is no additional comments, I will merge this, thanks everyone.

@jackye1995 jackye1995 merged commit 5c8db54 into apache:master Nov 5, 2021
KnightChess pushed a commit to KnightChess/iceberg that referenced this pull request Nov 7, 2021
BinPackStrategy.MIN_INPUT_FILES, Integer.toString(5),
BinPackStrategy.MAX_FILE_SIZE_BYTES, Long.toString(550 * MB),
BinPackStrategy.MIN_FILE_SIZE_BYTES, Long.toString(490 * MB),
BinPackStrategy.MIN_DELETES_PER_FILE, Integer.toString(2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kbendick, can you check our checkstyle config? It looks like lines that have incorrect indentation are getting through.

@rdblue
Copy link
Contributor

rdblue commented Nov 7, 2021

@jackye1995, thanks for getting this done! Sorry I didn't have a chance to review it sooner.

My only comment is that I don't think that we are using "min" in a consistent way so the option names may be confusing. For file sizes, min and max are the min and max allowed file sizes. Anything that is larger than max or less than min gets rewritten. But min deletes per file is actually the minimum before taking action. In other words, it is the maximum allowed number of delete files.

I'd prefer making these consistent and using max-delete-files instead of min-deletes-per-file. That fixes the min/max issue and also is more clear that we are talking about delete files and not actual deletes in the files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants