-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-14241. Implement Operations as objects in RDBBatchOperation #9555
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
base: master
Are you sure you want to change the base?
Conversation
e4b1a99 to
792fe8a
Compare
…by abstracting out implementation of each operation Change-Id: Idf5b9a4b9f66eae41a9d832ddbf22e43d1027344
Change-Id: I3a36aa7e4b421ec40c7a5dcb309c9a3a9e111e0a
Change-Id: I05e959b3a502156a783910ca24b679acc8025995
6a7927b to
7b762ae
Compare
|
@swamirishi , When this is ready, please click "Ready for review". |
|
@szetszwo this is good to be reviewed |
szetszwo
left a comment
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.
Some quick comments.
| private Op() { | ||
| } |
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.
Remove this empty constructor.
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.
@swamirishi , this is not yet addressed.
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.
This would be useful in the next PR. I have removed it and I will add it in the next PR.
| private static final String PUT_OP = "PUT"; | ||
| private static final String DELETE_OP = "DELETE"; |
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.
Use class name and remove string constants.
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.
done
| * existing entries when necessary. | ||
| */ | ||
| private final Map<Bytes, Object> ops = new HashMap<>(); | ||
| private final Map<Bytes, Op> batchOps = new HashMap<>(); |
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.
ops is better since the class is Op. batchOps should mean objects of RDBBatchOperation.
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.
done
Change-Id: I961641514c699d610719c1c0b2c6d7064ff4d0dd
Change-Id: I7f35eaa783ad38f296541448aa9ebddf80f456fe
| private final byte[] key; | ||
|
|
||
| private DeleteOp(byte[] key) { | ||
| super(); |
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.
Remove super() here and also the other subclasses.
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.
done
| /** | ||
| * Put operation to be applied to a {@link ColumnFamily} batch using the CodecBuffer api. | ||
| */ | ||
| private final class CodecBufferPutOp extends Op { |
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.
Let's call this PutOp since we are going to remove ByteArrayPutOp later on.
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 would rename this in the next patch
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.
Done renaming it
| final Object overwritten = ops.put(key, val); | ||
| } | ||
|
|
||
| void overWriteOpIfExist(Bytes key, Op operation) { |
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.
To be consistent with deleteIfExist, rename it to overwriteIfExist.
Also, rename operation to op to avoid long lines.
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.
done
Change-Id: I0aff2ee9911a56c4265c72819f75da268f325aaa
|
@szetszwo can you take another look. I have addressed all your review comments. |
What changes were proposed in this pull request?
Refactor RDBBatchOperation to support various Operations by abstracting out implementation of each operations.
The patch is going to create a separate Operations abstract class which is going to have 3 implementations PutByteArrayOperation, DeleteOperation, PutCodecBufferOperation each responsible for applying the operation into the rocksdb write batch.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-14241
How was this patch tested?
Just refactoring changes no additional tests required.