mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-21 02:57:46 -05:00
go/store/nbs: Keep GetChunkLocations, make a new GetChunkLocationsWithPaths.
This commit is contained in:
@@ -319,19 +319,36 @@ func (gcs *GenerationalNBS) SupportedOperations() TableFileStoreOps {
|
||||
return gcs.newGen.SupportedOperations()
|
||||
}
|
||||
|
||||
func (gcs *GenerationalNBS) GetChunkLocations(hashes hash.HashSet) (map[string]map[hash.Hash]Range, error) {
|
||||
res, err := gcs.newGen.GetChunkLocations(hashes)
|
||||
func (gcs *GenerationalNBS) GetChunkLocationsWithPaths(hashes hash.HashSet) (map[string]map[hash.Hash]Range, error) {
|
||||
res, err := gcs.newGen.GetChunkLocationsWithPaths(hashes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(hashes) > 0 {
|
||||
prefix := gcs.RelativeOldGenPath()
|
||||
toadd, err := gcs.oldGen.GetChunkLocationsWithPaths(hashes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for k, v := range toadd {
|
||||
res[prefix + "/" + k] = v
|
||||
}
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (gcs *GenerationalNBS) GetChunkLocations(hashes hash.HashSet) (map[hash.Hash]map[hash.Hash]Range, error) {
|
||||
res, err := gcs.newGen.GetChunkLocations(hashes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(hashes) > 0 {
|
||||
toadd, err := gcs.oldGen.GetChunkLocations(hashes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for k, v := range toadd {
|
||||
res[filepath.ToSlash(filepath.Join(prefix, k))] = v
|
||||
res[k] = v
|
||||
}
|
||||
}
|
||||
return res, nil
|
||||
|
||||
+18
-6
@@ -116,10 +116,22 @@ type Range struct {
|
||||
Length uint32
|
||||
}
|
||||
|
||||
func (nbs *NomsBlockStore) GetChunkLocations(hashes hash.HashSet) (map[string]map[hash.Hash]Range, error) {
|
||||
func (nbs *NomsBlockStore) GetChunkLocationsWithPaths(hashes hash.HashSet) (map[string]map[hash.Hash]Range, error) {
|
||||
locs, err := nbs.GetChunkLocations(hashes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
toret := make(map[string]map[hash.Hash]Range, len(locs))
|
||||
for k, v := range locs {
|
||||
toret[k.String()] = v
|
||||
}
|
||||
return toret, nil
|
||||
}
|
||||
|
||||
func (nbs *NomsBlockStore) GetChunkLocations(hashes hash.HashSet) (map[hash.Hash]map[hash.Hash]Range, error) {
|
||||
gr := toGetRecords(hashes)
|
||||
|
||||
ranges := make(map[string]map[hash.Hash]Range)
|
||||
ranges := make(map[hash.Hash]map[hash.Hash]Range)
|
||||
f := func(css chunkSources) error {
|
||||
for _, cs := range css {
|
||||
switch tr := cs.(type) {
|
||||
@@ -129,7 +141,7 @@ func (nbs *NomsBlockStore) GetChunkLocations(hashes hash.HashSet) (map[string]ma
|
||||
return err
|
||||
}
|
||||
if len(offsetRecSlice) > 0 {
|
||||
y, ok := ranges[hash.Hash(tr.h).String()]
|
||||
y, ok := ranges[hash.Hash(tr.h)]
|
||||
|
||||
if !ok {
|
||||
y = make(map[hash.Hash]Range)
|
||||
@@ -146,10 +158,10 @@ func (nbs *NomsBlockStore) GetChunkLocations(hashes hash.HashSet) (map[string]ma
|
||||
gr = toGetRecords(hashes)
|
||||
}
|
||||
|
||||
ranges[hash.Hash(tr.h).String()] = y
|
||||
ranges[hash.Hash(tr.h)] = y
|
||||
}
|
||||
case *chunkSourceAdapter:
|
||||
y, ok := ranges[hash.Hash(tr.h).String()]
|
||||
y, ok := ranges[hash.Hash(tr.h)]
|
||||
|
||||
if !ok {
|
||||
y = make(map[hash.Hash]Range)
|
||||
@@ -174,7 +186,7 @@ func (nbs *NomsBlockStore) GetChunkLocations(hashes hash.HashSet) (map[string]ma
|
||||
}
|
||||
}
|
||||
|
||||
ranges[hash.Hash(tr.h).String()] = y
|
||||
ranges[hash.Hash(tr.h)] = y
|
||||
|
||||
for _, h := range foundHashes {
|
||||
delete(hashes, h)
|
||||
|
||||
@@ -34,7 +34,7 @@ type store interface {
|
||||
nbs.TableFileStore
|
||||
|
||||
Path() (string, bool)
|
||||
GetChunkLocations(hashes hash.HashSet) (map[string]map[hash.Hash]nbs.Range, error)
|
||||
GetChunkLocationsWithPaths(hashes hash.HashSet) (map[string]map[hash.Hash]nbs.Range, error)
|
||||
}
|
||||
|
||||
var _ store = &nbs.NomsBlockStore{}
|
||||
|
||||
@@ -125,7 +125,7 @@ func (rs *RemoteChunkStore) GetDownloadLocations(ctx context.Context, req *remot
|
||||
return nil, err
|
||||
}
|
||||
|
||||
locations, err := cs.GetChunkLocations(hashes)
|
||||
locations, err := cs.GetChunkLocationsWithPaths(hashes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -184,7 +184,7 @@ func (rs *RemoteChunkStore) StreamDownloadLocations(stream remotesapi.ChunkStore
|
||||
}
|
||||
|
||||
hashes, _ := remotestorage.ParseByteSlices(req.ChunkHashes)
|
||||
locations, err := cs.GetChunkLocations(hashes)
|
||||
locations, err := cs.GetChunkLocationsWithPaths(hashes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user