-
Notifications
You must be signed in to change notification settings - Fork 882
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 segmented transaction get method #6484
Conversation
Signed-off-by: Jason Frame <[email protected]>
|
…ppen on a read operation Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Like the tests. I will leave for a storage expert to approve
} | ||
|
||
@Test | ||
void txGet_returnsUpdatedValueAfterPutPut() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the name 😁
@Override | ||
public Optional<byte[]> get(final SegmentIdentifier segmentId, final byte[] key) | ||
throws StorageException { | ||
checkState(active, "Cannot invoke get() on a completed transaction."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we invoke get on a completed transaction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a get maybe it is fine? I was just following the pattern that the other methods did which was not operations on a completed transaction. Hopefully, a storage expert will know the answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to throw in this case cause we want to avoid returning values we are uncertain if it's going to be committed or not. Think chances are minimal but there is a scenario where this could happen. @garyschulte what you reckon?
public Optional<byte[]> get(final SegmentIdentifier segmentIdentifier, final byte[] key) { | ||
return updatedValues | ||
.computeIfAbsent(segmentIdentifier, __ -> new HashMap<>()) | ||
.getOrDefault(Bytes.wrap(key), Optional.empty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking my understanding...if we are computing empty HashMap if absent, then can we ever actually return Optional.empty() here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we use this InMemory class for writing data to the database (i.e. persisting this state) or only for reading data and/or unit tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking my understanding...if we are computing empty HashMap if absent, then can we ever actually return Optional.empty() here?
We can return an Optional.empty() because this is used to create the Map holding values for a particular segment identifier. And if we try and get a value for a segment identifier that doesn't have any updates then we create the new map and return an Optional.empty()
Signed-off-by: Jason Frame <[email protected]>
No longer needed with current approach of not deleting self-destruct from code column |
PR description
Add segmented transaction get method. This is needed to fully implement the reference counting for code storage changes to move to hashing by code hash.
Fixed Issue(s)