Skip to content

Conversation

@adoroszlai
Copy link
Contributor

What changes were proposed in this pull request?

Reduce copying of maps in OmKeyArgs:

  • inherit metadata map from WithMetadata and its builder
  • use MapBuilder for tags in OmKeyArgs.Builder

Since metadata is now immutable, change BlockOutputStreamEntryPool and BlockDataStreamOutputEntryPool to keep an OmKeyArgs.Builder instead of OmKeyArgs.

https://issues.apache.org/jira/browse/HDDS-14169

How was this patch tested?

CI:
https://github.com/adoroszlai/ozone/actions/runs/20959833882

@adoroszlai adoroszlai self-assigned this Jan 13, 2026
@adoroszlai
Copy link
Contributor Author

CC @Russole

@Russole
Copy link
Contributor

Russole commented Jan 13, 2026

@adoroszlai Thanks for the ping and for picking this up.
I was blocked by the unit test failures longer than expected and appreciate you stepping in to resolve it.

addAllMetadata(metadatamap);
if (Boolean.parseBoolean(metadata.get(OzoneConsts.GDPR_FLAG))) {
GDPRSymmetricKey.newDefaultInstance().acceptKeyDetails(metadata::put);
if (Boolean.parseBoolean(metadatamap.get(OzoneConsts.GDPR_FLAG))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a null check on metadatamap before using the getter? metadatamap might be null. Alternatively use the underlying map that's being added to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, added a null check.

Copy link
Contributor

@siddhantsangwan siddhantsangwan left a comment

Choose a reason for hiding this comment

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

Just trying to complete my understanding - how does this change reduce copying of maps?

@adoroszlai
Copy link
Contributor Author

Just trying to complete my understanding - how does this change reduce copying of maps?

When OmKeyArgs is converted toBuilder() for modification, its properties are all set on the Builder. Currently, metadata and tags are stored in new HashMap, so that changes made to the Builder do not affect the original OmKeyArgs. However, this copying of the maps happens even if metadata/tags are not changed, e.g. here:

public OmKeyArgs update(OmKeyArgs args) {
return isLink()
? args.toBuilder()
.setVolumeName(realVolume())
.setBucketName(realBucket())
.build()

MapBuilder stores the original immutable map, and creates mutable copy only if and when the map is being modified (new items added, etc.).

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.

3 participants