Skip to content

Conversation

@swamirishi
Copy link
Contributor

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.

@swamirishi swamirishi requested a review from szetszwo December 24, 2025 21:17
@swamirishi swamirishi changed the title HDDS-14241. Refactor RDBBatchOperation to support various Operations by abstracting out implementation of each operatio HDDS-14241. Refactor RDBBatchOperation to support various Operations by abstracting out implementation of each operation Dec 25, 2025
@swamirishi swamirishi force-pushed the HDDS-14241 branch 2 times, most recently from e4b1a99 to 792fe8a Compare December 25, 2025 05:46
@adoroszlai adoroszlai changed the title HDDS-14241. Refactor RDBBatchOperation to support various Operations by abstracting out implementation of each operation HDDS-14241. Implement Operations as objects in RDBBatchOperation Dec 25, 2025
…by abstracting out implementation of each operation

Change-Id: Idf5b9a4b9f66eae41a9d832ddbf22e43d1027344
Change-Id: I3a36aa7e4b421ec40c7a5dcb309c9a3a9e111e0a
Change-Id: I05e959b3a502156a783910ca24b679acc8025995
@szetszwo
Copy link
Contributor

@swamirishi , When this is ready, please click "Ready for review".

@swamirishi swamirishi marked this pull request as ready for review December 27, 2025 19:22
@swamirishi
Copy link
Contributor Author

@szetszwo this is good to be reviewed

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

Some quick comments.

Comment on lines 140 to 141
private Op() {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this empty constructor.

Copy link
Contributor

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.

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 would be useful in the next PR. I have removed it and I will add it in the next PR.

Comment on lines 48 to 49
private static final String PUT_OP = "PUT";
private static final String DELETE_OP = "DELETE";
Copy link
Contributor

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.

Copy link
Contributor Author

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<>();
Copy link
Contributor

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.

Copy link
Contributor Author

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();
Copy link
Contributor

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.

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Change-Id: I0aff2ee9911a56c4265c72819f75da268f325aaa
@swamirishi
Copy link
Contributor Author

@szetszwo can you take another look. I have addressed all your review comments.

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

+1 the change looks good.

Please fix the typo before merging this.

final Object overwritten = ops.put(key, val);
}

void overWriteIfExist(Bytes key, Op op) {
Copy link
Contributor

Choose a reason for hiding this comment

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

English: "over write" or "overwrite"? Please don't create your own words/language. For example, see https://man7.org/linux/man-pages/man1/cp.1.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can I do it in the PR? Don't want to waste another CI run

Change-Id: I152be40a8376823f501df6594621512368b0e7cc
@swamirishi swamirishi merged commit 563b9d5 into apache:master Dec 28, 2025
43 checks passed
@swamirishi
Copy link
Contributor Author

thank you @szetszwo for reviewing the patch

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