Skip to content
Snippets Groups Projects
Unverified Commit 4a69d2aa authored by triump2020's avatar triump2020 Committed by GitHub
Browse files

Transaction timestamp2 (#4481)

Approved by: @XuPeng-SH
parent f8161d34
No related branches found
No related tags found
No related merge requests found
......@@ -195,16 +195,13 @@ func (sf *segmentFile) Replay() error {
var ts types.TS
var idx uint64
if len(info) > 2 {
//ts, err = strconv.ParseUint(info[2], 10, 64)
//if err != nil {
// return err
//}
ts = types.StringToTS(info[2])
if fileName[1] == INDEX_SUFFIX {
idx, err = strconv.ParseUint(info[2], 10, 64)
if err != nil {
return err
}
} else {
ts = types.StringToTS(info[2])
}
}
if file.snode.GetCols() > uint32(len(bf.columns)) && fileName[1] != INDEX_SUFFIX {
......
......@@ -30,10 +30,8 @@ func TxnMgrField(mgr *TxnManager) zap.Field {
func (mgr *TxnManager) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
enc.AddUint64("currId", mgr.IdAlloc.Get())
//enc.AddUint64("currTs", mgr.TsAlloc.Get())
enc.AddByteString("currTs", mgr.TsAlloc.Get().ToSlice())
//enc.AddUint64("safeTs", mgr.StatSafeTS())
enc.AddByteString("currTs", mgr.StatSafeTS().ToSlice())
enc.AddString("currTs", mgr.TsAlloc.Get().ToString())
enc.AddString("currTs", mgr.StatSafeTS().ToString())
return
}
......@@ -41,12 +39,10 @@ func (txn *Txn) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
txn.RLock()
defer txn.RUnlock()
enc.AddUint64("id", txn.ID)
//enc.AddUint64("startTs", txn.StartTS)
enc.AddByteString("startTs", txn.StartTS.ToSlice())
enc.AddString("startTs", txn.StartTS.ToString())
enc.AddString("state", txnif.TxnStrState(txn.State))
if !txn.IsActiveLocked() {
//enc.AddUint64("commitTs", txn.CommitTS)
enc.AddByteString("commitTs", txn.CommitTS.ToSlice())
enc.AddString("commitTs", txn.CommitTS.ToString())
}
return
}
......@@ -15,10 +15,13 @@
package types
import (
"fmt"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/encoding"
"golang.org/x/exp/constraints"
"math"
"strconv"
"strings"
)
type TypeId = types.T
......@@ -126,17 +129,19 @@ func (ts TS) GreaterEq(rhs TS) bool {
}
func (ts TS) ToString() (s string) {
s = string(ts[:])
return
}
func (ts TS) ToSlice() (s []byte) {
s = ts[:]
return
return fmt.Sprintf("%d-%d", encoding.DecodeInt64(ts[4:12]), encoding.DecodeUint32(ts[:4]))
}
func StringToTS(s string) (ts TS) {
copy(ts[:], s)
tmp := strings.Split(s, "-")
if len(tmp) == 1 {
panic("format of s is wrong, lack of - ")
}
pTime, _ := strconv.ParseInt(tmp[0], 10, 64)
copy(ts[4:12], encoding.EncodeInt64(pTime))
lTime, _ := strconv.ParseUint(tmp[1], 10, 32)
copy(ts[:4], encoding.EncodeUint32(uint32(lTime)))
return
}
......
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