Skip to content

HDDS-16215. Avoid the per-group list copy in OmMetadataManagerImpl.getBlocksForKeyDeletetBlocksForKeyDelete - #11089

Open
orca-07 wants to merge 2 commits into
apache:masterfrom
orca-07:HDDS-16215
Open

HDDS-16215. Avoid the per-group list copy in OmMetadataManagerImpl.getBlocksForKeyDeletetBlocksForKeyDelete#11089
orca-07 wants to merge 2 commits into
apache:masterfrom
orca-07:HDDS-16215

Conversation

@orca-07

@orca-07 orca-07 commented Aug 22, 2026

Copy link
Copy Markdown

What changes were proposed in this pull request?

getBlocksForKeyDelete flatten-copies each version group only to stream it once into DeletedBlock items:

      for (OmKeyLocationInfoGroup keyLocations :
          info.getKeyLocationVersions()) {
        List<DeletedBlock> item = keyLocations.createLocationList().stream()
            .map(b -> new DeletedBlock(
                new BlockID(b.getContainerID(), b.getLocalID()),
                b.getLength(),
                QuotaUtil.getReplicatedSize(b.getLength(), info.getReplicationConfig()),
                QuotaUtil.getSizePerReplica(b.getLength(), info.getReplicationConfig())))
            .collect(Collectors.toList());
        BlockGroup keyBlocks = BlockGroup.newBuilder()
            .setKeyName(deletedKey)
            .addAllDeletedBlocks(item)
            .build();
        result.add(keyBlocks);
      }

Fix: keyLocations.getLocationLists().stream().flatMap(List::stream). Behavior unchanged.

What is the link to the Apache JIRA

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

How was this patch tested?

https://github.com/orca-07/ozone/actions/runs/32567086538

@F64116045 F64116045 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks @orca-07 for the patch.

@chungen0126 chungen0126 changed the title HDDS-16215. Avoid the per-group list copy in OmMetadataManagerImpl.getBlocksForKeyDelete HDDS-16215. Avoid the per-group list copy in OmMetadataManagerImpl.getBlocksForKeyDeletetBlocksForKeyDelete Aug 22, 2026
@chungen0126

Copy link
Copy Markdown
Contributor

Thanks @orca-07 for working on this. It would be better to have a micro benchmark.

# Conflicts:
#	hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java
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