Huang Kuan Hao created HDDS-16216:
-------------------------------------

             Summary: Avoid the flatten-copy in 
KeyInputStream.getBlockLocationInfo
                 Key: HDDS-16216
                 URL: https://issues.apache.org/jira/browse/HDDS-16216
             Project: Apache Ozone
          Issue Type: Sub-task
            Reporter: Huang Kuan Hao
            Assignee: Huang Kuan Hao


getBlockLocationInfo allocates a flattened list on the per-block read / 
pipeline-refresh path just to find one block by ID:

List<OmKeyLocationInfo> collect =
    newKeyInfo.getLatestVersionLocations()
        .getLocationList()
        .stream()
        .filter(l -> l.getBlockID().equals(blockID))
        .collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
  return collect.get(0);
} else {
  return null;
}
Fix: iterate getLocationLists() and return on the first blockID match 
(short-circuits, no copy). Do not use getBlocksLatestVersionOnly() — the block 
may live in a non-latest createVersion bucket, so narrowing the search would 
change behavior. Behavior unchanged.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to