diff --git a/api.go b/api.go index e528a4b21..fec6b3129 100644 --- a/api.go +++ b/api.go @@ -218,7 +218,7 @@ func (api *API) DeleteIndex(ctx context.Context, indexName string) error { } // CreateFrame makes the named frame in the named index with the given options. -func (api *API) CreateFrame(ctx context.Context, indexName string, frameName string, options FrameOptions) (*Frame, error) { +func (api *API) CreateFrame(ctx context.Context, indexName string, frameName string, options FieldOptions) (*Field, error) { if err := api.validate(apiCreateFrame); err != nil { return nil, errors.Wrap(err, "validating api method") } @@ -679,7 +679,7 @@ func (api *API) LongQueryTime() time.Duration { return api.Cluster.LongQueryTime } -func (api *API) indexFrame(indexName string, frameName string, slice uint64) (*Index, *Frame, error) { +func (api *API) indexFrame(indexName string, frameName string, slice uint64) (*Index, *Field, error) { // Validate that this handler owns the slice. if !api.Cluster.OwnsSlice(api.LocalID(), indexName, slice) { api.Logger.Printf("node %s does not own slice %d of index %s", api.LocalID(), slice, indexName) diff --git a/client.go b/client.go index 1d78dde23..4c8ba2157 100644 --- a/client.go +++ b/client.go @@ -330,7 +330,7 @@ func (c *InternalHTTPClient) EnsureIndex(ctx context.Context, name string, optio return err } -func (c *InternalHTTPClient) EnsureFrame(ctx context.Context, indexName string, frameName string, options FrameOptions) error { +func (c *InternalHTTPClient) EnsureFrame(ctx context.Context, indexName string, frameName string, options FieldOptions) error { err := c.CreateFrame(ctx, indexName, frameName, options) if err == nil || err == ErrFrameExists { return nil @@ -616,7 +616,7 @@ func (c *InternalHTTPClient) backupSliceNode(ctx context.Context, index, frame s } // CreateFrame creates a new frame on the server. -func (c *InternalHTTPClient) CreateFrame(ctx context.Context, index, frame string, opt FrameOptions) error { +func (c *InternalHTTPClient) CreateFrame(ctx context.Context, index, frame string, opt FieldOptions) error { if index == "" { return ErrIndexRequired } @@ -1056,10 +1056,10 @@ type InternalClient interface { Import(ctx context.Context, index, frame string, slice uint64, bits []Bit) error ImportK(ctx context.Context, index, frame string, bits []Bit) error EnsureIndex(ctx context.Context, name string, options IndexOptions) error - EnsureFrame(ctx context.Context, indexName string, frameName string, options FrameOptions) error + EnsureFrame(ctx context.Context, indexName string, frameName string, options FieldOptions) error ImportValue(ctx context.Context, index, frame string, slice uint64, vals []FieldValue) error ExportCSV(ctx context.Context, index, frame string, slice uint64, w io.Writer) error - CreateFrame(ctx context.Context, index, frame string, opt FrameOptions) error + CreateFrame(ctx context.Context, index, frame string, opt FieldOptions) error FragmentBlocks(ctx context.Context, index, frame string, slice uint64) ([]FragmentBlock, error) BlockData(ctx context.Context, index, frame string, slice uint64, block int) ([]uint64, []uint64, error) ColumnAttrDiff(ctx context.Context, index string, blks []AttrBlock) (map[uint64]map[string]interface{}, error) diff --git a/client_test.go b/client_test.go index 1edd37bc2..6f1931e29 100644 --- a/client_test.go +++ b/client_test.go @@ -246,8 +246,8 @@ func TestClient_ImportValue(t *testing.T) { fldName := "f" - fo := pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + fo := pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: -100, Max: 100, } diff --git a/cluster_internal_test.go b/cluster_internal_test.go index 6b1f6e72b..acccd37d3 100644 --- a/cluster_internal_test.go +++ b/cluster_internal_test.go @@ -145,7 +145,7 @@ func TestFragSources(t *testing.T) { c5.addNodeBasicSorted(node3) idx := newIndexWithTempPath("i") - frame, err := idx.CreateFrameIfNotExists("f", FrameOptions{}) + frame, err := idx.CreateFrameIfNotExists("f", FieldOptions{}) if err != nil { t.Fatal(err) } diff --git a/cluster_test.go b/cluster_test.go index 99b322a0e..f8903aafd 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -416,7 +416,7 @@ func TestCluster_ResizeStates(t *testing.T) { } // Add Bit Data to node0. - if err := tc.CreateFrame("i", "f", FrameOptions{}); err != nil { + if err := tc.CreateFrame("i", "f", FieldOptions{}); err != nil { t.Fatal(err) } tc.SetBit("i", "f", "standard", 1, 101, nil) diff --git a/ctl/import.go b/ctl/import.go index 45bf81d42..3a7835cb2 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -41,7 +41,7 @@ type ImportCommand struct { // Options for index & frame to be created if they don't exist IndexOptions pilosa.IndexOptions - FrameOptions pilosa.FrameOptions + FrameOptions pilosa.FieldOptions // CreateSchema ensures the schema exists before import CreateSchema bool @@ -103,7 +103,7 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { } // Determine the frame type in order to correctly handle the input data. - frameType := pilosa.DefaultFrameType + frameType := pilosa.DefaultFieldType schema, err := cmd.Client.Schema(ctx) if err != nil { return errors.Wrap(err, "getting schema") @@ -144,7 +144,7 @@ func (cmd *ImportCommand) ensureSchema(ctx context.Context) error { // importPath parses a path into bits and imports it to the server. func (cmd *ImportCommand) importPath(ctx context.Context, frameType, path string) error { // If frameType is `int`, treat the import data as values to be range-encoded. - if frameType == pilosa.FrameTypeInt { + if frameType == pilosa.FieldTypeInt { return cmd.bufferValues(ctx, path) } else { if cmd.StringKeys { diff --git a/diagnostics.go b/diagnostics.go index 1968a4e74..10ecfa22d 100644 --- a/diagnostics.go +++ b/diagnostics.go @@ -227,7 +227,7 @@ func (d *DiagnosticsCollector) EnrichWithSchemaProperties() { numIndexes += 1 for _, frame := range index.Frames() { numFrames += 1 - if frame.Type() == FrameTypeInt { + if frame.Type() == FieldTypeInt { bsiFieldCount += 1 } if frame.TimeQuantum() != "" { diff --git a/executor.go b/executor.go index eee4fa0ee..fd98f7189 100644 --- a/executor.go +++ b/executor.go @@ -983,7 +983,7 @@ func (e *Executor) executeClearBit(ctx context.Context, index string, c *pql.Cal } // executeClearBitView executes a ClearBit() call for a single view. -func (e *Executor) executeClearBitView(ctx context.Context, index string, c *pql.Call, f *Frame, view string, colID, rowID uint64, opt *ExecOptions) (bool, error) { +func (e *Executor) executeClearBitView(ctx context.Context, index string, c *pql.Call, f *Field, view string, colID, rowID uint64, opt *ExecOptions) (bool, error) { slice := colID / SliceWidth ret := false for _, node := range e.Cluster.SliceNodes(index, slice) { @@ -1058,7 +1058,7 @@ func (e *Executor) executeSetBit(ctx context.Context, index string, c *pql.Call, } // executeSetBitView executes a SetBit() call for a specific view. -func (e *Executor) executeSetBitView(ctx context.Context, index string, c *pql.Call, f *Frame, view string, colID, rowID uint64, timestamp *time.Time, opt *ExecOptions) (bool, error) { +func (e *Executor) executeSetBitView(ctx context.Context, index string, c *pql.Call, f *Field, view string, colID, rowID uint64, timestamp *time.Time, opt *ExecOptions) (bool, error) { slice := colID / SliceWidth ret := false diff --git a/executor_test.go b/executor_test.go index 89e54a1de..0d70ae37f 100644 --- a/executor_test.go +++ b/executor_test.go @@ -33,7 +33,7 @@ func TestExecutor_Execute_Bitmap(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - f, err := index.CreateFrame("f", pilosa.FrameOptions{}) + f, err := index.CreateFrame("f", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) } @@ -83,7 +83,7 @@ func TestExecutor_Execute_Bitmap(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := index.CreateFrame("f", pilosa.FrameOptions{}); err != nil { + if _, err := index.CreateFrame("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -271,13 +271,13 @@ func TestExecutor_Execute_SetValue(t *testing.T) { // Create frames. index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 50, }); err != nil { t.Fatal(err) - } else if _, err := index.CreateFrameIfNotExists("xxx", pilosa.FrameOptions{}); err != nil { + } else if _, err := index.CreateFrameIfNotExists("xxx", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -311,8 +311,8 @@ func TestExecutor_Execute_SetValue(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 100, }); err != nil { @@ -349,9 +349,9 @@ func TestExecutor_Execute_SetRowAttrs(t *testing.T) { // Create frames. index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{}); err != nil { + if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if _, err := index.CreateFrameIfNotExists("xxx", pilosa.FrameOptions{}); err != nil { + } else if _, err := index.CreateFrameIfNotExists("xxx", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -388,9 +388,9 @@ func TestExecutor_Execute_TopN(t *testing.T) { // Set columns for rows 0, 10, & 20 across two slices. if idx, err := hldr.CreateIndex("i", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("f", pilosa.FrameOptions{}); err != nil { + } else if _, err := idx.CreateFrame("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("other", pilosa.FrameOptions{}); err != nil { + } else if _, err := idx.CreateFrame("other", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := e.Execute(context.Background(), "i", test.MustParse(` SetBit(frame=f, row=0, col=0) @@ -572,12 +572,12 @@ func TestExecutor_Execute_MinMax(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("x", pilosa.FrameOptions{}); err != nil { + if _, err := idx.CreateFrame("x", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: -10, Max: 100, }); err != nil { @@ -667,28 +667,28 @@ func TestExecutor_Execute_Sum(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("x", pilosa.FrameOptions{}); err != nil { + if _, err := idx.CreateFrame("x", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("foo", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("foo", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 10, Max: 100, }); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 100000, }); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("other", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("other", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 1000, }); err != nil { @@ -737,8 +737,8 @@ func TestExecutor_Execute_BSIGroupRange(t *testing.T) { index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) // Create frame. - if _, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeTime, + if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeTime, TimeQuantum: pilosa.TimeQuantum("YMDH"), }); err != nil { t.Fatal(err) @@ -780,36 +780,36 @@ func TestExecutor_Execute_Range(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("f", pilosa.FrameOptions{}); err != nil { + if _, err := idx.CreateFrame("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("foo", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("foo", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 10, Max: 100, }); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 100000, }); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("other", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("other", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 1000, }); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("edge", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("edge", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: -100, Max: 100, }); err != nil { @@ -1068,7 +1068,7 @@ func TestExecutor_Execute_Remote_SetBit(t *testing.T) { s.Handler.API.Holder = hldr.Holder // Create frame. - if _, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateFrame("f", pilosa.FrameOptions{}); err != nil { + if _, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateFrame("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -1120,7 +1120,7 @@ func TestExecutor_Execute_Remote_SetBit_With_Timestamp(t *testing.T) { s.Handler.API.Holder = hldr.Holder // Create frame. - if f, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateFrame("f", pilosa.FrameOptions{}); err != nil { + if f, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateFrame("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if err := f.SetTimeQuantum("Y"); err != nil { t.Fatal(err) @@ -1223,7 +1223,7 @@ func TestExectutor_SetColumnAttrs_ExcludeFrame(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - index.CreateFrame("f", pilosa.FrameOptions{}) + index.CreateFrame("f", pilosa.FieldOptions{}) targetAttrs := map[string]interface{}{ "foo": "bar", } diff --git a/fragment_test.go b/fragment_test.go index b72450fbb..2d618aa81 100644 --- a/fragment_test.go +++ b/fragment_test.go @@ -754,7 +754,7 @@ func TestFragment_TopN_CacheSize(t *testing.T) { defer index.Close() // Create frame. - frame, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{CacheType: pilosa.CacheTypeRanked, CacheSize: cacheSize}) + frame, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked, CacheSize: cacheSize}) if err != nil { t.Fatal(err) } @@ -924,7 +924,7 @@ func TestFragment_RankCache_Persistence(t *testing.T) { defer index.Close() // Create frame. - frame, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{CacheType: pilosa.CacheTypeRanked}) + frame, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked}) if err != nil { t.Fatal(err) } diff --git a/frame.go b/frame.go index ac9eb5ee7..b69848344 100644 --- a/frame.go +++ b/frame.go @@ -31,7 +31,7 @@ import ( // Default frame settings. const ( - DefaultFrameType = FrameTypeSet + DefaultFieldType = FieldTypeSet DefaultCacheType = CacheTypeRanked @@ -39,15 +39,15 @@ const ( DefaultCacheSize = 50000 ) -// Frame types. +// Field types. const ( - FrameTypeSet = "set" - FrameTypeInt = "int" - FrameTypeTime = "time" + FieldTypeSet = "set" + FieldTypeInt = "int" + FieldTypeTime = "time" ) -// Frame represents a container for views. -type Frame struct { +// Field represents a container for views. +type Field struct { mu sync.RWMutex path string index string @@ -61,33 +61,33 @@ type Frame struct { broadcaster Broadcaster Stats StatsClient - // Frame options. - options FrameOptions + // Field options. + options FieldOptions bsiGroups []*bsiGroup Logger Logger } -// FrameOption is a functional option type for pilosa.Frame. -type FrameOption func(f *Frame) error +// FieldOption is a functional option type for pilosa.Fielde. +type FieldOption func(f *Field) error -// TODO: break these out into separate Options (not a FrameOptions object) -func OptFrameFrameOptions(o FrameOptions) FrameOption { - return func(f *Frame) error { +// TODO: break these out into separate Options (not a FieldOptions object) +func OptFieldFieldOptions(o FieldOptions) FieldOption { + return func(f *Field) error { f.options = o return nil } } -// NewFrame returns a new instance of frame. -func NewFrame(path, index, name string, opts ...FrameOption) (*Frame, error) { +// NewField returns a new instance of frame. +func NewField(path, index, name string, opts ...FieldOption) (*Field, error) { err := ValidateName(name) if err != nil { return nil, err } - f := &Frame{ + f := &Field{ path: path, index: index, name: name, @@ -99,8 +99,8 @@ func NewFrame(path, index, name string, opts ...FrameOption) (*Frame, error) { broadcaster: NopBroadcaster, Stats: NopStatsClient, - options: FrameOptions{ - Type: DefaultFrameType, + options: FieldOptions{ + Type: DefaultFieldType, CacheType: DefaultCacheType, CacheSize: DefaultCacheSize, }, @@ -119,19 +119,19 @@ func NewFrame(path, index, name string, opts ...FrameOption) (*Frame, error) { } // Name returns the name the frame was initialized with. -func (f *Frame) Name() string { return f.name } +func (f *Field) Name() string { return f.name } // Index returns the index name the frame was initialized with. -func (f *Frame) Index() string { return f.index } +func (f *Field) Index() string { return f.index } // Path returns the path the frame was initialized with. -func (f *Frame) Path() string { return f.path } +func (f *Field) Path() string { return f.path } // RowAttrStore returns the attribute storage. -func (f *Frame) RowAttrStore() AttrStore { return f.rowAttrStore } +func (f *Field) RowAttrStore() AttrStore { return f.rowAttrStore } // MaxSlice returns the max slice in the frame. -func (f *Frame) MaxSlice() uint64 { +func (f *Field) MaxSlice() uint64 { f.mu.RLock() defer f.mu.RUnlock() @@ -145,14 +145,14 @@ func (f *Frame) MaxSlice() uint64 { } // Type returns the frame type. -func (f *Frame) Type() string { +func (f *Field) Type() string { f.mu.RLock() defer f.mu.RUnlock() return f.options.Type } // CacheType returns the caching mode for the frame. -func (f *Frame) CacheType() string { +func (f *Field) CacheType() string { f.mu.RLock() defer f.mu.RUnlock() return f.options.CacheType @@ -160,7 +160,7 @@ func (f *Frame) CacheType() string { // SetCacheSize sets the cache size for ranked fames. Persists to meta file on update. // defaults to DefaultCacheSize 50000 -func (f *Frame) SetCacheSize(v uint32) error { +func (f *Field) SetCacheSize(v uint32) error { f.mu.Lock() defer f.mu.Unlock() @@ -179,7 +179,7 @@ func (f *Frame) SetCacheSize(v uint32) error { } // CacheSize returns the ranked frame cache size. -func (f *Frame) CacheSize() uint32 { +func (f *Field) CacheSize() uint32 { f.mu.RLock() v := f.options.CacheSize f.mu.RUnlock() @@ -187,14 +187,14 @@ func (f *Frame) CacheSize() uint32 { } // Options returns all options for this frame. -func (f *Frame) Options() FrameOptions { +func (f *Field) Options() FieldOptions { f.mu.RLock() defer f.mu.RUnlock() return f.options } // Open opens and initializes the frame. -func (f *Frame) Open() error { +func (f *Field) Open() error { if err := func() error { // Ensure the frame's path exists. if err := os.MkdirAll(f.path, 0777); err != nil { @@ -228,7 +228,7 @@ func (f *Frame) Open() error { } // openViews opens and initializes the views inside the frame. -func (f *Frame) openViews() error { +func (f *Field) openViews() error { file, err := os.Open(filepath.Join(f.path, "views")) if os.IsNotExist(err) { return nil @@ -260,7 +260,7 @@ func (f *Frame) openViews() error { } // loadMeta reads meta data for the frame, if any. -func (f *Frame) loadMeta() error { +func (f *Field) loadMeta() error { var pb internal.FrameMeta // Read data from meta file. @@ -287,7 +287,7 @@ func (f *Frame) loadMeta() error { } // saveMeta writes meta data for the frame. -func (f *Frame) saveMeta() error { +func (f *Field) saveMeta() error { // Marshal metadata. fo := f.options buf, err := proto.Marshal(fo.Encode()) @@ -304,10 +304,10 @@ func (f *Frame) saveMeta() error { } // applyOptions configures the frame based on opt. -func (f *Frame) applyOptions(opt FrameOptions) error { +func (f *Field) applyOptions(opt FieldOptions) error { switch opt.Type { - case FrameTypeSet, "": - f.options.Type = FrameTypeSet + case FieldTypeSet, "": + f.options.Type = FieldTypeSet if opt.CacheType != "" { f.options.CacheType = opt.CacheType } @@ -317,7 +317,7 @@ func (f *Frame) applyOptions(opt FrameOptions) error { f.options.Min = 0 f.options.Max = 0 f.options.TimeQuantum = "" - case FrameTypeInt: + case FieldTypeInt: f.options.Type = opt.Type f.options.CacheType = CacheTypeNone f.options.CacheSize = 0 @@ -339,7 +339,7 @@ func (f *Frame) applyOptions(opt FrameOptions) error { if err := f.createBSIGroup(bsig); err != nil { return errors.Wrap(err, "creating bsigroup") } - case FrameTypeTime: + case FieldTypeTime: f.options.Type = opt.Type f.options.CacheType = CacheTypeNone f.options.CacheSize = 0 @@ -358,7 +358,7 @@ func (f *Frame) applyOptions(opt FrameOptions) error { } // Close closes the frame and its views. -func (f *Frame) Close() error { +func (f *Field) Close() error { f.mu.Lock() defer f.mu.Unlock() @@ -379,7 +379,7 @@ func (f *Frame) Close() error { } // bsiGroup returns a bsiGroup by name. -func (f *Frame) bsiGroup(name string) *bsiGroup { +func (f *Field) bsiGroup(name string) *bsiGroup { f.mu.RLock() defer f.mu.RUnlock() for _, bsig := range f.bsiGroups { @@ -391,7 +391,7 @@ func (f *Frame) bsiGroup(name string) *bsiGroup { } // hasBSIGroup returns true if a bsiGroup exists on the frame. -func (f *Frame) hasBSIGroup(name string) bool { +func (f *Field) hasBSIGroup(name string) bool { for _, bsig := range f.bsiGroups { if bsig.Name == name { return true @@ -401,7 +401,7 @@ func (f *Frame) hasBSIGroup(name string) bool { } // createBSIGroup creates a new bsiGroup on the frame. -func (f *Frame) createBSIGroup(bsig *bsiGroup) error { +func (f *Field) createBSIGroup(bsig *bsiGroup) error { f.mu.Lock() defer f.mu.Unlock() @@ -414,7 +414,7 @@ func (f *Frame) createBSIGroup(bsig *bsiGroup) error { } // addBSIGroup adds a single bsiGroup to bsiGroups. -func (f *Frame) addBSIGroup(bsig *bsiGroup) error { +func (f *Field) addBSIGroup(bsig *bsiGroup) error { if err := bsig.validate(); err != nil { return errors.Wrap(err, "validating bsigroup") } else if f.hasBSIGroup(bsig.Name) { @@ -433,7 +433,7 @@ func (f *Frame) addBSIGroup(bsig *bsiGroup) error { } // deleteBSIGroupAndView deletes an existing bsiGroup on the schema. -func (f *Frame) deleteBSIGroupAndView(name string) error { +func (f *Field) deleteBSIGroupAndView(name string) error { f.mu.Lock() defer f.mu.Unlock() @@ -458,7 +458,7 @@ func (f *Frame) deleteBSIGroupAndView(name string) error { } // deleteBSIGroup removes a single bsiGroup from bsiGroups. -func (f *Frame) deleteBSIGroup(name string) error { +func (f *Field) deleteBSIGroup(name string) error { for i, bsig := range f.bsiGroups { if bsig.Name == name { copy(f.bsiGroups[i:], f.bsiGroups[i+1:]) @@ -470,14 +470,14 @@ func (f *Frame) deleteBSIGroup(name string) error { } // TimeQuantum returns the time quantum for the frame. -func (f *Frame) TimeQuantum() TimeQuantum { +func (f *Field) TimeQuantum() TimeQuantum { f.mu.Lock() defer f.mu.Unlock() return f.options.TimeQuantum } // SetTimeQuantum sets the time quantum for the frame. -func (f *Frame) SetTimeQuantum(q TimeQuantum) error { +func (f *Field) SetTimeQuantum(q TimeQuantum) error { f.mu.Lock() defer f.mu.Unlock() @@ -498,21 +498,21 @@ func (f *Frame) SetTimeQuantum(q TimeQuantum) error { } // ViewPath returns the path to a view in the frame. -func (f *Frame) ViewPath(name string) string { +func (f *Field) ViewPath(name string) string { return filepath.Join(f.path, "views", name) } // View returns a view in the frame by name. -func (f *Frame) View(name string) *View { +func (f *Field) View(name string) *View { f.mu.RLock() defer f.mu.RUnlock() return f.view(name) } -func (f *Frame) view(name string) *View { return f.views[name] } +func (f *Field) view(name string) *View { return f.views[name] } // Views returns a list of all views in the frame. -func (f *Frame) Views() []*View { +func (f *Field) Views() []*View { f.mu.RLock() defer f.mu.RUnlock() @@ -524,7 +524,7 @@ func (f *Frame) Views() []*View { } // viewNames returns a list of all views (as a string) in the frame. -func (f *Frame) viewNames() []string { +func (f *Field) viewNames() []string { f.mu.Lock() defer f.mu.Unlock() @@ -536,7 +536,7 @@ func (f *Frame) viewNames() []string { } // RecalculateCaches recalculates caches on every view in the frame. -func (f *Frame) RecalculateCaches() { +func (f *Field) RecalculateCaches() { for _, view := range f.Views() { view.RecalculateCaches() } @@ -544,7 +544,7 @@ func (f *Frame) RecalculateCaches() { // CreateViewIfNotExists returns the named view, creating it if necessary. // Additionally, a CreateViewMessage is sent to the cluster. -func (f *Frame) CreateViewIfNotExists(name string) (*View, error) { +func (f *Field) CreateViewIfNotExists(name string) (*View, error) { view, created, err := f.createViewIfNotExistsBase(name) if err != nil { @@ -569,7 +569,7 @@ func (f *Frame) CreateViewIfNotExists(name string) (*View, error) { // createViewIfNotExistsBase returns the named view, creating it if necessary. // The returned bool indicates whether the view was created or not. -func (f *Frame) createViewIfNotExistsBase(name string) (*View, bool, error) { +func (f *Field) createViewIfNotExistsBase(name string) (*View, bool, error) { f.mu.Lock() defer f.mu.Unlock() @@ -588,7 +588,7 @@ func (f *Frame) createViewIfNotExistsBase(name string) (*View, bool, error) { return view, true, nil } -func (f *Frame) newView(path, name string) *View { +func (f *Field) newView(path, name string) *View { view := NewView(path, f.index, f.name, name, f.options.CacheSize) view.cacheType = f.options.CacheType view.Logger = f.Logger @@ -599,7 +599,7 @@ func (f *Frame) newView(path, name string) *View { } // DeleteView removes the view from the frame. -func (f *Frame) DeleteView(name string) error { +func (f *Field) DeleteView(name string) error { view := f.views[name] if view == nil { return ErrInvalidView @@ -621,7 +621,7 @@ func (f *Frame) DeleteView(name string) error { } // SetBit sets a bit on a view within the frame. -func (f *Frame) SetBit(name string, rowID, colID uint64, t *time.Time) (changed bool, err error) { +func (f *Field) SetBit(name string, rowID, colID uint64, t *time.Time) (changed bool, err error) { // Validate view name. if !IsValidView(name) { return false, ErrInvalidView @@ -663,7 +663,7 @@ func (f *Frame) SetBit(name string, rowID, colID uint64, t *time.Time) (changed } // ClearBit clears a bit within the frame. -func (f *Frame) ClearBit(name string, rowID, colID uint64, t *time.Time) (changed bool, err error) { +func (f *Field) ClearBit(name string, rowID, colID uint64, t *time.Time) (changed bool, err error) { // Validate view name. if !IsValidView(name) { return false, ErrInvalidView @@ -705,7 +705,7 @@ func (f *Frame) ClearBit(name string, rowID, colID uint64, t *time.Time) (change } // Value reads a frame value for a column. -func (f *Frame) Value(columnID uint64) (value int64, exists bool, err error) { +func (f *Field) Value(columnID uint64) (value int64, exists bool, err error) { bsig := f.bsiGroup(f.name) if bsig == nil { return 0, false, ErrBSIGroupNotFound @@ -727,7 +727,7 @@ func (f *Frame) Value(columnID uint64) (value int64, exists bool, err error) { } // SetValue sets a frame value for a column. -func (f *Frame) SetValue(columnID uint64, value int64) (changed bool, err error) { +func (f *Field) SetValue(columnID uint64, value int64) (changed bool, err error) { // Fetch bsiGroup and validate value. bsig := f.bsiGroup(f.name) if bsig == nil { @@ -752,7 +752,7 @@ func (f *Frame) SetValue(columnID uint64, value int64) (changed bool, err error) // Sum returns the sum and count for a frame. // An optional filtering row can be provided. -func (f *Frame) Sum(filter *Row, name string) (sum, count int64, err error) { +func (f *Field) Sum(filter *Row, name string) (sum, count int64, err error) { bsig := f.bsiGroup(name) if bsig == nil { return 0, 0, ErrBSIGroupNotFound @@ -772,7 +772,7 @@ func (f *Frame) Sum(filter *Row, name string) (sum, count int64, err error) { // Min returns the min for a frame. // An optional filtering row can be provided. -func (f *Frame) Min(filter *Row, name string) (min, count int64, err error) { +func (f *Field) Min(filter *Row, name string) (min, count int64, err error) { bsig := f.bsiGroup(name) if bsig == nil { return 0, 0, ErrBSIGroupNotFound @@ -792,7 +792,7 @@ func (f *Frame) Min(filter *Row, name string) (min, count int64, err error) { // Max returns the max for a frame. // An optional filtering row can be provided. -func (f *Frame) Max(filter *Row, name string) (max, count int64, err error) { +func (f *Field) Max(filter *Row, name string) (max, count int64, err error) { bsig := f.bsiGroup(name) if bsig == nil { return 0, 0, ErrBSIGroupNotFound @@ -810,7 +810,7 @@ func (f *Frame) Max(filter *Row, name string) (max, count int64, err error) { return int64(vmax) + bsig.Min, int64(vcount), nil } -func (f *Frame) Range(name string, op pql.Token, predicate int64) (*Row, error) { +func (f *Field) Range(name string, op pql.Token, predicate int64) (*Row, error) { // Retrieve and validate bsiGroup. bsig := f.bsiGroup(name) if bsig == nil { @@ -833,7 +833,7 @@ func (f *Frame) Range(name string, op pql.Token, predicate int64) (*Row, error) return view.rangeOp(op, bsig.BitDepth(), baseValue) } -func (f *Frame) RangeBetween(name string, predicateMin, predicateMax int64) (*Row, error) { +func (f *Field) RangeBetween(name string, predicateMin, predicateMax int64) (*Row, error) { // Retrieve and validate bsiGroup. bsig := f.bsiGroup(name) if bsig == nil { @@ -857,7 +857,7 @@ func (f *Frame) RangeBetween(name string, predicateMin, predicateMax int64) (*Ro } // Import bulk imports data. -func (f *Frame) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) error { +func (f *Field) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) error { // Determine quantum if timestamps are set. q := f.TimeQuantum() if hasTime(timestamps) && q == "" { @@ -914,7 +914,7 @@ func (f *Frame) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) erro } // ImportValue bulk imports range-encoded value data. -func (f *Frame) ImportValue(columnIDs []uint64, values []int64) error { +func (f *Field) ImportValue(columnIDs []uint64, values []int64) error { viewName := viewBSIGroupPrefix + f.name // Get the bsiGroup so we know bitDepth. bsig := f.bsiGroup(f.name) @@ -970,17 +970,17 @@ func (f *Frame) ImportValue(columnIDs []uint64, values []int64) error { return nil } -// encodeFrames converts a into its internal representation. -func encodeFrames(a []*Frame) []*internal.Frame { +// encodeFields converts a into its internal representation. +func encodeFields(a []*Field) []*internal.Frame { other := make([]*internal.Frame, len(a)) for i := range a { - other[i] = encodeFrame(a[i]) + other[i] = encodeField(a[i]) } return other } -// encodeFrame converts f into its internal representation. -func encodeFrame(f *Frame) *internal.Frame { +// encodeField converts f into its internal representation. +func encodeField(f *Field) *internal.Frame { fo := f.options return &internal.Frame{ Name: f.name, @@ -989,45 +989,45 @@ func encodeFrame(f *Frame) *internal.Frame { } } -type frameSlice []*Frame +type fieldSlice []*Field -func (p frameSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } -func (p frameSlice) Len() int { return len(p) } -func (p frameSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() } +func (p fieldSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +func (p fieldSlice) Len() int { return len(p) } +func (p fieldSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() } -// FrameInfo represents schema information for a frame. -type FrameInfo struct { +// FieldInfo represents schema information for a frame. +type FieldInfo struct { Name string `json:"name"` - Options FrameOptions `json:"options"` + Options FieldOptions `json:"options"` Views []*ViewInfo `json:"views,omitempty"` } -type frameInfoSlice []*FrameInfo +type fieldInfoSlice []*FieldInfo -func (p frameInfoSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } -func (p frameInfoSlice) Len() int { return len(p) } -func (p frameInfoSlice) Less(i, j int) bool { return p[i].Name < p[j].Name } +func (p fieldInfoSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +func (p fieldInfoSlice) Len() int { return len(p) } +func (p fieldInfoSlice) Less(i, j int) bool { return p[i].Name < p[j].Name } -// FrameOptions represents options to set when initializing a frame. -type FrameOptions struct { +// FieldOptions represents options to set when initializing a field. +type FieldOptions struct { Type string `json:"type,omitempty"` CacheType string `json:"cacheType,omitempty"` CacheSize uint32 `json:"cacheSize,omitempty"` Min int64 `json:"min,omitempty"` Max int64 `json:"max,omitempty"` - TimeQuantum TimeQuantum `json:"timeQuantum,omitempty"` // TODO: rename this Quantum? + TimeQuantum TimeQuantum `json:"timeQuantum,omitempty"` } -// Validate ensures that FrameOption values are valid. -func (o *FrameOptions) Validate() error { +// Validate ensures that FieldOption values are valid. +func (o *FieldOptions) Validate() error { switch o.Type { - case FrameTypeSet, "": + case FieldTypeSet, "": // TODO: cacheType, cacheSize validation - case FrameTypeInt: + case FieldTypeInt: if o.Min > o.Max { return ErrInvalidBSIGroupRange } - case FrameTypeTime: + case FieldTypeTime: if o.TimeQuantum == "" || !o.TimeQuantum.Valid() { return ErrInvalidTimeQuantum } @@ -1038,11 +1038,11 @@ func (o *FrameOptions) Validate() error { } // Encode converts o into its internal representation. -func (o *FrameOptions) Encode() *internal.FrameMeta { - return encodeFrameOptions(o) +func (o *FieldOptions) Encode() *internal.FrameMeta { + return encodeFieldOptions(o) } -func encodeFrameOptions(o *FrameOptions) *internal.FrameMeta { +func encodeFieldOptions(o *FieldOptions) *internal.FrameMeta { if o == nil { return nil } @@ -1056,11 +1056,11 @@ func encodeFrameOptions(o *FrameOptions) *internal.FrameMeta { } } -func decodeFrameOptions(options *internal.FrameMeta) *FrameOptions { +func decodeFieldOptions(options *internal.FrameMeta) *FieldOptions { if options == nil { return nil } - return &FrameOptions{ + return &FieldOptions{ Type: options.Type, CacheType: options.CacheType, CacheSize: options.CacheSize, diff --git a/frame_test.go b/frame_test.go index 3964af785..99dea0938 100644 --- a/frame_test.go +++ b/frame_test.go @@ -50,10 +50,10 @@ func TestFrame_CreateViewIfNotExists(t *testing.T) { // Ensure frame can set its time quantum. func TestFrame_SetTimeQuantum(t *testing.T) { - fo := pilosa.FrameOptions{ + fo := pilosa.FieldOptions{ Type: "time", } - f := test.MustOpenFrame(pilosa.OptFrameFrameOptions(fo)) + f := test.MustOpenFrame(pilosa.OptFieldFieldOptions(fo)) defer f.Close() // Set & retrieve time quantum. @@ -77,8 +77,8 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 30, }) @@ -114,8 +114,8 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 30, }) @@ -151,8 +151,8 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeSet, + f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeSet, }) if err != nil { t.Fatal(err) @@ -168,8 +168,8 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 20, Max: 30, }) @@ -187,8 +187,8 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 20, Max: 30, }) @@ -208,7 +208,7 @@ func TestFrame_NameRestriction(t *testing.T) { if err != nil { panic(err) } - frame, err := pilosa.NewFrame(path, "i", ".meta") + frame, err := pilosa.NewField(path, "i", ".meta") if frame != nil { t.Fatalf("unexpected frame name %s", err) } @@ -240,13 +240,13 @@ func TestFrame_NameValidation(t *testing.T) { panic(err) } for _, name := range validFrameNames { - _, err := pilosa.NewFrame(path, "i", name) + _, err := pilosa.NewField(path, "i", name) if err != nil { t.Fatalf("unexpected frame name: %s %s", name, err) } } for _, name := range invalidFrameNames { - _, err := pilosa.NewFrame(path, "i", name) + _, err := pilosa.NewField(path, "i", name) if err == nil { t.Fatalf("expected error on frame name: %s", name) } diff --git a/handler.go b/handler.go index d4ed5ab37..4cc64fbb2 100644 --- a/handler.go +++ b/handler.go @@ -546,7 +546,7 @@ func (p *postFrameRequest) UnmarshalJSON(b []byte) error { return errors.Wrap(err, "unmarshaling unexpected keys") } - validFrameOptions := getValidOptions(FrameOptions{}) + validFrameOptions := getValidOptions(FieldOptions{}) err := validateOptions(m, validFrameOptions) if err != nil { return err @@ -575,7 +575,7 @@ func getValidOptions(option interface{}) []string { } type postFrameRequest struct { - Options FrameOptions `json:"options"` + Options FieldOptions `json:"options"` } type postFrameResponse struct{} diff --git a/handler_internal_test.go b/handler_internal_test.go index ceaeb707c..9adab16ac 100644 --- a/handler_internal_test.go +++ b/handler_internal_test.go @@ -62,12 +62,12 @@ func TestPostFrameRequestUnmarshalJSON(t *testing.T) { expected postFrameRequest err string }{ - {json: `{"options": {}}`, expected: postFrameRequest{Options: FrameOptions{}}}, + {json: `{"options": {}}`, expected: postFrameRequest{Options: FieldOptions{}}}, {json: `{"options": 4}`, err: "options is not map[string]interface{}"}, {json: `{"option": {}}`, err: "Unknown key: option:map[]"}, {json: `{"options": {"badKey": "test"}}`, err: "Unknown key: badKey:test"}, {json: `{"options": {"inverseEnabled": true}}`, err: "Unknown key: inverseEnabled:true"}, - {json: `{"options": {"cacheType": "type"}}`, expected: postFrameRequest{Options: FrameOptions{CacheType: "type"}}}, + {json: `{"options": {"cacheType": "type"}}`, expected: postFrameRequest{Options: FieldOptions{CacheType: "type"}}}, {json: `{"options": {"inverse": true, "cacheType": "type"}}`, err: "Unknown key: inverse:true"}, } for _, test := range tests { diff --git a/handler_test.go b/handler_test.go index 30bba9254..c378a30cf 100644 --- a/handler_test.go +++ b/handler_test.go @@ -83,17 +83,17 @@ func TestHandler_Schema(t *testing.T) { i0 := hldr.MustCreateIndexIfNotExists("i0", pilosa.IndexOptions{}) i1 := hldr.MustCreateIndexIfNotExists("i1", pilosa.IndexOptions{}) - if f, err := i0.CreateFrameIfNotExists("f1", pilosa.FrameOptions{}); err != nil { + if f, err := i0.CreateFrameIfNotExists("f1", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := f.SetBit(pilosa.ViewStandard, 0, 0, nil); err != nil { t.Fatal(err) } - if f, err := i1.CreateFrameIfNotExists("f0", pilosa.FrameOptions{}); err != nil { + if f, err := i1.CreateFrameIfNotExists("f0", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := f.SetBit(pilosa.ViewStandard, 0, 0, nil); err != nil { t.Fatal(err) } - if _, err := i0.CreateFrameIfNotExists("f0", pilosa.FrameOptions{}); err != nil { + if _, err := i0.CreateFrameIfNotExists("f0", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -120,17 +120,17 @@ func TestHandler_Status(t *testing.T) { i0 := hldr.MustCreateIndexIfNotExists("i0", pilosa.IndexOptions{}) i1 := hldr.MustCreateIndexIfNotExists("i1", pilosa.IndexOptions{}) - if f, err := i0.CreateFrameIfNotExists("f1", pilosa.FrameOptions{}); err != nil { + if f, err := i0.CreateFrameIfNotExists("f1", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := f.SetBit(pilosa.ViewStandard, 0, 0, nil); err != nil { t.Fatal(err) } - if f, err := i1.CreateFrameIfNotExists("f0", pilosa.FrameOptions{}); err != nil { + if f, err := i1.CreateFrameIfNotExists("f0", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := f.SetBit(pilosa.ViewStandard, 0, 0, nil); err != nil { t.Fatal(err) } - if _, err := i0.CreateFrameIfNotExists("f0", pilosa.FrameOptions{}); err != nil { + if _, err := i0.CreateFrameIfNotExists("f0", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -699,7 +699,7 @@ func TestHandler_DeleteFrame(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() i0 := hldr.MustCreateIndexIfNotExists("i0", pilosa.IndexOptions{}) - if _, err := i0.CreateFrameIfNotExists("f1", pilosa.FrameOptions{}); err != nil { + if _, err := i0.CreateFrameIfNotExists("f1", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -777,7 +777,7 @@ func TestHandler_Frame_AttrStore_Diff(t *testing.T) { // Set attributes on the index. idx := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - f, err := idx.CreateFrameIfNotExists("meta", pilosa.FrameOptions{}) + f, err := idx.CreateFrameIfNotExists("meta", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) } diff --git a/holder.go b/holder.go index 6d13159b9..3a3bcca0c 100644 --- a/holder.go +++ b/holder.go @@ -215,14 +215,14 @@ func (h *Holder) Schema() []*IndexInfo { for _, index := range h.Indexes() { di := &IndexInfo{Name: index.Name()} for _, frame := range index.Frames() { - fi := &FrameInfo{Name: frame.Name(), Options: frame.Options()} + fi := &FieldInfo{Name: frame.Name(), Options: frame.Options()} for _, view := range frame.Views() { fi.Views = append(fi.Views, &ViewInfo{Name: view.Name()}) } sort.Sort(viewInfoSlice(fi.Views)) di.Frames = append(di.Frames, fi) } - sort.Sort(frameInfoSlice(di.Frames)) + sort.Sort(fieldInfoSlice(di.Frames)) a = append(a, di) } sort.Sort(indexInfoSlice(a)) @@ -240,7 +240,7 @@ func (h *Holder) ApplySchema(schema *internal.Schema) error { } // Create frames that don't exist. for _, f := range index.Frames { - opt := decodeFrameOptions(f.Meta) + opt := decodeFieldOptions(f.Meta) frame, err := idx.CreateFrameIfNotExists(f.Name, *opt) if err != nil { return errors.Wrap(err, "creating frame") @@ -391,7 +391,7 @@ func (h *Holder) DeleteIndex(name string) error { } // Frame returns the frame for an index and name. -func (h *Holder) Frame(index, name string) *Frame { +func (h *Holder) Frame(index, name string) *Field { idx := h.Index(index) if idx == nil { return nil diff --git a/holder_test.go b/holder_test.go index c7877e3ba..0081b105c 100644 --- a/holder_test.go +++ b/holder_test.go @@ -100,7 +100,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if err := h.Holder.Close(); err != nil { t.Fatal(err) @@ -119,7 +119,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if err := h.Holder.Close(); err != nil { t.Fatal(err) @@ -137,7 +137,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if err := h.Holder.Close(); err != nil { t.Fatal(err) @@ -159,7 +159,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) @@ -183,7 +183,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) @@ -208,7 +208,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) @@ -231,7 +231,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) @@ -257,7 +257,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) diff --git a/index.go b/index.go index 7829903aa..8421f8273 100644 --- a/index.go +++ b/index.go @@ -35,7 +35,7 @@ type Index struct { name string // Frames by name. - frames map[string]*Frame + frames map[string]*Field // Max Slice on any node in the cluster, according to this node. remoteMaxSlice uint64 @@ -61,7 +61,7 @@ func NewIndex(path, name string) (*Index, error) { return &Index{ path: path, name: name, - frames: make(map[string]*Frame), + frames: make(map[string]*Field), remoteMaxSlice: 0, @@ -203,7 +203,7 @@ func (i *Index) Close() error { return errors.Wrap(err, "closing frame") } } - i.frames = make(map[string]*Frame) + i.frames = make(map[string]*Field) return nil } @@ -238,24 +238,24 @@ func (i *Index) SetRemoteMaxSlice(newmax uint64) { func (i *Index) FramePath(name string) string { return filepath.Join(i.path, name) } // Frame returns a frame in the index by name. -func (i *Index) Frame(name string) *Frame { +func (i *Index) Frame(name string) *Field { i.mu.RLock() defer i.mu.RUnlock() return i.frame(name) } -func (i *Index) frame(name string) *Frame { return i.frames[name] } +func (i *Index) frame(name string) *Field { return i.frames[name] } // Frames returns a list of all frames in the index. -func (i *Index) Frames() []*Frame { +func (i *Index) Frames() []*Field { i.mu.RLock() defer i.mu.RUnlock() - a := make([]*Frame, 0, len(i.frames)) + a := make([]*Field, 0, len(i.frames)) for _, f := range i.frames { a = append(a, f) } - sort.Sort(frameSlice(a)) + sort.Sort(fieldSlice(a)) return a } @@ -268,7 +268,7 @@ func (i *Index) RecalculateCaches() { } // CreateFrame creates a frame. -func (i *Index) CreateFrame(name string, opt FrameOptions) (*Frame, error) { +func (i *Index) CreateFrame(name string, opt FieldOptions) (*Field, error) { i.mu.Lock() defer i.mu.Unlock() @@ -280,7 +280,7 @@ func (i *Index) CreateFrame(name string, opt FrameOptions) (*Frame, error) { } // CreateFrameIfNotExists creates a frame with the given options if it doesn't exist. -func (i *Index) CreateFrameIfNotExists(name string, opt FrameOptions) (*Frame, error) { +func (i *Index) CreateFrameIfNotExists(name string, opt FieldOptions) (*Field, error) { i.mu.Lock() defer i.mu.Unlock() @@ -292,7 +292,7 @@ func (i *Index) CreateFrameIfNotExists(name string, opt FrameOptions) (*Frame, e return i.createFrame(name, opt) } -func (i *Index) createFrame(name string, opt FrameOptions) (*Frame, error) { +func (i *Index) createFrame(name string, opt FieldOptions) (*Field, error) { if name == "" { return nil, errors.New("frame name required") } else if opt.CacheType != "" && !IsValidCacheType(opt.CacheType) { @@ -332,8 +332,8 @@ func (i *Index) createFrame(name string, opt FrameOptions) (*Frame, error) { return f, nil } -func (i *Index) newFrame(path, name string) (*Frame, error) { - f, err := NewFrame(path, i.name, name) +func (i *Index) newFrame(path, name string) (*Field, error) { + f, err := NewField(path, i.name, name) if err != nil { return nil, err } @@ -380,7 +380,7 @@ func (p indexSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() } // IndexInfo represents schema information for an index. type IndexInfo struct { Name string `json:"name"` - Frames []*FrameInfo `json:"frames"` + Frames []*FieldInfo `json:"frames"` } type indexInfoSlice []*IndexInfo @@ -402,7 +402,7 @@ func EncodeIndexes(a []*Index) []*internal.Index { func encodeIndex(d *Index) *internal.Index { return &internal.Index{ Name: d.name, - Frames: encodeFrames(d.Frames()), + Frames: encodeFields(d.Frames()), } } diff --git a/index_test.go b/index_test.go index 86d9043ce..be6288ad8 100644 --- a/index_test.go +++ b/index_test.go @@ -29,7 +29,7 @@ func TestIndex_CreateFrameIfNotExists(t *testing.T) { defer index.Close() // Create frame. - f, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{}) + f, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) } else if f == nil { @@ -37,14 +37,14 @@ func TestIndex_CreateFrameIfNotExists(t *testing.T) { } // Retrieve existing frame. - other, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{}) + other, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) - } else if f.Frame != other.Frame { + } else if f.Field != other.Field { t.Fatal("frame mismatch") } - if f.Frame != index.Frame("f") { + if f.Field != index.Frame("f") { t.Fatal("frame mismatch") } } @@ -57,8 +57,8 @@ func TestIndex_CreateFrame(t *testing.T) { defer index.Close() // Create frame with explicit quantum. - f, err := index.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeTime, + f, err := index.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeTime, TimeQuantum: pilosa.TimeQuantum("YMDH"), }) if err != nil { @@ -76,20 +76,20 @@ func TestIndex_CreateFrame(t *testing.T) { defer index.Close() // Create frame with schema and verify it exists. - if f, err := index.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if f, err := index.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 10, Max: 20, }); err != nil { t.Fatal(err) - } else if !reflect.DeepEqual(f.Type(), pilosa.FrameTypeInt) { + } else if !reflect.DeepEqual(f.Type(), pilosa.FieldTypeInt) { t.Fatalf("unexpected type: %#v", f.Type()) } // Reopen the index & verify the fields are loaded. if err := index.Reopen(); err != nil { t.Fatal(err) - } else if f := index.Frame("f"); !reflect.DeepEqual(f.Type(), pilosa.FrameTypeInt) { + } else if f := index.Frame("f"); !reflect.DeepEqual(f.Type(), pilosa.FieldTypeInt) { t.Fatalf("unexpected type after reopen: %#v", f.Type()) } }) @@ -180,7 +180,7 @@ func TestIndex_DeleteFrame(t *testing.T) { defer index.Close() // Create frame. - if _, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{}); err != nil { + if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } diff --git a/server.go b/server.go index 02e56e9b0..d0585c992 100644 --- a/server.go +++ b/server.go @@ -460,7 +460,7 @@ func (s *Server) ReceiveMessage(pb proto.Message) error { if idx == nil { return fmt.Errorf("Local Index not found: %s", obj.Index) } - opt := decodeFrameOptions(obj.Meta) + opt := decodeFieldOptions(obj.Meta) _, err := idx.CreateFrame(obj.Frame, *opt) if err != nil { return err diff --git a/server/cluster_test.go b/server/cluster_test.go index e6777d90c..1b4e0b807 100644 --- a/server/cluster_test.go +++ b/server/cluster_test.go @@ -54,7 +54,7 @@ func TestMain_SendReceiveMessage(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { + } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -209,7 +209,7 @@ func TestClusterResize_AddNode(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { + } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -253,7 +253,7 @@ func TestClusterResize_AddNode(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { + } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -305,7 +305,7 @@ func TestClusterResize_AddNode(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { + } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -458,7 +458,7 @@ func TestClusterResize_RemoveNode(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { + } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } diff --git a/server/server_test.go b/server/server_test.go index edac4b6fd..920fde809 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -54,7 +54,7 @@ func TestMain_Set_Quick(t *testing.T) { if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && !strings.Contains(err.Error(), "index already exists") { t.Fatal(err) } - if err := client.CreateFrame(context.Background(), "i", cmd.Frame, pilosa.FrameOptions{}); err != nil && !strings.Contains(err.Error(), "frame already exists") { + if err := client.CreateFrame(context.Background(), "i", cmd.Frame, pilosa.FieldOptions{}); err != nil && !strings.Contains(err.Error(), "frame already exists") { t.Fatal(err) } if _, err := m.Query("i", "", fmt.Sprintf(`SetBit(row=%d, frame=%q, col=%d)`, cmd.ID, cmd.Frame, cmd.ColumnID)); err != nil { @@ -123,11 +123,11 @@ func TestMain_SetRowAttrs(t *testing.T) { client := m.Client() if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client.CreateFrame(context.Background(), "i", "x", pilosa.FrameOptions{}); err != nil { + } else if err := client.CreateFrame(context.Background(), "i", "x", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if err := client.CreateFrame(context.Background(), "i", "z", pilosa.FrameOptions{}); err != nil { + } else if err := client.CreateFrame(context.Background(), "i", "z", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if err := client.CreateFrame(context.Background(), "i", "neg", pilosa.FrameOptions{}); err != nil { + } else if err := client.CreateFrame(context.Background(), "i", "neg", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -200,7 +200,7 @@ func TestMain_SetColumnAttrs(t *testing.T) { client := m.Client() if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client.CreateFrame(context.Background(), "i", "x", pilosa.FrameOptions{}); err != nil { + } else if err := client.CreateFrame(context.Background(), "i", "x", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -286,7 +286,7 @@ func TestMain_RecalculateHashes(t *testing.T) { if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal("create index:", err) } - if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{CacheType: "ranked"}); err != nil { + if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{CacheType: "ranked"}); err != nil { t.Fatal("create frame:", err) } diff --git a/server_test.go b/server_test.go index 9e10374d7..9b5409330 100644 --- a/server_test.go +++ b/server_test.go @@ -19,7 +19,7 @@ func TestMonitorAntiEntropy(t *testing.T) { if err != nil { t.Fatalf("creating index: %v", err) } - err = client.CreateFrame(context.Background(), "balh", "fralh", pilosa.FrameOptions{}) + err = client.CreateFrame(context.Background(), "balh", "fralh", pilosa.FieldOptions{}) if err != nil { t.Fatalf("creating frame: %v", err) } diff --git a/stats_test.go b/stats_test.go index 611b7b2b6..47521fbf8 100644 --- a/stats_test.go +++ b/stats_test.go @@ -298,7 +298,7 @@ func TestStatsCount_DeleteFrame(t *testing.T) { called := false // Create index. indx, _ := hldr.CreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := indx.CreateFrameIfNotExists("test", pilosa.FrameOptions{}); err != nil { + if _, err := indx.CreateFrameIfNotExists("test", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } s.Handler.API.Holder.Stats = &MockStats{ diff --git a/test/cluster.go b/test/cluster.go index bf6858e79..4c0bd45a0 100644 --- a/test/cluster.go +++ b/test/cluster.go @@ -114,7 +114,7 @@ func (t *TestCluster) CreateIndex(name string) error { return nil } -func (t *TestCluster) CreateFrame(index, frame string, opt pilosa.FrameOptions) error { +func (t *TestCluster) CreateFrame(index, frame string, opt pilosa.FieldOptions) error { for _, c := range t.Clusters { idx, err := c.Holder.CreateIndexIfNotExists(index, pilosa.IndexOptions{}) if err != nil { diff --git a/test/frame.go b/test/frame.go index 09503a3cf..929070368 100644 --- a/test/frame.go +++ b/test/frame.go @@ -25,24 +25,24 @@ import ( // Frame represents a test wrapper for pilosa.Frame. type Frame struct { - *pilosa.Frame + *pilosa.Field } // NewFrame returns a new instance of Frame d/0. -func NewFrame(opt ...pilosa.FrameOption) *Frame { +func NewFrame(opt ...pilosa.FieldOption) *Frame { path, err := ioutil.TempDir("", "pilosa-frame-") if err != nil { panic(err) } - frame, err := pilosa.NewFrame(path, "i", "f", opt...) + frame, err := pilosa.NewField(path, "i", "f", opt...) if err != nil { panic(err) } - return &Frame{Frame: frame} + return &Frame{Field: frame} } // MustOpenFrame returns a new, opened frame at a temporary path. Panic on error. -func MustOpenFrame(opt ...pilosa.FrameOption) *Frame { +func MustOpenFrame(opt ...pilosa.FieldOption) *Frame { f := NewFrame(opt...) if err := f.Open(); err != nil { panic(err) @@ -53,18 +53,18 @@ func MustOpenFrame(opt ...pilosa.FrameOption) *Frame { // Close closes the frame and removes the underlying data. func (f *Frame) Close() error { defer os.RemoveAll(f.Path()) - return f.Frame.Close() + return f.Field.Close() } // Reopen closes the index and reopens it. func (f *Frame) Reopen() error { var err error - if err := f.Frame.Close(); err != nil { + if err := f.Field.Close(); err != nil { return err } path, index, name := f.Path(), f.Index(), f.Name() - f.Frame, err = pilosa.NewFrame(path, index, name) + f.Field, err = pilosa.NewField(path, index, name) if err != nil { return err } diff --git a/test/holder.go b/test/holder.go index 97b399bea..1344bd4c9 100644 --- a/test/holder.go +++ b/test/holder.go @@ -82,7 +82,7 @@ func (h *Holder) MustCreateIndexIfNotExists(index string, opt pilosa.IndexOption // MustCreateFrameIfNotExists returns a given frame. Panic on error. func (h *Holder) MustCreateFrameIfNotExists(index, frame string) *Frame { - f, err := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}).CreateFrameIfNotExists(frame, pilosa.FrameOptions{}) + f, err := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}).CreateFrameIfNotExists(frame, pilosa.FieldOptions{}) if err != nil { panic(err) } @@ -92,7 +92,7 @@ func (h *Holder) MustCreateFrameIfNotExists(index, frame string) *Frame { // MustCreateFragmentIfNotExists returns a given fragment. Panic on error. func (h *Holder) MustCreateFragmentIfNotExists(index, frame, view string, slice uint64) *Fragment { idx := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}) - f, err := idx.CreateFrameIfNotExists(frame, pilosa.FrameOptions{}) + f, err := idx.CreateFrameIfNotExists(frame, pilosa.FieldOptions{}) if err != nil { panic(err) } @@ -110,7 +110,7 @@ func (h *Holder) MustCreateFragmentIfNotExists(index, frame, view string, slice // MustCreateRankedFragmentIfNotExists returns a given fragment with a ranked cache. Panic on error. func (h *Holder) MustCreateRankedFragmentIfNotExists(index, frame, view string, slice uint64) *Fragment { idx := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}) - f, err := idx.CreateFrameIfNotExists(frame, pilosa.FrameOptions{CacheType: pilosa.CacheTypeRanked}) + f, err := idx.CreateFrameIfNotExists(frame, pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked}) if err != nil { panic(err) } diff --git a/test/index.go b/test/index.go index 5354c85f9..5689afda3 100644 --- a/test/index.go +++ b/test/index.go @@ -74,19 +74,19 @@ func (i *Index) Reopen() error { } // CreateFrame creates a frame with the given options. -func (i *Index) CreateFrame(name string, opt pilosa.FrameOptions) (*Frame, error) { +func (i *Index) CreateFrame(name string, opt pilosa.FieldOptions) (*Frame, error) { f, err := i.Index.CreateFrame(name, opt) if err != nil { return nil, err } - return &Frame{Frame: f}, nil + return &Frame{Field: f}, nil } // CreateFrameIfNotExists creates a frame with the given options if it doesn't exist. -func (i *Index) CreateFrameIfNotExists(name string, opt pilosa.FrameOptions) (*Frame, error) { +func (i *Index) CreateFrameIfNotExists(name string, opt pilosa.FieldOptions) (*Frame, error) { f, err := i.Index.CreateFrameIfNotExists(name, opt) if err != nil { return nil, err } - return &Frame{Frame: f}, nil + return &Frame{Field: f}, nil } diff --git a/utils_test.go b/utils_test.go index eb4170a19..7773db06c 100644 --- a/utils_test.go +++ b/utils_test.go @@ -104,7 +104,7 @@ func (t *ClusterCluster) CreateIndex(name string) error { return nil } -func (t *ClusterCluster) CreateFrame(index, frame string, opt FrameOptions) error { +func (t *ClusterCluster) CreateFrame(index, frame string, opt FieldOptions) error { for _, c := range t.Clusters { idx, err := c.Holder.CreateIndexIfNotExists(index, IndexOptions{}) if err != nil {