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

Fix Snapshot to handle deleteSet properly when a delete operation is mixed with other operations. #138

Merged
merged 1 commit into from
Jan 21, 2021

Conversation

feeblefakie
Copy link
Contributor

@feeblefakie feeblefakie commented Jan 19, 2021

@feeblefakie feeblefakie changed the title Fix Snapshot to handle deleteSet properly when a delete operation is mixed with other operations. [Bug fixes] Fix Snapshot to handle deleteSet properly when a delete operation is mixed with other operations. Jan 19, 2021
@feeblefakie feeblefakie changed the title [Bug fixes] Fix Snapshot to handle deleteSet properly when a delete operation is mixed with other operations. Fix Snapshot to handle deleteSet properly when a delete operation is mixed with other operations. Jan 20, 2021
Copy link
Member

@yito88 yito88 left a comment

Choose a reason for hiding this comment

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

LGTM!

}

public Optional<TransactionResult> get(Snapshot.Key key) {
if (writeSet.containsKey(key)) {
throw new CrudRuntimeException("reading already written data is not allowed");
} else if (deleteSet.containsKey(key)) {
return Optional.empty();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why we allow reading already deleted data while we don't allow reading already written data?

Copy link
Contributor Author

@feeblefakie feeblefakie Jan 21, 2021

Choose a reason for hiding this comment

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

Thank you for the question!
This is because we can return empty for the already deleted records.
The reason why we throw an exception for reading already written data is we can't create Result from Put since Put might not have a full set of values.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah okay. I understood. Thank you for the clear explanation! I'll approve this.

}

public Optional<TransactionResult> get(Snapshot.Key key) {
if (writeSet.containsKey(key)) {
throw new CrudRuntimeException("reading already written data is not allowed");
} else if (deleteSet.containsKey(key)) {
return Optional.empty();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah okay. I understood. Thank you for the clear explanation! I'll approve this.

@feeblefakie
Copy link
Contributor Author

@Yonezawa-T2 I'm mering it but PTAL when you get a chance since I might miss something.

@feeblefakie feeblefakie merged commit 62c56a1 into master Jan 21, 2021
@feeblefakie feeblefakie deleted the handle-delete-set-properly branch January 21, 2021 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants