Skip to content

Commit

Permalink
resolved the comments and refined code, need unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxuan Wang <[email protected]>
  • Loading branch information
wangxiaoxuan273 committed Sep 25, 2023
1 parent 5bc32d2 commit 466ffd1
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 199 deletions.
2 changes: 1 addition & 1 deletion internal/container/set/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (s Set[T]) Contains(item T) bool {
return ok
}

// Delete deletes an item from the set
// Delete deletes an item from the set.
func (s Set[T]) Delete(item T) {
delete(s, item)
}
8 changes: 1 addition & 7 deletions internal/graph/deletablememory.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"oras.land/oras-go/v2/internal/syncutil"
)

// DeletableMemory is a DeletableMemory based PredecessorFinder.
// DeletableMemory is a memory based PredecessorFinder.
type DeletableMemory struct {
nodes map[descriptor.Descriptor]ocispec.Descriptor // nodes saves the map keys of ocispec.Descriptor
predecessors map[descriptor.Descriptor]set.Set[descriptor.Descriptor]
Expand All @@ -47,16 +47,12 @@ func NewDeletableMemory() *DeletableMemory {
}

// Index indexes predecessors for each direct successor of the given node.
// There is no data consistency issue as long as deletion is not implemented
// for the underlying storage.
func (m *DeletableMemory) Index(ctx context.Context, fetcher content.Fetcher, node ocispec.Descriptor) error {
_, err := m.index(ctx, fetcher, node)
return err
}

// Index indexes predecessors for all the successors of the given node.
// There is no data consistency issue as long as deletion is not implemented
// for the underlying storage.
func (m *DeletableMemory) IndexAll(ctx context.Context, fetcher content.Fetcher, node ocispec.Descriptor) error {
// track content status
tracker := status.NewTracker()
Expand Down Expand Up @@ -123,8 +119,6 @@ func (m *DeletableMemory) Remove(ctx context.Context, node ocispec.Descriptor) e
}

// index indexes predecessors for each direct successor of the given node.
// There is no data consistency issue as long as deletion is not implemented
// for the underlying storage.
func (m *DeletableMemory) index(ctx context.Context, fetcher content.Fetcher, node ocispec.Descriptor) ([]ocispec.Descriptor, error) {
successors, err := content.Successors(ctx, fetcher, node)
if err != nil {
Expand Down
Loading

0 comments on commit 466ffd1

Please sign in to comment.