Skip to content

Commit

Permalink
Merge pull request #4502 from butonic/addall
Browse files Browse the repository at this point in the history
add spaceindex.AddAll()
  • Loading branch information
butonic authored Feb 6, 2024
2 parents bf89f7a + 0754ba8 commit 1a380e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/spaceindex-addall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: add spaceindex.AddAll()

We now expose an AddAll() function that allows adding multiple entries to a space index with a single lock.

https://github.com/cs3org/reva/pull/4502
6 changes: 6 additions & 0 deletions pkg/storage/utils/decomposedfs/spaceidindex/spaceidindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ func (i *Index) Load(index string) (map[string]string, error) {
}

// Add adds an entry to an index
// Consider calling AddAll() when trying to add multiple entries as every Add call has to lock the index
func (i *Index) Add(index, key string, value string) error {
return i.updateIndex(index, map[string]string{key: value}, []string{})
}

// AddAll adds multiple entries to the index
func (i *Index) AddAll(index string, m map[string]string) error {
return i.updateIndex(index, m, []string{})
}

// Remove removes an entry from the index
func (i *Index) Remove(index, key string) error {
return i.updateIndex(index, map[string]string{}, []string{key})
Expand Down

0 comments on commit 1a380e0

Please sign in to comment.