Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor block adapter walker #8575

Merged
merged 5 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/block/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ type Adapter interface {
}

type WalkerOptions struct {
StorageURI *url.URL
StorageURI *url.URL
// SkipOutOfOrder - used when iterating on ADLS Gen 2
N-o-Z marked this conversation as resolved.
Show resolved Hide resolved
SkipOutOfOrder bool
guy-har marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/block/blocktest/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,11 @@ func dumpPathTree(t testing.TB, ctx context.Context, adapter block.Adapter, qk b
uri, err := url.Parse(p)
require.NoError(t, err, "URL Parse Error")

walker, err := block.NewWalkerWrapperFromAdapter(adapter, "", p, block.WalkerOptions{StorageURI: uri})
walker, err := adapter.GetWalker("", block.WalkerOptions{StorageURI: uri})
require.NoError(t, err, "GetWalker failed")

err = walker.Walk(ctx, block.WalkOptions{}, func(e block.ObjectStoreEntry) error {
wwalker := block.NewWalkerWrapper(walker, uri)
err = wwalker.Walk(ctx, block.WalkOptions{}, func(e block.ObjectStoreEntry) error {
_, p, _ := strings.Cut(e.Address, uri.String())
tree = append(tree, p)
return nil
Expand Down
16 changes: 9 additions & 7 deletions pkg/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ func New(ctx context.Context, cfg Config) (*Catalog, error) {
workPool := pond.New(sharedWorkers, sharedWorkers*pendingTasksPerWorker, pond.Context(ctx))

return &Catalog{
Config: cfg.Config,
BlockAdapter: tierFSParams.Adapter,
Store: gStore,
UGCPrepareMaxFileSize: baseCfg.UGC.PrepareMaxFileSize,
Expand Down Expand Up @@ -2326,15 +2325,17 @@ func (c *Catalog) importAsync(ctx context.Context, repository *graveler.Reposito
if err != nil {
return fmt.Errorf("could not parse storage URI %s: %w", uri, err)
}
walker, err := block.NewWalkerWrapperFromAdapter(c.BlockAdapter, repository.StorageID.String(), source.Path, block.WalkerOptions{StorageURI: uri})

walker, err := c.BlockAdapter.GetWalker(repository.StorageID.String(), block.WalkerOptions{StorageURI: uri})
if err != nil {
return err
return fmt.Errorf("creating object-store walker on path %s: %w", source.Path, err)
}

it, err := NewWalkEntryIterator(wgCtx, walker, source.Type, source.Destination, "", "")
it, err := NewWalkEntryIterator(wgCtx, block.NewWalkerWrapper(walker, uri), source.Type, source.Destination, "", "")
if err != nil {
return fmt.Errorf("creating walk iterator on path %s: %w", source.Path, err)
}

logger.WithFields(logging.Fields{"source": source.Path, "itr": it}).Debug("Ingest source")
defer it.Close()
return importManager.Ingest(it)
Expand Down Expand Up @@ -2503,12 +2504,13 @@ func (c *Catalog) WriteRange(ctx context.Context, repositoryID string, params Wr
if err != nil {
return nil, nil, fmt.Errorf("could not parse storage URI %s: %w", uri, err)
}
walker, err := block.NewWalkerWrapperFromAdapter(c.BlockAdapter, repository.StorageID.String(), params.SourceURI, block.WalkerOptions{StorageURI: uri, SkipOutOfOrder: true})

walker, err := c.BlockAdapter.GetWalker(repository.StorageID.String(), block.WalkerOptions{StorageURI: uri})
if err != nil {
return nil, nil, err
return nil, nil, fmt.Errorf("creating object-store walker on path %s: %w", params.SourceURI, err)
}

it, err := NewWalkEntryIterator(ctx, walker, ImportPathTypePrefix, params.Prepend, params.After, params.ContinuationToken)
it, err := NewWalkEntryIterator(ctx, block.NewWalkerWrapper(walker, uri), ImportPathTypePrefix, params.Prepend, params.After, params.ContinuationToken)
if err != nil {
return nil, nil, fmt.Errorf("creating walk iterator: %w", err)
}
Expand Down
Loading