mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-11 15:21:02 +00:00
refactor frame options to reduce code duplication
This commit is contained in:
parent
4d2b009315
commit
f68110be8b
1 changed files with 7 additions and 9 deletions
16
frame.go
16
frame.go
|
|
@ -213,6 +213,11 @@ func (f *Frame) CacheSize() uint32 {
|
|||
// Options returns all options for this frame.
|
||||
func (f *Frame) Options() FrameOptions {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
return f.options()
|
||||
}
|
||||
|
||||
func (f *Frame) options() FrameOptions {
|
||||
opt := FrameOptions{
|
||||
RowLabel: f.rowLabel,
|
||||
InverseEnabled: f.inverseEnabled,
|
||||
|
|
@ -221,7 +226,6 @@ func (f *Frame) Options() FrameOptions {
|
|||
CacheSize: f.cacheSize,
|
||||
TimeQuantum: f.timeQuantum,
|
||||
}
|
||||
f.mu.Unlock()
|
||||
return opt
|
||||
}
|
||||
|
||||
|
|
@ -329,14 +333,8 @@ func (f *Frame) loadMeta() error {
|
|||
// saveMeta writes meta data for the frame.
|
||||
func (f *Frame) saveMeta() error {
|
||||
// Marshal metadata.
|
||||
buf, err := proto.Marshal(&internal.FrameMeta{
|
||||
RowLabel: f.rowLabel,
|
||||
InverseEnabled: f.inverseEnabled,
|
||||
RangeEnabled: f.rangeEnabled,
|
||||
CacheType: f.cacheType,
|
||||
CacheSize: f.cacheSize,
|
||||
TimeQuantum: string(f.timeQuantum),
|
||||
})
|
||||
fo := f.options()
|
||||
buf, err := proto.Marshal(fo.Encode())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue