mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
handle insert into timequantum fields with default 'now' time (fb-1868) (#2398)
* handle insert into timequantum fields with default 'now' time
* allocate on the stack
(cherry picked from commit 18fe6a35f6)
This commit is contained in:
parent
3b233d271d
commit
5e151eed0e
1 changed files with 19 additions and 0 deletions
|
|
@ -168,6 +168,9 @@ func (i *insertRowIter) Next(ctx context.Context) (types.Row, error) {
|
|||
return nil, errors.Wrap(err, "setting up batch")
|
||||
}
|
||||
|
||||
var qbatchTime fbbatch.QuantizedTime
|
||||
qbatchTime.Set(time.Now().UTC())
|
||||
|
||||
// row is the single instance of batch.Row allocated. It is re-used
|
||||
// throughout the for loop to minimize memory allocation.
|
||||
var row fbbatch.Row
|
||||
|
|
@ -249,6 +252,22 @@ func (i *insertRowIter) Next(ctx context.Context) (types.Row, error) {
|
|||
row.Values[posVals[idx]] = eval
|
||||
}
|
||||
|
||||
case pilosa.FieldTypeTime:
|
||||
row.Time = qbatchTime
|
||||
switch v := eval.(type) {
|
||||
case []int64:
|
||||
uint64s := make([]uint64, len(v))
|
||||
for i := range v {
|
||||
if v[i] < 0 {
|
||||
return nil, sql3.NewErrInternalf("converting negative slice value to uint64: %d", v[i])
|
||||
}
|
||||
uint64s[i] = uint64(v[i])
|
||||
}
|
||||
row.Values[posVals[idx]] = uint64s
|
||||
default:
|
||||
row.Values[posVals[idx]] = eval
|
||||
}
|
||||
|
||||
case pilosa.FieldTypeInt:
|
||||
if eval != nil {
|
||||
v, ok := eval.(int64)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue