HDFS-13693. Remove unnecessary search in INodeDirectory.addChild during image loading. Contributed by Lisheng Sun.
(cherry picked from commit 377f95bbe8
)
This commit is contained in:
parent
732a68cfb4
commit
702572434c
|
@ -269,7 +269,7 @@ public final class FSImageFormatPBINode {
|
||||||
+ "name before upgrading to this release.");
|
+ "name before upgrading to this release.");
|
||||||
}
|
}
|
||||||
// NOTE: This does not update space counts for parents
|
// NOTE: This does not update space counts for parents
|
||||||
if (!parent.addChild(child)) {
|
if (!parent.addChildAtLoading(child)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dir.cacheName(child);
|
dir.cacheName(child);
|
||||||
|
@ -551,6 +551,8 @@ public final class FSImageFormatPBINode {
|
||||||
++numImageErrors;
|
++numImageErrors;
|
||||||
}
|
}
|
||||||
if (!inode.isReference()) {
|
if (!inode.isReference()) {
|
||||||
|
// Serialization must ensure that children are in order, related
|
||||||
|
// to HDFS-13693
|
||||||
b.addChildren(inode.getId());
|
b.addChildren(inode.getId());
|
||||||
} else {
|
} else {
|
||||||
refList.add(inode.asReference());
|
refList.add(inode.asReference());
|
||||||
|
|
|
@ -572,6 +572,22 @@ public class INodeDirectory extends INodeWithAdditionalFields
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* During image loading, the search is unnecessary since the insert position
|
||||||
|
* should always be at the end of the map given the sequence they are
|
||||||
|
* serialized on disk.
|
||||||
|
*/
|
||||||
|
public boolean addChildAtLoading(INode node) {
|
||||||
|
int pos;
|
||||||
|
if (!node.isReference()) {
|
||||||
|
pos = (children == null) ? (-1) : (-children.size() - 1);
|
||||||
|
addChild(node, pos);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return addChild(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the node to the children list at the given insertion point.
|
* Add the node to the children list at the given insertion point.
|
||||||
* The basic add method which actually calls children.add(..).
|
* The basic add method which actually calls children.add(..).
|
||||||
|
|
Loading…
Reference in New Issue