mirror of
https://github.com/restic/restic.git
synced 2025-03-15 07:30:52 +00:00
index: Compact data structure for Index.EachByPack
This commit is contained in:
parent
137f0bc944
commit
0e8893dae9
@ -252,21 +252,18 @@ func (idx *Index) EachByPack(ctx context.Context, packBlacklist restic.IDSet) <-
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer idx.m.Unlock()
|
defer idx.m.Unlock()
|
||||||
defer func() {
|
defer close(ch)
|
||||||
close(ch)
|
|
||||||
}()
|
|
||||||
|
|
||||||
byPack := make(map[restic.ID][][]*indexEntry)
|
byPack := make(map[restic.ID][restic.NumBlobTypes][]*indexEntry)
|
||||||
|
|
||||||
for typ := range idx.byType {
|
for typ := range idx.byType {
|
||||||
m := &idx.byType[typ]
|
m := &idx.byType[typ]
|
||||||
m.foreach(func(e *indexEntry) bool {
|
m.foreach(func(e *indexEntry) bool {
|
||||||
packID := idx.packs[e.packIndex]
|
packID := idx.packs[e.packIndex]
|
||||||
if !idx.final || !packBlacklist.Has(packID) {
|
if !idx.final || !packBlacklist.Has(packID) {
|
||||||
if _, ok := byPack[packID]; !ok {
|
v := byPack[packID]
|
||||||
byPack[packID] = make([][]*indexEntry, restic.NumBlobTypes)
|
v[typ] = append(v[typ], e)
|
||||||
}
|
byPack[packID] = v
|
||||||
byPack[packID][typ] = append(byPack[packID][typ], e)
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
@ -281,7 +278,7 @@ func (idx *Index) EachByPack(ctx context.Context, packBlacklist restic.IDSet) <-
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// allow GC once entry is no longer necessary
|
// allow GC once entry is no longer necessary
|
||||||
byPack[packID] = nil
|
delete(byPack, packID)
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user