From 0754ba8771bb048898c60076b1a4a34a3ecaf68a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 6 Feb 2024 14:26:21 +0100 Subject: [PATCH] add spaceindex.AddAll() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/spaceindex-addall.md | 5 +++++ pkg/storage/utils/decomposedfs/spaceidindex/spaceidindex.go | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 changelog/unreleased/spaceindex-addall.md diff --git a/changelog/unreleased/spaceindex-addall.md b/changelog/unreleased/spaceindex-addall.md new file mode 100644 index 0000000000..2dccee3cc6 --- /dev/null +++ b/changelog/unreleased/spaceindex-addall.md @@ -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 diff --git a/pkg/storage/utils/decomposedfs/spaceidindex/spaceidindex.go b/pkg/storage/utils/decomposedfs/spaceidindex/spaceidindex.go index 4d9add3895..d9dc9c3597 100644 --- a/pkg/storage/utils/decomposedfs/spaceidindex/spaceidindex.go +++ b/pkg/storage/utils/decomposedfs/spaceidindex/spaceidindex.go @@ -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})