mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-06 19:07:50 +00:00
convert to RWMutex in index, holder, view, and frame
use RLock and RUnlock in mapperLocal hotpath
This commit is contained in:
parent
b11b8b074d
commit
ce7283ae1b
4 changed files with 14 additions and 14 deletions
10
frame.go
10
frame.go
|
|
@ -43,7 +43,7 @@ const (
|
|||
|
||||
// Frame represents a container for views.
|
||||
type Frame struct {
|
||||
mu sync.Mutex
|
||||
mu sync.RWMutex
|
||||
path string
|
||||
index string
|
||||
name string
|
||||
|
|
@ -404,8 +404,8 @@ func (f *Frame) Close() error {
|
|||
|
||||
// Schema returns the frame's current schema.
|
||||
func (f *Frame) Schema() *FrameSchema {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
f.mu.RLock()
|
||||
defer f.mu.RUnlock()
|
||||
return f.schema
|
||||
}
|
||||
|
||||
|
|
@ -506,8 +506,8 @@ func (f *Frame) ViewPath(name string) string {
|
|||
|
||||
// View returns a view in the frame by name.
|
||||
func (f *Frame) View(name string) *View {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
f.mu.RLock()
|
||||
defer f.mu.RUnlock()
|
||||
return f.view(name)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ const (
|
|||
|
||||
// Holder represents a container for indexes.
|
||||
type Holder struct {
|
||||
mu sync.Mutex
|
||||
mu sync.RWMutex
|
||||
|
||||
// Indexes by name.
|
||||
indexes map[string]*Index
|
||||
|
|
@ -183,8 +183,8 @@ func (h *Holder) IndexPath(name string) string { return filepath.Join(h.Path, na
|
|||
|
||||
// Index returns the index by name.
|
||||
func (h *Holder) Index(name string) *Index {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
h.mu.RLock()
|
||||
defer h.mu.RUnlock()
|
||||
return h.index(name)
|
||||
}
|
||||
|
||||
|
|
|
|||
6
index.go
6
index.go
|
|
@ -37,7 +37,7 @@ const (
|
|||
|
||||
// Index represents a container for frames.
|
||||
type Index struct {
|
||||
mu sync.Mutex
|
||||
mu sync.RWMutex
|
||||
path string
|
||||
name string
|
||||
|
||||
|
|
@ -345,8 +345,8 @@ func (i *Index) InputDefinitionPath() string {
|
|||
|
||||
// Frame returns a frame in the index by name.
|
||||
func (i *Index) Frame(name string) *Frame {
|
||||
i.mu.Lock()
|
||||
defer i.mu.Unlock()
|
||||
i.mu.RLock()
|
||||
defer i.mu.RUnlock()
|
||||
return i.frame(name)
|
||||
}
|
||||
|
||||
|
|
|
|||
6
view.go
6
view.go
|
|
@ -43,7 +43,7 @@ func IsValidView(name string) bool {
|
|||
|
||||
// View represents a container for frame data.
|
||||
type View struct {
|
||||
mu sync.Mutex
|
||||
mu sync.RWMutex
|
||||
path string
|
||||
index string
|
||||
frame string
|
||||
|
|
@ -194,8 +194,8 @@ func (v *View) FragmentPath(slice uint64) string {
|
|||
|
||||
// Fragment returns a fragment in the view by slice.
|
||||
func (v *View) Fragment(slice uint64) *Fragment {
|
||||
v.mu.Lock()
|
||||
defer v.mu.Unlock()
|
||||
v.mu.RLock()
|
||||
defer v.mu.RUnlock()
|
||||
return v.fragment(slice)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue