prefix each index block name with an inverse timestamp, that decreases over time an can be lexicographically sorted to produce newest blocks first when listing by prefix P

This commit is contained in:
Jarek Kowalski
2017-12-31 13:52:25 -08:00
parent 596c2b122a
commit 6dda6ca5e5

View File

@@ -7,6 +7,7 @@
"fmt"
"io"
"log"
"math"
"sort"
"strconv"
"strings"
@@ -280,7 +281,9 @@ func (bm *Manager) writePackIndexes(ndx packIndexes, replacesBlockBeforeTime *ti
suffix = fmt.Sprintf("%v%x", compactedBlockSuffix, replacesBlockBeforeTime.UnixNano())
}
return bm.writeUnpackedBlockNotLocked(buf.Bytes(), packBlockPrefix, suffix, true)
inverseTimePrefix := fmt.Sprintf("%016x", math.MaxInt64-time.Now().UnixNano())
return bm.writeUnpackedBlockNotLocked(buf.Bytes(), packBlockPrefix+inverseTimePrefix, suffix, true)
}
func (bm *Manager) finishAllOpenPacksLocked() error {