[ https://issues.apache.org/jira/browse/HDFS-7056?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14334515#comment-14334515 ]
Konstantin Shvachko commented on HDFS-7056: ------------------------------------------- Sounds right, Jing. Let me write it down to make sure my math is right this time. {{binarySearch(diffs, snapshotId)}} returns {{i == -insertPoint-1}}, where {{insertPoint}} is the index of the first element greater than the key. So if the {{snapshotId}} is not found then we can start searching backwards from {{insertPoint-1 == -i-2}}. So we've been checking two extra elements. Good catch, thanks. Will create a jira to fix this. > Snapshot support for truncate > ----------------------------- > > Key: HDFS-7056 > URL: https://issues.apache.org/jira/browse/HDFS-7056 > Project: Hadoop HDFS > Issue Type: Sub-task > Components: namenode > Affects Versions: 3.0.0 > Reporter: Konstantin Shvachko > Assignee: Plamen Jeliazkov > Fix For: 2.7.0 > > Attachments: HDFS-3107-HDFS-7056-combined-13.patch, > HDFS-3107-HDFS-7056-combined-15.patch, HDFS-3107-HDFS-7056-combined.patch, > HDFS-3107-HDFS-7056-combined.patch, HDFS-3107-HDFS-7056-combined.patch, > HDFS-3107-HDFS-7056-combined.patch, HDFS-3107-HDFS-7056-combined.patch, > HDFS-3107-HDFS-7056-combined.patch, HDFS-3107-HDFS-7056-combined.patch, > HDFS-3107-HDFS-7056-combined.patch, HDFS-3107-HDFS-7056-combined.patch, > HDFS-7056-13.patch, HDFS-7056-15.patch, HDFS-7056.15_branch2.patch, > HDFS-7056.patch, HDFS-7056.patch, HDFS-7056.patch, HDFS-7056.patch, > HDFS-7056.patch, HDFS-7056.patch, HDFS-7056.patch, HDFS-7056.patch, > HDFSSnapshotWithTruncateDesign.docx, HDFSSnapshotWithTruncateDesign.docx, > editsStored, editsStored.xml > > > Implementation of truncate in HDFS-3107 does not allow truncating files which > are in a snapshot. It is desirable to be able to truncate and still keep the > old file state of the file in the snapshot. -- This message was sent by Atlassian JIRA (v6.3.4#6332)