mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
ditch OptFieldTypeTimeWithOptions
This commit is contained in:
parent
45e2951e87
commit
3d54f737cd
4 changed files with 5 additions and 9 deletions
8
field.go
8
field.go
|
|
@ -131,11 +131,7 @@ func OptFieldTypeInt(min, max int64) FieldOption {
|
|||
}
|
||||
}
|
||||
|
||||
func OptFieldTypeTime(timeQuantum TimeQuantum) FieldOption {
|
||||
return OptFieldTypeTimeOptions(timeQuantum, false)
|
||||
}
|
||||
|
||||
func OptFieldTypeTimeOptions(timeQuantum TimeQuantum, noStandardView bool) FieldOption {
|
||||
func OptFieldTypeTime(timeQuantum TimeQuantum, opt ...bool) FieldOption {
|
||||
return func(fo *FieldOptions) error {
|
||||
if fo.Type != "" {
|
||||
return errors.Errorf("field type is already set to: %s", fo.Type)
|
||||
|
|
@ -145,7 +141,7 @@ func OptFieldTypeTimeOptions(timeQuantum TimeQuantum, noStandardView bool) Field
|
|||
}
|
||||
fo.Type = FieldTypeTime
|
||||
fo.TimeQuantum = timeQuantum
|
||||
fo.NoStandardView = noStandardView
|
||||
fo.NoStandardView = len(opt) >= 1 && opt[0]
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -704,7 +704,7 @@ func (h *Handler) handlePostField(w http.ResponseWriter, r *http.Request) {
|
|||
case pilosa.FieldTypeInt:
|
||||
fos = append(fos, pilosa.OptFieldTypeInt(*req.Options.Min, *req.Options.Max))
|
||||
case pilosa.FieldTypeTime:
|
||||
fos = append(fos, pilosa.OptFieldTypeTimeOptions(*req.Options.TimeQuantum, req.Options.NoStandardView))
|
||||
fos = append(fos, pilosa.OptFieldTypeTime(*req.Options.TimeQuantum, req.Options.NoStandardView))
|
||||
case pilosa.FieldTypeMutex:
|
||||
fos = append(fos, pilosa.OptFieldTypeMutex(*req.Options.CacheType, *req.Options.CacheSize))
|
||||
case pilosa.FieldTypeBool:
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ func TestIndex_CreateField(t *testing.T) {
|
|||
defer index.Close()
|
||||
|
||||
// Create field with explicit quantum with no standard view
|
||||
f, err := index.CreateField("f", pilosa.OptFieldTypeTimeOptions(pilosa.TimeQuantum("YMDH"), true))
|
||||
f, err := index.CreateField("f", pilosa.OptFieldTypeTime(pilosa.TimeQuantum("YMDH"), true))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if q := f.TimeQuantum(); q != pilosa.TimeQuantum("YMDH") {
|
||||
|
|
|
|||
|
|
@ -634,7 +634,7 @@ func TestMain_ImportTimestampNoStandardView(t *testing.T) {
|
|||
}
|
||||
|
||||
// Create field.
|
||||
if _, err := m.API.CreateField(context.Background(), indexName, fieldName, pilosa.OptFieldTypeTimeOptions(pilosa.TimeQuantum("YMD"), true)); err != nil {
|
||||
if _, err := m.API.CreateField(context.Background(), indexName, fieldName, pilosa.OptFieldTypeTime(pilosa.TimeQuantum("YMD"), true)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue