use both hot and cold when doing fetches for markset positive objects

This commit is contained in:
vyzo 2022-01-30 22:47:20 +02:00
parent 7b8447a95a
commit a9d4495d83
2 changed files with 27 additions and 3 deletions

View File

@ -280,7 +280,7 @@ func (s *SplitStore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error)
}
if has {
return s.hot.Get(ctx, cid)
return s.get(cid)
}
return s.cold.Get(ctx, cid)
@ -331,7 +331,7 @@ func (s *SplitStore) GetSize(ctx context.Context, cid cid.Cid) (int, error) {
}
if has {
return s.hot.GetSize(ctx, cid)
return s.getSize(cid)
}
return s.cold.GetSize(ctx, cid)
@ -500,7 +500,7 @@ func (s *SplitStore) View(ctx context.Context, cid cid.Cid, cb func([]byte) erro
}
if has {
return s.hot.View(ctx, cid, cb)
return s.view(cid, cb)
}
return s.cold.View(ctx, cid, cb)

View File

@ -948,6 +948,30 @@ func (s *SplitStore) has(c cid.Cid) (bool, error) {
return s.cold.Has(s.ctx, c)
}
func (s *SplitStore) get(c cid.Cid) (blocks.Block, error) {
blk, err := s.hot.Get(s.ctx, c)
switch err {
case nil:
return blk, nil
case bstore.ErrNotFound:
return s.cold.Get(s.ctx, c)
default:
return nil, err
}
}
func (s *SplitStore) getSize(c cid.Cid) (int, error) {
sz, err := s.hot.GetSize(s.ctx, c)
switch err {
case nil:
return sz, nil
case bstore.ErrNotFound:
return s.cold.GetSize(s.ctx, c)
default:
return 0, err
}
}
func (s *SplitStore) moveColdBlocks(coldr *ColdSetReader) error {
batch := make([]blocks.Block, 0, batchSize)