Skip to content

Conversation

@shidayang
Copy link
Contributor

Like #5195 PositionIndex also can be cache

@shidayang
Copy link
Contributor Author

@rdblue cc

@github-actions github-actions bot added the data label Jul 13, 2022
if (deleteRowPositions == null) {
deleteRowPositions = Deletes.toPositionIndex(filePath, deletes);
}
Predicate<T> isDeleted = record -> deleteRowPositions.isDeleted(pos(record));
Copy link
Contributor

Choose a reason for hiding this comment

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

If deleteRowPositions is null, is this predicate at risk of an NPE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No NPE. The return of " Deletes.toPositionIndex(filePath, deletes)" must not be null.

if (posDeletes.stream().mapToLong(DeleteFile::recordCount).sum() < setFilterThreshold) {
PositionDeleteIndex positionIndex = Deletes.toPositionIndex(filePath, deletes);
Predicate<T> isDeleted = record -> positionIndex.isDeleted(pos(record));
if (deleteRowPositions == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this should run line 225 to open the deletes if they can be reused.

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 get you

List<CloseableIterable<Record>> deletes = Lists.transform(posDeletes, this::openPosDeletes);

// if there are fewer deletes than a reasonable number to keep in memory, use a set
if (posDeletes.stream().mapToLong(DeleteFile::recordCount).sum() < setFilterThreshold) {

Choose a reason for hiding this comment

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

What about the else case? In that case we will not cache.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it won't cache because the deletes are streamed from files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, Because it use sort merge to avoid loading too many delete rows in memory.

Copy link
Contributor Author

@shidayang shidayang Jul 14, 2022

Choose a reason for hiding this comment

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

But, They should't reopen position delete file and read position delete file from head, they should read position delete file continue。I will do some change here

@shidayang shidayang requested review from kbendick and rdblue July 14, 2022 01:25
@github-actions github-actions bot added the core label Jul 14, 2022
@shidayang
Copy link
Contributor Author

shidayang commented Jul 14, 2022

I add some code to reuse Merge Sort, I don't know whether it is suitable

@shidayang shidayang closed this Nov 23, 2023
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.

4 participants