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
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions db/column_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

other.db_ = db_;
other.mutex_ = mutex_;
cfd_ = nullptr;
db_ = nullptr;
mutex_ = nullptr;
}

ColumnFamilyHandleImpl::~ColumnFamilyHandleImpl() {
if (cfd_ != nullptr) {
#ifndef ROCKSDB_LITE
Expand Down
1 change: 1 addition & 0 deletions db/column_family.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class ColumnFamilyHandleImpl : public ColumnFamilyHandle {
// create while holding the mutex
ColumnFamilyHandleImpl(
ColumnFamilyData* cfd, DBImpl* db, InstrumentedMutex* mutex);
ColumnFamilyHandleImpl(ColumnFamilyHandleImpl&& other);
// destroy without mutex
virtual ~ColumnFamilyHandleImpl();
virtual ColumnFamilyData* cfd() const { return cfd_; }
Expand Down
Loading