mirror of https://github.com/milvus-io/milvus.git
Fix ParseHybridTs return type to int64 (#10583)
Signed-off-by: yangxuan <xuan.yang@zilliz.com>pull/10720/head
parent
169af67eb1
commit
bb7e3d3e70
|
@ -423,7 +423,7 @@ func (t *DescribeCollectionReqTask) Execute(ctx context.Context) error {
|
|||
|
||||
t.Rsp.CreatedTimestamp = collInfo.CreateTime
|
||||
createdPhysicalTime, _ := tsoutil.ParseHybridTs(collInfo.CreateTime)
|
||||
t.Rsp.CreatedUtcTimestamp = createdPhysicalTime
|
||||
t.Rsp.CreatedUtcTimestamp = uint64(createdPhysicalTime)
|
||||
t.Rsp.Aliases = t.core.MetaTable.ListAliases(collInfo.ID)
|
||||
t.Rsp.StartPositions = collInfo.GetStartPositions()
|
||||
return nil
|
||||
|
@ -455,7 +455,7 @@ func (t *ShowCollectionReqTask) Execute(ctx context.Context) error {
|
|||
t.Rsp.CollectionIds = append(t.Rsp.CollectionIds, meta.ID)
|
||||
t.Rsp.CreatedTimestamps = append(t.Rsp.CreatedTimestamps, meta.CreateTime)
|
||||
physical, _ := tsoutil.ParseHybridTs(meta.CreateTime)
|
||||
t.Rsp.CreatedUtcTimestamps = append(t.Rsp.CreatedUtcTimestamps, physical)
|
||||
t.Rsp.CreatedUtcTimestamps = append(t.Rsp.CreatedUtcTimestamps, uint64(physical))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -716,7 +716,7 @@ func (t *ShowPartitionReqTask) Execute(ctx context.Context) error {
|
|||
t.Rsp.CreatedUtcTimestamps = make([]uint64, 0, len(coll.PartitionCreatedTimestamps))
|
||||
for _, ts := range coll.PartitionCreatedTimestamps {
|
||||
physical, _ := tsoutil.ParseHybridTs(ts)
|
||||
t.Rsp.CreatedUtcTimestamps = append(t.Rsp.CreatedUtcTimestamps, physical)
|
||||
t.Rsp.CreatedUtcTimestamps = append(t.Rsp.CreatedUtcTimestamps, uint64(physical))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -37,10 +37,10 @@ func ParseTS(ts uint64) (time.Time, uint64) {
|
|||
}
|
||||
|
||||
// ParseHybridTs parses the ts to (physical, logical), physical part is of utc-timestamp format.
|
||||
func ParseHybridTs(ts uint64) (uint64, uint64) {
|
||||
func ParseHybridTs(ts uint64) (int64, int64) {
|
||||
logical := ts & logicalBitsMask
|
||||
physical := ts >> logicalBits
|
||||
return physical, logical
|
||||
return int64(physical), int64(logical)
|
||||
}
|
||||
|
||||
// Mod24H parses the ts to millisecond in one day
|
||||
|
@ -51,6 +51,13 @@ func Mod24H(ts uint64) uint64 {
|
|||
return (physical << logicalBits) | logical
|
||||
}
|
||||
|
||||
// AddPhysicalTimeOnTs adds physical time on ts and return ts
|
||||
func AddPhysicalTimeOnTs(timeInMs int64, ts uint64) uint64 {
|
||||
physical, logical := ParseHybridTs(ts)
|
||||
|
||||
return ComposeTS(physical+timeInMs, logical)
|
||||
}
|
||||
|
||||
// NewTSOKVBase returns a etcdkv.EtcdKV object
|
||||
func NewTSOKVBase(etcdEndpoints []string, tsoRoot, subPath string) (*etcdkv.EtcdKV, error) {
|
||||
return etcdkv.NewEtcdKV(etcdEndpoints, path.Join(tsoRoot, subPath))
|
||||
|
|
|
@ -22,9 +22,9 @@ import (
|
|||
func TestParseHybridTs(t *testing.T) {
|
||||
var ts uint64 = 426152581543231492
|
||||
physical, logical := ParseHybridTs(ts)
|
||||
physicalTime := time.Unix(int64(physical/1000), int64(physical)%1000*time.Millisecond.Nanoseconds())
|
||||
physicalTime := time.Unix(physical/1000, physical%1000*time.Millisecond.Nanoseconds())
|
||||
log.Debug("TestParseHybridTs",
|
||||
zap.Uint64("physical", physical),
|
||||
zap.Uint64("logical", logical),
|
||||
zap.Int64("physical", physical),
|
||||
zap.Int64("logical", logical),
|
||||
zap.Any("physical time", physicalTime))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue