本文整理汇总了Golang中github.com/pingcap/tidb/util/codec.EncodeUint函数的典型用法代码示例。如果您正苦于以下问题:Golang EncodeUint函数的具体用法?Golang EncodeUint怎么用?Golang EncodeUint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EncodeUint函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: encodeHashDataKey
func (t *TxStructure) encodeHashDataKey(key []byte, field []byte) kv.Key {
ek := make([]byte, 0, len(t.prefix)+len(key)+len(field)+30)
ek = append(ek, t.prefix...)
ek = codec.EncodeBytes(ek, key)
ek = codec.EncodeUint(ek, uint64(HashData))
return codec.EncodeBytes(ek, field)
}
示例2: datumExpr
func datumExpr(d types.Datum) *tipb.Expr {
expr := new(tipb.Expr)
switch d.Kind() {
case types.KindInt64:
expr.Tp = tipb.ExprType_Int64
expr.Val = codec.EncodeInt(nil, d.GetInt64())
case types.KindUint64:
expr.Tp = tipb.ExprType_Uint64
expr.Val = codec.EncodeUint(nil, d.GetUint64())
case types.KindString:
expr.Tp = tipb.ExprType_String
expr.Val = d.GetBytes()
case types.KindBytes:
expr.Tp = tipb.ExprType_Bytes
expr.Val = d.GetBytes()
case types.KindFloat32:
expr.Tp = tipb.ExprType_Float32
expr.Val = codec.EncodeFloat(nil, d.GetFloat64())
case types.KindFloat64:
expr.Tp = tipb.ExprType_Float64
expr.Val = codec.EncodeFloat(nil, d.GetFloat64())
case types.KindMysqlDuration:
expr.Tp = tipb.ExprType_MysqlDuration
expr.Val = codec.EncodeInt(nil, int64(d.GetMysqlDuration().Duration))
case types.KindMysqlDecimal:
expr.Tp = tipb.ExprType_MysqlDecimal
expr.Val = codec.EncodeDecimal(nil, d)
default:
expr.Tp = tipb.ExprType_Null
}
return expr
}
示例3: encodeListDataKey
func (t *TxStructure) encodeListDataKey(key []byte, index int64) kv.Key {
ek := make([]byte, 0, len(t.prefix)+len(key)+36)
ek = append(ek, t.prefix...)
ek = codec.EncodeBytes(ek, key)
ek = codec.EncodeUint(ek, uint64(ListData))
return codec.EncodeInt(ek, index)
}
示例4: encodeStringDataKey
func (t *TxStructure) encodeStringDataKey(key []byte) kv.Key {
// for codec Encode, we may add extra bytes data, so here and following encode
// we will use extra length like 4 for a little optimization.
ek := make([]byte, 0, len(t.prefix)+len(key)+24)
ek = append(ek, t.prefix...)
ek = codec.EncodeBytes(ek, key)
return codec.EncodeUint(ek, uint64(StringData))
}
示例5: doCommit
func (txn *dbTxn) doCommit() error {
b := txn.store.newBatch()
keysLocked := make([]string, 0, len(txn.snapshotVals))
defer func() {
for _, key := range keysLocked {
txn.store.unLockKeys(key)
}
}()
// check lazy condition pairs
if err := txn.UnionStore.CheckLazyConditionPairs(); err != nil {
return errors.Trace(err)
}
txn.Snapshot.Release()
// Check locked keys
for k := range txn.snapshotVals {
err := txn.store.tryConditionLockKey(txn.tid, k)
if err != nil {
return errors.Trace(err)
}
keysLocked = append(keysLocked, k)
}
// disable version provider temporarily
providerMu.Lock()
defer providerMu.Unlock()
curVer, err := globalVersionProvider.CurrentVersion()
if err != nil {
return errors.Trace(err)
}
err = txn.each(func(iter kv.Iterator) error {
metaKey := codec.EncodeBytes(nil, []byte(iter.Key()))
// put dummy meta key, write current version
b.Put(metaKey, codec.EncodeUint(nil, curVer.Ver))
mvccKey := MvccEncodeVersionKey(kv.Key(iter.Key()), curVer)
if len(iter.Value()) == 0 { // Deleted marker
b.Put(mvccKey, nil)
} else {
b.Put(mvccKey, iter.Value())
}
return nil
})
if err != nil {
return errors.Trace(err)
}
// Update commit version.
txn.version = curVer
return txn.store.writeBatch(b)
}
示例6: doCommit
func (txn *dbTxn) doCommit() error {
b := txn.store.newBatch()
keysLocked := make([]string, 0, len(txn.snapshotVals))
defer func() {
for _, key := range keysLocked {
txn.store.unLockKeys(key)
}
}()
// Check locked keys
for k, v := range txn.snapshotVals {
err := txn.store.tryConditionLockKey(txn.tid, k, v)
if err != nil {
return errors.Trace(err)
}
keysLocked = append(keysLocked, k)
}
// Check dirty store
curVer, err := globalVersionProvider.CurrentVersion()
if err != nil {
return errors.Trace(err)
}
err = txn.each(func(iter kv.Iterator) error {
metaKey := codec.EncodeBytes(nil, []byte(iter.Key()))
// put dummy meta key, write current version
b.Put(metaKey, codec.EncodeUint(nil, curVer.Ver))
mvccKey := MvccEncodeVersionKey(kv.Key(iter.Key()), curVer)
if len(iter.Value()) == 0 { // Deleted marker
b.Put(mvccKey, nil)
} else {
b.Put(mvccKey, iter.Value())
}
return nil
})
if err != nil {
return errors.Trace(err)
}
// Update commit version.
txn.version = curVer
// Release read lock before write. Workaround for BoltDB.
txn.Snapshot.Release()
return txn.store.writeBatch(b)
}
示例7: datumToPBExpr
func (b *executorBuilder) datumToPBExpr(client kv.Client, d types.Datum) *tipb.Expr {
var tp tipb.ExprType
var val []byte
switch d.Kind() {
case types.KindNull:
tp = tipb.ExprType_Null
case types.KindInt64:
tp = tipb.ExprType_Int64
val = codec.EncodeInt(nil, d.GetInt64())
case types.KindUint64:
tp = tipb.ExprType_Uint64
val = codec.EncodeUint(nil, d.GetUint64())
case types.KindString:
tp = tipb.ExprType_String
val = d.GetBytes()
case types.KindBytes:
tp = tipb.ExprType_Bytes
val = d.GetBytes()
case types.KindFloat32:
tp = tipb.ExprType_Float32
val = codec.EncodeFloat(nil, d.GetFloat64())
case types.KindFloat64:
tp = tipb.ExprType_Float64
val = codec.EncodeFloat(nil, d.GetFloat64())
case types.KindMysqlDuration:
tp = tipb.ExprType_MysqlDuration
val = codec.EncodeInt(nil, int64(d.GetMysqlDuration().Duration))
case types.KindMysqlDecimal:
tp = tipb.ExprType_MysqlDecimal
val = codec.EncodeDecimal(nil, d.GetMysqlDecimal())
default:
return nil
}
if !client.SupportRequestType(kv.ReqTypeSelect, int64(tp)) {
return nil
}
return &tipb.Expr{Tp: tp.Enum(), Val: val}
}
示例8: hashDataKeyPrefix
func (t *TxStructure) hashDataKeyPrefix(key []byte) kv.Key {
ek := make([]byte, 0, len(t.prefix)+len(key)+24)
ek = append(ek, t.prefix...)
ek = codec.EncodeBytes(ek, key)
return codec.EncodeUint(ek, uint64(HashData))
}
示例9: encodeHashMetaKey
func (t *TxStructure) encodeHashMetaKey(key []byte) []byte {
ek := make([]byte, 0, len(t.prefix)+len(key)+24)
ek = append(ek, t.prefix...)
ek = codec.EncodeBytes(ek, key)
return codec.EncodeUint(ek, uint64(HashMeta))
}