mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
more Frame to Field in tests. move frame*.go files to field*.go
This commit is contained in:
parent
ba5d687ee0
commit
0f8bd62e33
11 changed files with 92 additions and 92 deletions
|
|
@ -254,7 +254,7 @@ func TestClient_ImportValue(t *testing.T) {
|
|||
|
||||
// Load bitmap into cache to ensure cache gets updated.
|
||||
index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{})
|
||||
frame, err := index.CreateFrameIfNotExists(fldName, fo)
|
||||
frame, err := index.CreateFieldIfNotExists(fldName, fo)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.FieldOptions{})
|
||||
f, err := index.CreateField("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.FieldOptions{}); err != nil {
|
||||
if _, err := index.CreateField("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.FieldOptions{
|
||||
if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{
|
||||
Type: pilosa.FieldTypeInt,
|
||||
Min: 0,
|
||||
Max: 50,
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := index.CreateFrameIfNotExists("xxx", pilosa.FieldOptions{}); err != nil {
|
||||
} else if _, err := index.CreateFieldIfNotExists("xxx", pilosa.FieldOptions{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ 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.FieldOptions{
|
||||
if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{
|
||||
Type: pilosa.FieldTypeInt,
|
||||
Min: 0,
|
||||
Max: 100,
|
||||
|
|
@ -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.FieldOptions{}); err != nil {
|
||||
if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := index.CreateFrameIfNotExists("xxx", pilosa.FieldOptions{}); err != nil {
|
||||
} else if _, err := index.CreateFieldIfNotExists("xxx", pilosa.FieldOptions{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -737,7 +737,7 @@ func TestExecutor_Execute_BSIGroupRange(t *testing.T) {
|
|||
index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{})
|
||||
|
||||
// Create frame.
|
||||
if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{
|
||||
if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{
|
||||
Type: pilosa.FieldTypeTime,
|
||||
TimeQuantum: pilosa.TimeQuantum("YMDH"),
|
||||
}); 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.FieldOptions{}); err != nil {
|
||||
if _, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateField("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.FieldOptions{}); err != nil {
|
||||
if f, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateField("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.FieldOptions{})
|
||||
index.CreateField("f", pilosa.FieldOptions{})
|
||||
targetAttrs := map[string]interface{}{
|
||||
"foo": "bar",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ import (
|
|||
"github.com/pilosa/pilosa/test"
|
||||
)
|
||||
|
||||
// Ensure frame can open and retrieve a view.
|
||||
func TestFrame_CreateViewIfNotExists(t *testing.T) {
|
||||
f := test.MustOpenFrame()
|
||||
// Ensure field can open and retrieve a view.
|
||||
func TestField_CreateViewIfNotExists(t *testing.T) {
|
||||
f := test.MustOpenField()
|
||||
defer f.Close()
|
||||
|
||||
// Create view.
|
||||
|
|
@ -48,12 +48,12 @@ func TestFrame_CreateViewIfNotExists(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure frame can set its time quantum.
|
||||
func TestFrame_SetTimeQuantum(t *testing.T) {
|
||||
// Ensure field can set its time quantum.
|
||||
func TestField_SetTimeQuantum(t *testing.T) {
|
||||
fo := pilosa.FieldOptions{
|
||||
Type: "time",
|
||||
}
|
||||
f := test.MustOpenFrame(pilosa.OptFieldFieldOptions(fo))
|
||||
f := test.MustOpenField(pilosa.OptFieldFieldOptions(fo))
|
||||
defer f.Close()
|
||||
|
||||
// Set & retrieve time quantum.
|
||||
|
|
@ -63,7 +63,7 @@ func TestFrame_SetTimeQuantum(t *testing.T) {
|
|||
t.Fatalf("unexpected quantum: %s", q)
|
||||
}
|
||||
|
||||
// Reload frame and verify that it is persisted.
|
||||
// Reload field and verify that it is persisted.
|
||||
if err := f.Reopen(); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if q := f.TimeQuantum(); q != pilosa.TimeQuantum("YMDH") {
|
||||
|
|
@ -71,13 +71,13 @@ func TestFrame_SetTimeQuantum(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure a frame can set & read a bsiGroup value.
|
||||
func TestFrame_SetValue(t *testing.T) {
|
||||
// Ensure a field can set & read a bsiGroup value.
|
||||
func TestField_SetValue(t *testing.T) {
|
||||
t.Run("OK", func(t *testing.T) {
|
||||
idx := test.MustOpenIndex()
|
||||
defer idx.Close()
|
||||
|
||||
f, err := idx.CreateFrame("f", pilosa.FieldOptions{
|
||||
f, err := idx.CreateField("f", pilosa.FieldOptions{
|
||||
Type: pilosa.FieldTypeInt,
|
||||
Min: 0,
|
||||
Max: 30,
|
||||
|
|
@ -86,7 +86,7 @@ func TestFrame_SetValue(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Set value on frame.
|
||||
// Set value on field.
|
||||
if changed, err := f.SetValue(100, 21); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !changed {
|
||||
|
|
@ -114,7 +114,7 @@ func TestFrame_SetValue(t *testing.T) {
|
|||
idx := test.MustOpenIndex()
|
||||
defer idx.Close()
|
||||
|
||||
f, err := idx.CreateFrame("f", pilosa.FieldOptions{
|
||||
f, err := idx.CreateField("f", pilosa.FieldOptions{
|
||||
Type: pilosa.FieldTypeInt,
|
||||
Min: 0,
|
||||
Max: 30,
|
||||
|
|
@ -151,7 +151,7 @@ func TestFrame_SetValue(t *testing.T) {
|
|||
idx := test.MustOpenIndex()
|
||||
defer idx.Close()
|
||||
|
||||
f, err := idx.CreateFrame("f", pilosa.FieldOptions{
|
||||
f, err := idx.CreateField("f", pilosa.FieldOptions{
|
||||
Type: pilosa.FieldTypeSet,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -168,7 +168,7 @@ func TestFrame_SetValue(t *testing.T) {
|
|||
idx := test.MustOpenIndex()
|
||||
defer idx.Close()
|
||||
|
||||
f, err := idx.CreateFrame("f", pilosa.FieldOptions{
|
||||
f, err := idx.CreateField("f", pilosa.FieldOptions{
|
||||
Type: pilosa.FieldTypeInt,
|
||||
Min: 20,
|
||||
Max: 30,
|
||||
|
|
@ -187,7 +187,7 @@ func TestFrame_SetValue(t *testing.T) {
|
|||
idx := test.MustOpenIndex()
|
||||
defer idx.Close()
|
||||
|
||||
f, err := idx.CreateFrame("f", pilosa.FieldOptions{
|
||||
f, err := idx.CreateField("f", pilosa.FieldOptions{
|
||||
Type: pilosa.FieldTypeInt,
|
||||
Min: 20,
|
||||
Max: 30,
|
||||
|
|
@ -203,27 +203,27 @@ func TestFrame_SetValue(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestFrame_NameRestriction(t *testing.T) {
|
||||
path, err := ioutil.TempDir("", "pilosa-frame-")
|
||||
func TestField_NameRestriction(t *testing.T) {
|
||||
path, err := ioutil.TempDir("", "pilosa-field-")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
frame, err := pilosa.NewField(path, "i", ".meta")
|
||||
if frame != nil {
|
||||
t.Fatalf("unexpected frame name %s", err)
|
||||
field, err := pilosa.NewField(path, "i", ".meta")
|
||||
if field != nil {
|
||||
t.Fatalf("unexpected field name %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that frame name validation is consistent.
|
||||
func TestFrame_NameValidation(t *testing.T) {
|
||||
validFrameNames := []string{
|
||||
// Ensure that field name validation is consistent.
|
||||
func TestField_NameValidation(t *testing.T) {
|
||||
validFieldNames := []string{
|
||||
"foo",
|
||||
"hyphen-ated",
|
||||
"under_score",
|
||||
"abc123",
|
||||
"trailing_",
|
||||
}
|
||||
invalidFrameNames := []string{
|
||||
invalidFieldNames := []string{
|
||||
"",
|
||||
"123abc",
|
||||
"x.y",
|
||||
|
|
@ -235,27 +235,27 @@ func TestFrame_NameValidation(t *testing.T) {
|
|||
"a12345678901234567890123456789012345678901234567890123456789012345",
|
||||
}
|
||||
|
||||
path, err := ioutil.TempDir("", "pilosa-frame-")
|
||||
path, err := ioutil.TempDir("", "pilosa-field-")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, name := range validFrameNames {
|
||||
for _, name := range validFieldNames {
|
||||
_, err := pilosa.NewField(path, "i", name)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected frame name: %s %s", name, err)
|
||||
t.Fatalf("unexpected field name: %s %s", name, err)
|
||||
}
|
||||
}
|
||||
for _, name := range invalidFrameNames {
|
||||
for _, name := range invalidFieldNames {
|
||||
_, err := pilosa.NewField(path, "i", name)
|
||||
if err == nil {
|
||||
t.Fatalf("expected error on frame name: %s", name)
|
||||
t.Fatalf("expected error on field name: %s", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure frame can open and retrieve a view.
|
||||
func TestFrame_DeleteView(t *testing.T) {
|
||||
f := test.MustOpenFrame()
|
||||
// Ensure field can open and retrieve a view.
|
||||
func TestField_DeleteView(t *testing.T) {
|
||||
f := test.MustOpenField()
|
||||
defer f.Close()
|
||||
|
||||
viewName := pilosa.ViewStandard + "_v"
|
||||
|
|
@ -274,7 +274,7 @@ func TestFrame_DeleteView(t *testing.T) {
|
|||
}
|
||||
|
||||
if f.View(viewName) != nil {
|
||||
t.Fatal("view still exists in frame")
|
||||
t.Fatal("view still exists in field")
|
||||
}
|
||||
|
||||
// Recreate view with same name, verify that the old view was not reused.
|
||||
|
|
@ -754,7 +754,7 @@ func TestFragment_TopN_CacheSize(t *testing.T) {
|
|||
defer index.Close()
|
||||
|
||||
// Create frame.
|
||||
frame, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked, CacheSize: cacheSize})
|
||||
frame, err := index.CreateFieldIfNotExists("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.FieldOptions{CacheType: pilosa.CacheTypeRanked})
|
||||
frame, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.FieldOptions{}); err != nil {
|
||||
if f, err := i0.CreateFieldIfNotExists("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.FieldOptions{}); err != nil {
|
||||
if f, err := i1.CreateFieldIfNotExists("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.FieldOptions{}); err != nil {
|
||||
if _, err := i0.CreateFieldIfNotExists("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.FieldOptions{}); err != nil {
|
||||
if f, err := i0.CreateFieldIfNotExists("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.FieldOptions{}); err != nil {
|
||||
if f, err := i1.CreateFieldIfNotExists("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.FieldOptions{}); err != nil {
|
||||
if _, err := i0.CreateFieldIfNotExists("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.FieldOptions{}); err != nil {
|
||||
if _, err := i0.CreateFieldIfNotExists("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.FieldOptions{})
|
||||
f, err := idx.CreateFieldIfNotExists("meta", pilosa.FieldOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ func TestIndex_CreateFrameIfNotExists(t *testing.T) {
|
|||
defer index.Close()
|
||||
|
||||
// Create frame.
|
||||
f, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{})
|
||||
f, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if f == nil {
|
||||
|
|
@ -37,7 +37,7 @@ func TestIndex_CreateFrameIfNotExists(t *testing.T) {
|
|||
}
|
||||
|
||||
// Retrieve existing frame.
|
||||
other, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{})
|
||||
other, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if f.Field != other.Field {
|
||||
|
|
@ -57,7 +57,7 @@ func TestIndex_CreateFrame(t *testing.T) {
|
|||
defer index.Close()
|
||||
|
||||
// Create frame with explicit quantum.
|
||||
f, err := index.CreateFrame("f", pilosa.FieldOptions{
|
||||
f, err := index.CreateField("f", pilosa.FieldOptions{
|
||||
Type: pilosa.FieldTypeTime,
|
||||
TimeQuantum: pilosa.TimeQuantum("YMDH"),
|
||||
})
|
||||
|
|
@ -76,7 +76,7 @@ func TestIndex_CreateFrame(t *testing.T) {
|
|||
defer index.Close()
|
||||
|
||||
// Create frame with schema and verify it exists.
|
||||
if f, err := index.CreateFrame("f", pilosa.FieldOptions{
|
||||
if f, err := index.CreateField("f", pilosa.FieldOptions{
|
||||
Type: pilosa.FieldTypeInt,
|
||||
Min: 10,
|
||||
Max: 20,
|
||||
|
|
@ -180,7 +180,7 @@ func TestIndex_DeleteFrame(t *testing.T) {
|
|||
defer index.Close()
|
||||
|
||||
// Create frame.
|
||||
if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{}); err != nil {
|
||||
if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,41 +23,41 @@ import (
|
|||
"github.com/pilosa/pilosa"
|
||||
)
|
||||
|
||||
// Frame represents a test wrapper for pilosa.Frame.
|
||||
type Frame struct {
|
||||
// Field represents a test wrapper for pilosa.Field.
|
||||
type Field struct {
|
||||
*pilosa.Field
|
||||
}
|
||||
|
||||
// NewFrame returns a new instance of Frame d/0.
|
||||
func NewFrame(opt ...pilosa.FieldOption) *Frame {
|
||||
path, err := ioutil.TempDir("", "pilosa-frame-")
|
||||
// NewField returns a new instance of Field d/0.
|
||||
func NewField(opt ...pilosa.FieldOption) *Field {
|
||||
path, err := ioutil.TempDir("", "pilosa-field-")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
frame, err := pilosa.NewField(path, "i", "f", opt...)
|
||||
field, err := pilosa.NewField(path, "i", "f", opt...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &Frame{Field: frame}
|
||||
return &Field{Field: field}
|
||||
}
|
||||
|
||||
// MustOpenFrame returns a new, opened frame at a temporary path. Panic on error.
|
||||
func MustOpenFrame(opt ...pilosa.FieldOption) *Frame {
|
||||
f := NewFrame(opt...)
|
||||
// MustOpenField returns a new, opened field at a temporary path. Panic on error.
|
||||
func MustOpenField(opt ...pilosa.FieldOption) *Field {
|
||||
f := NewField(opt...)
|
||||
if err := f.Open(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
// Close closes the frame and removes the underlying data.
|
||||
func (f *Frame) Close() error {
|
||||
// Close closes the field and removes the underlying data.
|
||||
func (f *Field) Close() error {
|
||||
defer os.RemoveAll(f.Path())
|
||||
return f.Field.Close()
|
||||
}
|
||||
|
||||
// Reopen closes the index and reopens it.
|
||||
func (f *Frame) Reopen() error {
|
||||
func (f *Field) Reopen() error {
|
||||
var err error
|
||||
if err := f.Field.Close(); err != nil {
|
||||
return err
|
||||
|
|
@ -75,8 +75,8 @@ func (f *Frame) Reopen() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MustSetBit sets a bit on the frame. Panic on error.
|
||||
func (f *Frame) MustSetBit(view string, rowID, columnID uint64, t *time.Time) (changed bool) {
|
||||
// MustSetBit sets a bit on the field. Panic on error.
|
||||
func (f *Field) MustSetBit(view string, rowID, columnID uint64, t *time.Time) (changed bool) {
|
||||
changed, err := f.SetBit(view, rowID, columnID, t)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -84,23 +84,23 @@ func (f *Frame) MustSetBit(view string, rowID, columnID uint64, t *time.Time) (c
|
|||
return changed
|
||||
}
|
||||
|
||||
// Ensure frame can set its cache
|
||||
func TestFrame_SetCacheSize(t *testing.T) {
|
||||
f := MustOpenFrame()
|
||||
// Ensure field can set its cache
|
||||
func TestField_SetCacheSize(t *testing.T) {
|
||||
f := MustOpenField()
|
||||
defer f.Close()
|
||||
cacheSize := uint32(100)
|
||||
|
||||
// Set & retrieve frame cache size.
|
||||
// Set & retrieve field cache size.
|
||||
if err := f.SetCacheSize(cacheSize); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if q := f.CacheSize(); q != cacheSize {
|
||||
t.Fatalf("unexpected frame cache size: %d", q)
|
||||
t.Fatalf("unexpected field cache size: %d", q)
|
||||
}
|
||||
|
||||
// Reload frame and verify that it is persisted.
|
||||
// Reload field and verify that it is persisted.
|
||||
if err := f.Reopen(); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if q := f.CacheSize(); q != cacheSize {
|
||||
t.Fatalf("unexpected frame cache size (reopen): %d", q)
|
||||
t.Fatalf("unexpected field cache size (reopen): %d", q)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ 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.FieldOptions{})
|
||||
func (h *Holder) MustCreateFrameIfNotExists(index, frame string) *Field {
|
||||
f, err := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}).CreateFieldIfNotExists(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.FieldOptions{})
|
||||
f, err := idx.CreateFieldIfNotExists(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.FieldOptions{CacheType: pilosa.CacheTypeRanked})
|
||||
f, err := idx.CreateFieldIfNotExists(frame, pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,20 +73,20 @@ func (i *Index) Reopen() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// CreateFrame creates a frame with the given options.
|
||||
func (i *Index) CreateFrame(name string, opt pilosa.FieldOptions) (*Frame, error) {
|
||||
// CreateField creates a field with the given options.
|
||||
func (i *Index) CreateField(name string, opt pilosa.FieldOptions) (*Field, error) {
|
||||
f, err := i.Index.CreateField(name, opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Frame{Field: f}, nil
|
||||
return &Field{Field: f}, nil
|
||||
}
|
||||
|
||||
// CreateFrameIfNotExists creates a frame with the given options if it doesn't exist.
|
||||
func (i *Index) CreateFrameIfNotExists(name string, opt pilosa.FieldOptions) (*Frame, error) {
|
||||
// CreateFieldIfNotExists creates a field with the given options if it doesn't exist.
|
||||
func (i *Index) CreateFieldIfNotExists(name string, opt pilosa.FieldOptions) (*Field, error) {
|
||||
f, err := i.Index.CreateFieldIfNotExists(name, opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Frame{Field: f}, nil
|
||||
return &Field{Field: f}, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue