github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/pkg/graveler/sstable/collectors.go (about) 1 package sstable 2 3 import ( 4 "github.com/cockroachdb/pebble/sstable" 5 ) 6 7 // staticCollector is a sstable.TablePropertyCollector that adds a map's values to the user 8 // property map. 9 type staticCollector struct { 10 m map[string]string 11 } 12 13 func (*staticCollector) Add(_ sstable.InternalKey, _ []byte) error { 14 return nil 15 } 16 17 func (*staticCollector) Name() string { 18 return "static" 19 } 20 21 func (s *staticCollector) Finish(userProps map[string]string) error { 22 for k, v := range s.m { 23 userProps[k] = v 24 } 25 return nil 26 } 27 28 // NewStaticCollector returns an SSTable collector that will add the properties in m when 29 // writing ends. 30 func NewStaticCollector(m map[string]string) func() sstable.TablePropertyCollector { 31 return func() sstable.TablePropertyCollector { return &staticCollector{m} } 32 }