Skip to content
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

Add copy constructor to ColumnFamilyHandleImpl #353

Merged
merged 8 commits into from
Jan 3, 2024

Conversation

v01dstar
Copy link

@v01dstar v01dstar commented Dec 28, 2023

Ref tikv/titan#294

This is needed by tikv/titan#298.
In that PR, we need to create Titan's own ColumnFamiliyHandle instances. To avoid memory leak, we need to delete ColumnFamilyHandleImpl instances created by RocksDB itself.

@@ -50,6 +50,14 @@ ColumnFamilyHandleImpl::ColumnFamilyHandleImpl(
}
}

ColumnFamilyHandleImpl::ColumnFamilyHandleImpl(
const ColumnFamilyHandleImpl& other)
Copy link
Member

Choose a reason for hiding this comment

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

can we just move the other?

Signed-off-by: Yang Zhang <[email protected]>
@@ -50,6 +50,15 @@ ColumnFamilyHandleImpl::ColumnFamilyHandleImpl(
}
}

ColumnFamilyHandleImpl::ColumnFamilyHandleImpl(ColumnFamilyHandleImpl&& other) {
other.cfd_ = cfd_;
Copy link

@tonyxuqqi tonyxuqqi Jan 3, 2024

Choose a reason for hiding this comment

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

so that means the new ColumnFamilyHandleImpl instance will not have the valid information, but the other will be overwritten by the default values of ColumnFamilyHandleImpl?

I would imagine other will be empty and it's moved to this instance.

Copy link
Author

Choose a reason for hiding this comment

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

You are right, I didn't pay attention to copilot generated code.

Signed-off-by: Yang Zhang <[email protected]>
@v01dstar v01dstar changed the title Add copy constructor to ColumnFamilyHandleImpl Add move constructor to ColumnFamilyHandleImpl Jan 3, 2024
Copy link
Member

@Connor1996 Connor1996 left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Yang Zhang <[email protected]>
@v01dstar v01dstar changed the title Add move constructor to ColumnFamilyHandleImpl Add copy constructor to ColumnFamilyHandleImpl Jan 3, 2024
Signed-off-by: Yang Zhang <[email protected]>
@Connor1996 Connor1996 merged commit dcf2f8d into tikv:6.29.tikv Jan 3, 2024
3 checks passed
@v01dstar v01dstar deleted the cf-copy-constructor branch October 9, 2024 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants