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

Tsz Wo Nicholas Sze commented on HDFS-13171:
--------------------------------------------

- Question: What if nodePath[level] == head?  The code does nothing.  Would the 
remove(..) work for removing the first node?
{code}
      if (nodePath[level] != head) {
        ...
      }
      if (nodeLevel == headLevel) {
        while (headLevel > 0 && head.getSkipNode(headLevel) == null) {
          headLevel--;
        }
        head.skipDiffList = head.skipDiffList.subList(0, headLevel + 1);
      }
{code}
It seems that the remove code never update head.  If it is true, there is some 
bugs.

- remove(..) and addLast(..) both need to find the previous nodes.  Let's add a 
findPreviousNodes method as below
{code}
  SkipListNode[] findPreviousNodes(SkipListNode node, int nodeLevel) {
    final SkipListNode[] nodePath = new SkipListNode[nodeLevel + 1];
    SkipListNode cur = head;
    final int headLevel = head.level();
    for (int level = headLevel < nodeLevel ? headLevel : nodeLevel;
         level >= 0; level--) {
      while (cur.getSkipNode(level) != node) {
        cur = cur.getSkipNode(level);
      }
      nodePath[level] = cur;
    }
    for (int level = headLevel + 1; level <= nodeLevel; level++) {
      nodePath[level] = head;
    }
    return nodePath;
  }
{code}


> Handle Deletion of nodes in SnasphotSkipList
> --------------------------------------------
>
>                 Key: HDFS-13171
>                 URL: https://issues.apache.org/jira/browse/HDFS-13171
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: snapshots
>            Reporter: Shashikant Banerjee
>            Assignee: Shashikant Banerjee
>            Priority: Major
>         Attachments: HDFS-13171.000.patch
>
>
> This Jira will handle deletion of skipListNodes from DirectoryDiffList . If a 
> node has multiple levels, the list needs to be balanced .If the node is uni 
> level, no balancing of the list is required.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to