Skip to content
Snippets Groups Projects
Unverified Commit 4df94cf3 authored by XuPeng-SH's avatar XuPeng-SH Committed by GitHub
Browse files

(tae): support timestamp (#2820)

parent 7443f9e9
No related branches found
No related tags found
No related merge requests found
......@@ -106,6 +106,14 @@ func CompareGeneric(a, b any, t types.Type) int {
} else {
return 0
}
case types.T_timestamp:
if a.(types.Timestamp) > b.(types.Timestamp) {
return 1
} else if a.(types.Timestamp) < b.(types.Timestamp) {
return -1
} else {
return 0
}
case types.T_date:
if a.(types.Date) > b.(types.Date) {
return 1
......
......@@ -71,6 +71,9 @@ func AppendValue(vec *gvec.Vector, v any) {
case types.T_date:
vvals := vec.Col.([]types.Date)
vec.Col = append(vvals, v.(types.Date))
case types.T_timestamp:
vvals := vec.Col.([]types.Timestamp)
vec.Col = append(vvals, v.(types.Timestamp))
case types.T_datetime:
vvals := vec.Col.([]types.Datetime)
vec.Col = append(vvals, v.(types.Datetime))
......
......@@ -136,6 +136,8 @@ func EncodeKey(key any, typ types.Type) ([]byte, error) {
} else {
panic("unsupported type")
}
case types.T_timestamp:
return encoding.EncodeTimestamp(key.(types.Timestamp)), nil
case types.T_datetime:
if v, ok := key.(types.Datetime); ok {
return encoding.EncodeDatetime(v), nil
......@@ -351,6 +353,22 @@ func ProcessVector(vec *vector.Vector, offset uint32, length uint32, task func(v
}
}
}
case types.T_timestamp:
vs := vec.Col.([]types.Timestamp)[offset:]
if keyselects == nil {
for i, v := range vs {
if err := task(v, uint32(i)); err != nil {
return err
}
}
} else {
for _, idx := range idxes {
v := vs[idx]
if err := task(v, idx); err != nil {
return err
}
}
}
case types.T_date:
vs := vec.Col.([]types.Date)[offset:]
if keyselects == nil {
......
......@@ -349,6 +349,25 @@ func (idx *simpleTableIndex) BatchInsert(col *gvec.Vector, start, count int, row
idx.tree[v] = row
row++
}
case types.T_timestamp:
data := vals.([]types.Timestamp)
if dedupCol {
set := make(map[types.Timestamp]bool)
for _, v := range data[start : start+count] {
if _, ok := set[v]; ok {
return idata.ErrDuplicate
}
set[v] = true
}
break
}
for _, v := range data[start : start+count] {
if _, ok := idx.tree[v]; ok {
return idata.ErrDuplicate
}
idx.tree[v] = row
row++
}
case types.T_datetime:
data := vals.([]types.Datetime)
if dedupCol {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment