hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jing Zhao (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-7829) Code clean up for LocatedBlock
Date Tue, 10 Mar 2015 21:48:40 GMT

    [ https://issues.apache.org/jira/browse/HDFS-7829?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14355787#comment-14355787
] 

Jing Zhao commented on HDFS-7829:
---------------------------------

Thanks for updating the patch, Takanobu.

So my main concern about the current patch is that to support the subclass we need to bring
in extra complexity when using the Builder pattern. Also LocatedBlock is not immutable. Maybe
we can avoid this complexity by not using the Builder pattern but simply removing some unnecessary
constructors? Looking into the code, seems that we have chance to remove the following constructors:
# {{LocatedBlock(ExtendedBlock, DatanodeInfo[], long, boolean)}}
This constructor is called in 4 places, and 3 of them pass -1 and false for the last two arguments.
{{LocatedBlocks#findBlock}} can also call {{LocatedBlock(ExtendedBlock, DatanodeInfo[]}} instead
since it sets the offset immediately after creating the object.
# {{LocatedBlock(ExtendedBlock, DatanodeStorageInfo[])}}
This constructor is only used once and we can simply use {{LocatedBlock(ExtendedBlock, DatanodeStorageInfo[],
long, boolean}} to replace it
# {{LocatedBlock(ExtendedBlock b, DatanodeInfo[], String[], StorageType[])}}
This one is also only called by 1 or 2 places and can be replaced by {{LocatedBlock(ExtendedBlock,
DatanodeStorageInfo[], long, boolean}}

In this way we can remove 3 constructors without bringing extra complexity. Thoughts?

> Code clean up for LocatedBlock
> ------------------------------
>
>                 Key: HDFS-7829
>                 URL: https://issues.apache.org/jira/browse/HDFS-7829
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>            Reporter: Jing Zhao
>            Assignee: Takanobu Asanuma
>            Priority: Minor
>         Attachments: HDFS-7829.1.patch, HDFS-7829.2.patch, HDFS-7829.3.patch
>
>
> We can do some code cleanup for {{LocatedBlock}}, including:
> # Using a simple Builder pattern to avoid multiple constructors
> # Setting data fields like {{corrupt}} and {{offset}} to final



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message