mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
avoid creating a slice of nil timestamps on Import()
This commit is contained in:
parent
94f4015196
commit
7f41c0256c
2 changed files with 12 additions and 2 deletions
6
frame.go
6
frame.go
|
|
@ -834,7 +834,11 @@ func (f *Frame) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) erro
|
|||
// Split import data by fragment.
|
||||
dataByFragment := make(map[importKey]importData)
|
||||
for i := range rowIDs {
|
||||
rowID, columnID, timestamp := rowIDs[i], columnIDs[i], timestamps[i]
|
||||
rowID, columnID := rowIDs[i], columnIDs[i]
|
||||
var timestamp *time.Time
|
||||
if len(timestamps) > i {
|
||||
timestamp = timestamps[i]
|
||||
}
|
||||
|
||||
var standard, inverse []string
|
||||
if timestamp == nil {
|
||||
|
|
|
|||
8
index.go
8
index.go
|
|
@ -642,7 +642,8 @@ func (i *Index) openInputDefinitions() error {
|
|||
// InputBits Process the []Bit though the Frame import process
|
||||
func (i *Index) InputBits(frame string, bits []*Bit) error {
|
||||
var rowIDs, columnIDs []uint64
|
||||
timestamps := make([]*time.Time, len(bits))
|
||||
var timestamps []*time.Time
|
||||
|
||||
f := i.Frame(frame)
|
||||
if f == nil {
|
||||
return fmt.Errorf("Frame not found: %s", frame)
|
||||
|
|
@ -657,6 +658,11 @@ func (i *Index) InputBits(frame string, bits []*Bit) error {
|
|||
|
||||
// Convert timestamps to time.Time.
|
||||
if bit.Timestamp > 0 {
|
||||
// Don't create a full timestamps slice unless
|
||||
// at least one bit contains a timestamp.
|
||||
if len(timestamps) == 0 {
|
||||
timestamps = make([]*time.Time, len(bits))
|
||||
}
|
||||
t := time.Unix(bit.Timestamp, 0)
|
||||
timestamps[i] = &t
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue