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 GetAllKeyVersions API #2232

Closed
wants to merge 4 commits into from
Closed

Add GetAllKeyVersions API #2232

wants to merge 4 commits into from

Conversation

ajkr
Copy link
Contributor

@ajkr ajkr commented Apr 29, 2017

  • Introduced an include/ file dedicated to db-related debug functions to avoid making db.h more complex
  • Added debugging function, GetAllKeyVersions(), to return a listing of internal data for a range of user keys. The new struct KeyVersion exposes data similar to internal key without exposing any internal type.
  • Migrated the "ldb idump" subcommand to use this function
  • The API takes an inclusive-inclusive range. "ldb idump" traditionally uses inclusive-exclusive, so I filter out any key versions having the range's end user key.

@facebook-github-bot
Copy link
Contributor

@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@ajkr updated the pull request - view changes - changes since last import

@IslamAbdelRahman
Copy link
Contributor

LGTM, let's also add a simple test

break;
}

key_versions->emplace_back();
Copy link
Contributor

Choose a reason for hiding this comment

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

this is okay but looks a bit strange to me, maybe we can add the constructor and use it in the emplace_back

but it's up to you

@facebook-github-bot
Copy link
Contributor

@ajkr updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ajkr
Copy link
Contributor Author

ajkr commented May 11, 2017

ping, i want to include this in 5.5 so our customer can start using it

Copy link
Contributor

@siying siying left a comment

Choose a reason for hiding this comment

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

Forgot to send out comments...

SequenceNumber sequence;
// TODO(ajkr): we should provide a helper function that converts the int to a
// string describing the type for easier debugging.
int type;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just get a enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the authoritative enum is in db/dbformat.h and I didn't want to duplicate it. What do you suggest - duplicate it anyways since it'll almost never change?

assert(key_versions != nullptr);
key_versions->clear();

DBImpl* idb = dynamic_cast<DBImpl*>(db->GetRootDB());
Copy link
Contributor

Choose a reason for hiding this comment

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

Either check whether idb is empty after dynamic casting or just do static cast. I'm voting for simply do static casting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

};

// Returns listing of all versions of keys in the provided user key range.
// The range is inclusive-exclusive, i.e., [`begin_key`, `end_key`).
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should do inclusive end_key. Otherwise if they pass in the same key for begin and end key (and intuitive way if they assume this can return them versions for one specific key), the semantic is confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the reason for inclusive-exclusive was for compatibility with "ldb idump", which is exclusive of the end key. I can make the function return results for the inclusive-inclusive interval, and then filter out the end key in "ldb idump" to maintain compatibility.

@facebook-github-bot
Copy link
Contributor

@ajkr updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

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.

None yet

4 participants