mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
FB-1188 - Fixed ttl parseDuration
This commit is contained in:
parent
6d18d9e0c4
commit
5f640aab0c
2 changed files with 9 additions and 23 deletions
|
|
@ -1073,19 +1073,12 @@ func (s Serializer) decodeFieldOptions(options *pb.FieldOptions, m *pilosa.Field
|
|||
m.Scale = options.Scale
|
||||
m.BitDepth = uint64(options.BitDepth)
|
||||
m.TimeQuantum = pilosa.TimeQuantum(options.TimeQuantum)
|
||||
// Ttl is optional, it might not exist on some data
|
||||
// To prevent "ParseDuration error:" logs showwing for the empty Ttl values, set those emtpy Ttl as 0
|
||||
if options.Ttl != "" {
|
||||
ttlVal, err := time.ParseDuration(options.Ttl)
|
||||
if err != nil {
|
||||
m.Ttl = 0
|
||||
fmt.Println(fmt.Errorf("ParseDuration error: %v", err))
|
||||
} else {
|
||||
m.Ttl = ttlVal
|
||||
}
|
||||
} else {
|
||||
m.Ttl = 0
|
||||
ttlValue, err := time.ParseDuration(options.Ttl)
|
||||
if err != nil {
|
||||
ttlValue = 0
|
||||
fmt.Println(fmt.Errorf("ParseDuration error: %v", err))
|
||||
}
|
||||
m.Ttl = ttlValue
|
||||
m.TimeUnit = options.TimeUnit
|
||||
m.Keys = options.Keys
|
||||
m.ForeignIndex = options.ForeignIndex
|
||||
|
|
|
|||
15
hack.go
15
hack.go
|
|
@ -59,18 +59,11 @@ func UnmarshalFieldOptions(name string, createdAt int64, buf []byte) (*FieldInfo
|
|||
fi.Options.Base = pbi.Base
|
||||
fi.Options.BitDepth = pbi.BitDepth
|
||||
fi.Options.TimeQuantum = TimeQuantum(pbi.TimeQuantum)
|
||||
// Ttl is optional, it might not exist on some data
|
||||
// for the empty Ttl values, set those emtpy Ttl as 0
|
||||
if pbi.Ttl != "" {
|
||||
ttlVal, err := time.ParseDuration(pbi.Ttl)
|
||||
if err != nil {
|
||||
fi.Options.Ttl = 0
|
||||
} else {
|
||||
fi.Options.Ttl = ttlVal
|
||||
}
|
||||
} else {
|
||||
fi.Options.Ttl = 0
|
||||
ttlValue, err := time.ParseDuration(pbi.Ttl)
|
||||
if err != nil {
|
||||
ttlValue = 0
|
||||
}
|
||||
fi.Options.Ttl = ttlValue
|
||||
fi.Options.Keys = pbi.Keys
|
||||
fi.Options.NoStandardView = pbi.NoStandardView
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue