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

Unify SET_VERSIONSTAMPED_KEY and SET_VERSIONSTAMPED_VALUE API #242

Conversation

alecgrieser
Copy link
Contributor

This modifies both the SET_VERSIONSTAMP_KEY and SET_VERSIONSTAMPED_VALUE atomic mutations so that they do the same thing. In particular, they now both take four bytes of position at the end of the key/value and use that as an offset in which to place the versionstamp.

This uses the API version to allow older code to continue to use 2 bytes for keys and 0 bytes for values. The bindingtester is updated to write atomic mutations that are in the correct form, and the tuple packing methods will do the right thing, so old code that used those abstractions doesn't need to change (for keys). IMO, the most likely place for error is that I have updated some place to always use four bytes when it needs to look at the API version before deciding whether it should use the old format or the new format.

This modifies the API so is somewhat 🌶 by its nature. I am somewhat hesitant to submit it, but the alternative is either not letting the value set a position for its versionstamp, which is pretty annoying, or having the "key"-based API take two bytes while the "value"-based API takes four bytes. (It needs more than two bytes because the max value size is 100k, which astute observers will note requires more than 16 bits to represent, and four bytes is easier than three bytes to deal with.)

This addresses issue #148.

auto r = singleKeyRange( key, req.arena );
auto v = ValueRef( req.arena, operand );
auto r = singleKeyRange( key, req.arena );
auto v = ValueRef( req.arena, operand );
Copy link
Contributor

Choose a reason for hiding this comment

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

spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Curses! Foiled again!

} else if (m.type == MutationRef::SetVersionstampedValuePos ) {
transformSetVersionstampedValuePos( m, requests[0].version, transactionNumberInBatch );
} else if (m.type == MutationRef::SetVersionstampedValue) {
transformVersionstampMutation( m, &MutationRef::param2, requests[0].version, transactionNumberInBatch );
Copy link
Contributor

Choose a reason for hiding this comment

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

git clang-format might be easier to do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, our .clang-format is currently checked in only on the master branch. Does that need to be fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This particular alignment change I had fixed in a later commit, but it wouldn't surprise me if there are some other formatting things sitting elsewhere.

flow/Arena.h Outdated
Standalone<StringRef> withPrefix( const StringRef& prefix ) const {
Standalone<StringRef> r;
((StringRef &)r) = withPrefix(prefix, r.arena());
return r;
}

Standalone<StringRef> withSuffix( const StringRef& suffix ) const {
Standalone<StringRef> r;
((StringRef &)r) = withSuffix(suffix, r.arena());
Copy link
Contributor

Choose a reason for hiding this comment

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

r.contents() = is a less questionable way to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. I was following the same convention as withPrefix, so I went and changed both of them.

* @deprecated Since 5.2.0, replaced with {@link #packVersionstampedKey(Tuple) packVersionstampedKey()}
*/
@Deprecated
public byte[] packWithVersionstamp(Tuple tuple) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, and do these removals not need to be api versioned somehow? or are they already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making packWithVersionstamp deprecated was added within this PR when it looked like there would be different semantics for specifying the version offset with a key and with a value. This removal just gets us to status quo ante pull request.

@alecgrieser alecgrieser force-pushed the 32437306-better-versionstamped-value branch from 62df5ab to 8de914a Compare May 9, 2018 16:01
@alecgrieser
Copy link
Contributor Author

I believe Alex said somewhere that I should merge this after I addressed the comments, so that's what I'm going to do.

@alecgrieser alecgrieser merged commit f309364 into apple:release-5.2 May 9, 2018
sfc-gh-tclinkenbeard pushed a commit to sfc-gh-tclinkenbeard/foundationdb that referenced this pull request May 29, 2023
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.

2 participants