File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ var cli struct {
7171
7272 Merge struct {
7373 Archives []string `arg:"" name:"inputs_then_output" help:"One or more input archives, followed by the output name last."`
74- } `cmd:"" help:"Merge multiple archives into a single archive" hidden:"" `
74+ } `cmd:"" help:"Merge multiple archives into a single archive"`
7575
7676 Convert struct {
7777 Input string `arg:"" help:"Input archive" type:"existingfile"`
Original file line number Diff line number Diff line change @@ -97,11 +97,16 @@ func Merge(logger *log.Logger, inputs []string) error {
9797 acc := uint64 (0 )
9898 addressedTiles := uint64 (0 )
9999 tileContents := roaring64 .New ()
100+ maxOffsets := make ([]uint64 , len (headers ))
100101 for idx := range mergedEntries {
101- // TODO: this algo is broken with any deduplication of tiles
102- // need to bookkeep on the max seen offset in each input archive
103102 mergedEntries [idx ].Entry .Offset = acc
104- acc += uint64 (mergedEntries [idx ].Entry .Length )
103+
104+ // skip any deduplication (backreferences)
105+ if mergedEntries [idx ].InputOffset >= maxOffsets [mergedEntries [idx ].InputIdx ] {
106+ acc += uint64 (mergedEntries [idx ].Entry .Length )
107+ maxOffsets [mergedEntries [idx ].InputIdx ] = mergedEntries [idx ].InputOffset
108+ }
109+
105110 addressedTiles += uint64 (mergedEntries [idx ].Entry .RunLength )
106111 tileContents .Add (mergedEntries [idx ].Entry .Offset )
107112 }
You can’t perform that action at this time.
0 commit comments